so i have this script here thats supposed to save a players location when used, then when used a second time, return the player to the location he was when he first used it. the script works fine how it is for a single player mod, but not a multi-player mod, so i need help making it so it is, here's the script:
#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
if(nEvent != X2_ITEM_EVENT_ACTIVATE)return;
object oPC = GetItemActivator();
object oStone = GetItemPossessedBy(oPC, "whitestone");//Put your item tag here.
location lPCLocation = GetLocation(oPC);
location lStoredLocation = GetLocalLocation(oStone, "STORED_LOCATION");
if (!GetIsObjectValid(GetAreaFromLocation(lStoredLocation)))
{
SetLocalLocation(oStone, "STORED_LOCATION", lPCLocation);
SendMessageToPC(oPC, "Your location has been saved.");
return;
}
if (GetIsObjectValid(GetAreaFromLocation(lStoredLocation)))
{
AssignCommand(oPC, ActionJumpToLocation(lStoredLocation));
DestroyObject(oStone, 1.0);
SendMessageToPC(oPC, "You have been teleported to your saved location and your stone has been destroyed.");
}
}
thanks in advance
zero
need help altering a script...
Débuté par
zero-feeling
, févr. 19 2011 10:48
#1
Posté 19 février 2011 - 10:48
#2
Posté 19 février 2011 - 11:52
i see no reason it would work in Single player but not work in Multi player. Either way the script does have one major bug. If the PC has more then one of the items in there possesion the
object oStone = GetItemPossessedBy(oPC, "whitestone");
line may not be returning the same item that was used.
You would be better off Identifing the item with:
object oStone = GetItemActivated();
This will garentee that the item used is the same one you are storing your location on. This should be fixed in both the single and multi player Modules.
object oStone = GetItemPossessedBy(oPC, "whitestone");
line may not be returning the same item that was used.
You would be better off Identifing the item with:
object oStone = GetItemActivated();
This will garentee that the item used is the same one you are storing your location on. This should be fixed in both the single and multi player Modules.
#3
Posté 20 février 2011 - 12:08
great, i will give this a try
#4
Posté 20 février 2011 - 12:14
// zero_loc_itm
#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
if(nEvent != X2_ITEM_EVENT_ACTIVATE){return;}
object oPC = GetItemActivator();
location lPCLocation = GetLocation(oPC);
//object oStone = GetItemPossessedBy(oPC, "whitestone");//Put your item tag here.
object oStone = GetItemActivated();
location lStoredLocation = GetLocalLocation(oStone, "STORED_LOCATION");
if (!GetIsObjectValid(GetAreaFromLocation(lStoredLocation)))
{
SetLocalLocation(oStone, "STORED_LOCATION", lPCLocation);
SendMessageToPC(oPC, "Your location has been saved.");
return;
}
if (GetIsObjectValid(GetAreaFromLocation(lStoredLocation)))
{
AssignCommand(oPC, ActionJumpToLocation(lStoredLocation));
DestroyObject(oStone, 1.0);
SendMessageToPC(oPC, "You have been teleported to your saved location and your stone has been destroyed.");
}
}
so this is what Lightfoot8 is suggesting. Oh and if you want to insure the item being used is your "whitestone" use
if( GetTag(oStone)==""whitestone")
{
// then script here
}
#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
if(nEvent != X2_ITEM_EVENT_ACTIVATE){return;}
object oPC = GetItemActivator();
location lPCLocation = GetLocation(oPC);
//object oStone = GetItemPossessedBy(oPC, "whitestone");//Put your item tag here.
object oStone = GetItemActivated();
location lStoredLocation = GetLocalLocation(oStone, "STORED_LOCATION");
if (!GetIsObjectValid(GetAreaFromLocation(lStoredLocation)))
{
SetLocalLocation(oStone, "STORED_LOCATION", lPCLocation);
SendMessageToPC(oPC, "Your location has been saved.");
return;
}
if (GetIsObjectValid(GetAreaFromLocation(lStoredLocation)))
{
AssignCommand(oPC, ActionJumpToLocation(lStoredLocation));
DestroyObject(oStone, 1.0);
SendMessageToPC(oPC, "You have been teleported to your saved location and your stone has been destroyed.");
}
}
so this is what Lightfoot8 is suggesting. Oh and if you want to insure the item being used is your "whitestone" use
if( GetTag(oStone)==""whitestone")
{
// then script here
}
Modifié par Greyfort, 20 février 2011 - 12:17 .
#5
Posté 20 février 2011 - 12:56
@GrayFort.
There is no reason to check the tag. The Tag has already been checked by running the script in the first place. Since this is TagBased Scripting the Tag of the Item is matching the name of the script. All the Tag check will do in this script is make it harder to add the Script to another item if he ever tries to do that. The script would them have to be modified. The Script name and the Tag Check in the code would always have to match. Much simpler to just let the name of the script verify the tag of the object.
There is no reason to check the tag. The Tag has already been checked by running the script in the first place. Since this is TagBased Scripting the Tag of the Item is matching the name of the script. All the Tag check will do in this script is make it harder to add the Script to another item if he ever tries to do that. The script would them have to be modified. The Script name and the Tag Check in the code would always have to match. Much simpler to just let the name of the script verify the tag of the object.
Modifié par Lightfoot8, 20 février 2011 - 12:56 .
#6
Posté 20 février 2011 - 01:03
I didn't even notice that, I was remebering from a old on activate item script that zero had sent me to look at, and he did not used tag based scripting. Forgive me Lightfoot/Zero my eyes are a bit foggy, been trying to figure out my mistake with item props.





Retour en haut







