Author Topic: Jail wand script help  (Read 493 times)

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Jail wand script help
« on: October 03, 2010, 10:42:55 pm »


               This is a script for a DM wand .It teleports oPC to a waypoint in the jail.

Problem:

1. The message is not sending ..it supposed to send to all players ..


2. Not in the script yet ..but I would also like it to place prison outfit on the character also so it is not removable so if they login after reset it will put them back in jail..I know I will need an oclient enter script to check for this clothing also. 

All help is appreciated

void MessageAll(string sMessage)
{
    object oPlayer = GetFirstPC();
    while(GetIsObjectValid(oPlayer))
        {
        SendMessageToPC(oPlayer,sMessage);
        oPlayer = GetNextPC();
        }
}
#include "x2_inc_switches"
void main()
{
int nEvent = GetUserDefinedItemEventNumber();
if(nEvent != X2_ITEM_EVENT_ACTIVATE) return;
object oUser = GetItemActivator();
if (!GetIsDM(oUser)) return;
object oPlayer = GetItemActivatedTarget();
object oWaypoint = GetWaypointByTag("jail1");
if (GetIsPC(oPlayer))
DelayCommand(5.0, AssignCommand(oPlayer, JumpToObject(oWaypoint)));
return;
object oPC  = GetItemActivatedTarget();
string oPCname = GetName(oPC);
MessageAll( "<cÖ2¦>Jail:</c>" + GetName(oPC) + "<cÖ2¦>has been sent to jail for crimes against the land !</c>   ");

}
'Image
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Jail wand script help
« Reply #1 on: October 04, 2010, 02:56:38 am »


               You have a "return;" just after the line "DelayCommand(5.0, AssignCommand(oPlayer, JumpToObject(oWaypoint)));" so it ends there. Remove that and players should get the message.
               
               

               


                     Modifié par GhostOfGod, 04 octobre 2010 - 01:57 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Jail wand script help
« Reply #2 on: October 04, 2010, 03:12:17 am »


               And to equip a jail outfit you might try something like this:

void MessageAll(string sMessage)
{
    object oPlayer = GetFirstPC();
    while(GetIsObjectValid(oPlayer))
    {
        SendMessageToPC(oPlayer,sMessage);
        oPlayer = GetNextPC();
    }
}
#include "x2_inc_switches"
void main()
{
    int nEvent = GetUserDefinedItemEventNumber();
    if(nEvent != X2_ITEM_EVENT_ACTIVATE) return;
    object oUser = GetItemActivator();
    if (!GetIsDM(oUser)) return;
    object oPlayer = GetItemActivatedTarget();
    object oWaypoint = GetWaypointByTag("jail1");
    if (GetIsPC(oPlayer))
    {
        object oOutfit = CreateItemOnObject("res ref of clothes", oPlayer);
        SetItemCursedFlag(oOutfit, TRUE);
        AssignCommand(oPlayer, ActionEquipItem(oOutfit, INVENTORY_SLOT_CHEST));
        DelayCommand(5.0, AssignCommand(oPlayer, JumpToObject(oWaypoint)));
        MessageAll( "Jail: " + GetName(oPlayer) +
        " has been sent to jail for crimes against the land!");
    }
}


I added lines to create an item on the targeted player and for them to equip the item and set the cursed flag of the item to true. Setting the cursed flag only makes the item undroppable. They can still unequip the item. If you want them to NOT be able to unequip the item then you will need to make a tag based script for the clothes that if it is UnEquipped, it will just automatically reequip the clothing. Something like so:

#include "x2_inc_switches"
void main()
{
    int nEvent = GetUserDefinedItemEventNumber();
    if (nEvent != X2_ITEM_EVENT_UNEQUIP)return;
    object oItem = GetPCItemLastUnequipped();
    object oPC = GetPCItemLastUnequippedBy();
    AssignCommand(oPC, ActionEquipItem(oItem, INVENTORY_SLOT_CHEST));
}


EDIT: The color code got lost in the post. Just letting you know in case you copy/paste it. Also edited the first script to get rid of a bit of redundancy.
               
               

               


                     Modifié par GhostOfGod, 04 octobre 2010 - 03:51 .
                     
                  


            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Jail wand script help
« Reply #3 on: October 04, 2010, 03:17:49 am »


               This is great I will get to work on putting this in and tinkering with it.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Jail wand script help
« Reply #4 on: October 05, 2010, 12:28:52 am »


               My character recently landed in Jail and I realised I needed a bail-out system, so I made one.
Essentially any other character can walk up to the jailer and bail someone out for 100 gold per level of the incarcerated PC. At the same time the jail int on the PC's database item is removed so they won't get put in jail again on the next reset.  The reason I made this is that a DM may not be on at the time to get someone out of jail.
               
               

               


                     Modifié par ffbj, 04 octobre 2010 - 11:31 .