Author Topic: Script works in a local game but not on dedicated server?  (Read 529 times)

Legacy_Drakantus

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« on: September 01, 2010, 02:10:31 am »


               This has been driving me crazy, because I thought my script was broken, but when I tested it in a local game (just going new game, picking my PW module, playing single player) it works perfectly.  I can't tell why it would work in one case but not the other.


This is the main script that doesn't work in the dedicated server, it is simply placed on a trigger that covers the starting location:

//This script will take affect as soon as the PC enters the module//Place this script on the OnEnter event of a generic trigger placed over//the module starting point//The purpose of this script is to send new players to the Welcome area,//and to send older players to the proper starting waypoint depending on//which faction they belong to.
#include "nw_i0_tool"void main()    {
    //define player    object oPC = GetEnteringObject();    object oFaction = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);    //define waypoint    object oStart00 = GetWaypointByTag("ZKW_STARTNEW");    //define Faction Objects    /*object oFDuergar = GetObjectByTag("ZK_F_DUERGAR");    object oFBandit = GetObjectByTag("ZK_F_BANDIT");    object oFBlkwdgypsy = GetObjectByTag("ZK_F_BLKWDGYPSY");    object oFBugbear = GetObjectByTag("ZK_F_BUGBEAR");    object oFGoblin = GetObjectByTag("ZK_F_GOBLIN");    object oFIcecavern = GetObjectByTag("ZK_F_ICECAVERN");    object oFKalarok = GetObjectByTag("ZK_F_KALAROK");    object oFKalarokbndt = GetObjectByTag("ZK_F_KALAROKBNDT");    object oFKandorgnoll = GetObjectByTag("ZK_F_KANDORGNOLL");    object oFNhanimal = GetObjectByTag("ZK_F_NHANIMAL");    object oFNhostevils = GetObjectByTag("ZK_F_NHOSTEVILS");    object oFNhostgobl = GetObjectByTag("ZK_F_NHOSTGOBL");    object oFShadowfrst = GetObjectByTag("ZK_F_SHADOWFRST");    object oFSthrnallnce = GetObjectByTag("ZK_F_STHRNALLNCE");    object oFUgroundfrst = GetObjectByTag("ZK_F_UGROUNDFRST");    object oFMyrath = GetObjectByTag("ZK_F_MYRATH");    object oFKayketh = GetObjectByTag("ZK_F_KAYKETH");    */
    if (oFaction == OBJECT_INVALID)        {        object item = GetFirstItemInInventory(oPC);        if(GetXP(oPC) == 0)            {            while (item != OBJECT_INVALID)                {                DestroyObject(item);                item = GetNextItemInInventory(oPC);                }            GiveXPToCreature(oPC, 700);            GiveGoldToCreature( oPC, 300);            }        AssignCommand(oPC,ActionJumpToObject(oStart00));        }
    else        {        string sFactionSkin = GetTag(oFaction);         //Tag of PC's Faction item        string sLeft = GetStringLeft(sFactionSkin, 8);        string sBindLoc;        string sBase = "ZK_BIND_";        if (sFactionSkin == "ZK_F01__________________________")            {            string sBindLoc = "S0";            //FloatingTextStringOnCreature("if statement triggered", oPC, TRUE);            string sJumpTag = sBase + sBindLoc;            string sFaction = GetStringLeft(sFactionSkin, 6);   // Actual Faction of PC            //FloatingTextStringOnCreature("sJumpTag- "+sJumpTag, oPC, TRUE);            object oJump = GetWaypointByTag(sJumpTag);            if (sFaction == "ZK_F01")                {                /*AdjustReputation(oPC,oFKalarokbndt,80);                AdjustReputation(oPC,oFKalarok,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */            }            if (sFaction == "ZK_F02")                {                }            if (sFaction == "ZK_F03")                {                }            if (sFaction == "ZK_F04")                {                }            if (sFaction == "ZK_F05")                {                }            if (sFaction == "ZK_F06")                {                }            if (sFaction == "ZK_F07")                {                /*AdjustReputation(oPC,oFMyrath,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F08")                {                }            if (sFaction == "ZK_F09")                {                /*AdjustReputation(oPC,oFKalarokbndt,80);                AdjustReputation(oPC,oFKalarok,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F10")                {                /*AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F11")                {                }            if (sFaction == "ZK_F12")                {                }            if (sFaction == "ZK_F13")                {                /*AdjustReputation(oPC,oFKalarokbndt,80);                AdjustReputation(oPC,oFKalarok,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F14")                {                }            if (sFaction == "ZK_F15")                {                /*AdjustReputation(oPC,oFKayketh,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F16")                {                }            if (sFaction == "ZK_F17")                {                }            if (sFaction == "ZK_F18")                {                }            AssignCommand (oPC,ActionJumpToObject(oJump));            }        else            {            string sBindLoc = GetStringRight (sFactionSkin, 2); // stored bind location            //FloatingTextStringOnCreature("else triggered", oPC, TRUE);            string sJumpTag = sBase + sBindLoc;            string sFaction = GetStringLeft(sFactionSkin, 6);   // Actual Faction of PC            //FloatingTextStringOnCreature("sJumpTag- "+sJumpTag, oPC, TRUE);            object oJump = GetWaypointByTag(sJumpTag);            if (sFaction == "ZK_F01")                {                /*AdjustReputation(oPC,oFKalarokbndt,80);                AdjustReputation(oPC,oFKalarok,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F02")                {                }            if (sFaction == "ZK_F03")                {                }            if (sFaction == "ZK_F04")                {                }            if (sFaction == "ZK_F05")                {                }            if (sFaction == "ZK_F06")                {                }            if (sFaction == "ZK_F07")                {                /*AdjustReputation(oPC,oFMyrath,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F08")                {                }            if (sFaction == "ZK_F09")                {                /*AdjustReputation(oPC,oFKalarokbndt,80);                AdjustReputation(oPC,oFKalarok,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F10")                {                /*AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F11")                {                }            if (sFaction == "ZK_F12")                {                }            if (sFaction == "ZK_F13")                {                /*AdjustReputation(oPC,oFKalarokbndt,80);                AdjustReputation(oPC,oFKalarok,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F14")                {                }            if (sFaction == "ZK_F15")                {                /*AdjustReputation(oPC,oFKayketh,80);                AdjustReputation(oPC,oFSthrnallnce,-100);                AdjustReputation(oPC,oFDuergar,-100);                */}            if (sFaction == "ZK_F16")                {                }            if (sFaction == "ZK_F17")                {                }            if (sFaction == "ZK_F18")                {                }            AssignCommand (oPC,ActionJumpToObject(oJump));            }        }    }

               
               

               


                     Modifié par Drakantus, 01 septembre 2010 - 01:26 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #1 on: September 01, 2010, 02:48:52 am »


               A little housekeeping if someone wanted to look at the above.


//This script will take affect as soon as the PC enters the module
//Place this script on the OnEnter event of a generic trigger placed over
//the module starting point
//The purpose of this script is to send new players to the Welcome area,
//and to send older players to the proper starting waypoint depending on
//which faction they belong to.
#include "nw_i0_tool"
void main()
{
//define player
object oPC = GetEnteringObject();
object oFaction = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
//define waypoint
object oStart00 = GetWaypointByTag("ZKW_STARTNEW");
//define Faction Objects
/*object oFDuergar = GetObjectByTag("ZK_F_DUERGAR");
object oFBandit = GetObjectByTag("ZK_F_BANDIT");
object oFBlkwdgypsy = GetObjectByTag("ZK_F_BLKWDGYPSY");
object oFBugbear = GetObjectByTag("ZK_F_BUGBEAR");
object oFGoblin = GetObjectByTag("ZK_F_GOBLIN");
object oFIcecavern = GetObjectByTag("ZK_F_ICECAVERN");
object oFKalarok = GetObjectByTag("ZK_F_KALAROK");
object oFKalarokbndt = GetObjectByTag("ZK_F_KALAROKBNDT");
object oFKandorgnoll = GetObjectByTag("ZK_F_KANDORGNOLL");
object oFNhanimal = GetObjectByTag("ZK_F_NHANIMAL");
object oFNhostevils = GetObjectByTag("ZK_F_NHOSTEVILS");
object oFNhostgobl = GetObjectByTag("ZK_F_NHOSTGOBL");
object oFShadowfrst = GetObjectByTag("ZK_F_SHADOWFRST");
object oFSthrnallnce = GetObjectByTag("ZK_F_STHRNALLNCE");
object oFUgroundfrst = GetObjectByTag("ZK_F_UGROUNDFRST");
object oFMyrath = GetObjectByTag("ZK_F_MYRATH");
object oFKayketh = GetObjectByTag("ZK_F_KAYKETH");

if (oFaction == OBJECT_INVALID)
{
object item = GetFirstItemInInventory(oPC);
if(GetXP(oPC) == 0)
{
while (item != OBJECT_INVALID)
{
DestroyObject(item);
item = GetNextItemInInventory(oPC);
}
GiveXPToCreature(oPC, 700);
GiveGoldToCreature( oPC, 300);
[/list]}
AssignCommand(oPC,ActionJumpToObject(oStart00));
[/list]}
else
{
string sFactionSkin = GetTag(oFaction);
//Tag of PC's Faction item
string sLeft = GetStringLeft(sFactionSkin, 8);
string sBindLoc;
string sBase = "ZK_BIND_";
if (sFactionSkin == "ZK_F01__________________________")
{
string sBindLoc = "S0";
//FloatingTextStringOnCreature("if statement triggered", oPC, TRUE);
string sJumpTag = sBase + sBindLoc;
string sFaction = GetStringLeft(sFactionSkin, 6);
// Actual Faction of PC
//FloatingTextStringOnCreature("sJumpTag- "+sJumpTag, oPC, TRUE);
object oJump = GetWaypointByTag(sJumpTag);
if (sFaction == "ZK_F01")
{
/*AdjustReputation(oPC,oFKalarokbndt,80);
AdjustReputation(oPC,oFKalarok,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F02")
{
}
if (sFaction == "ZK_F03")
{
}
if (sFaction == "ZK_F04")
{
}
if (sFaction == "ZK_F05")
{
}
if (sFaction == "ZK_F06")
{
}
if (sFaction == "ZK_F07")
{
/*AdjustReputation(oPC,oFMyrath,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F08")
{
}
if (sFaction == "ZK_F09")
{
/*AdjustReputation(oPC,oFKalarokbndt,80);
AdjustReputation(oPC,oFKalarok,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F10")
{
/*AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F11")
{
}
if (sFaction == "ZK_F12")
{
}
if (sFaction == "ZK_F13")
{
/*AdjustReputation(oPC,oFKalarokbndt,80);
AdjustReputation(oPC,oFKalarok,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F14")
{
}
if (sFaction == "ZK_F15")
{
/*AdjustReputation(oPC,oFKayketh,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F16")
{
}
if (sFaction == "ZK_F17")
{
}
if (sFaction == "ZK_F18")
{
}
AssignCommand (oPC,ActionJumpToObject(oJump));
[/list]}
else
{
string sBindLoc = GetStringRight(sFactionSkin, 2);
// stored bind location
//FloatingTextStringOnCreature("else triggered", oPC, TRUE);
string sJumpTag = sBase + sBindLoc;
string sFaction = GetStringLeft(sFactionSkin, 6);
// Actual Faction of PC
//FloatingTextStringOnCreature("sJumpTag- "+sJumpTag, oPC, TRUE);
object oJump = GetWaypointByTag(sJumpTag);
if (sFaction == "ZK_F01")
{
/*AdjustReputation(oPC,oFKalarokbndt,80);
AdjustReputation(oPC,oFKalarok,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F02")
{
}
if (sFaction == "ZK_F03")
{
}
if (sFaction == "ZK_F04")
{
}
if (sFaction == "ZK_F05")
{
}
if (sFaction == "ZK_F06")
{
}
if (sFaction == "ZK_F07")
{
/*AdjustReputation(oPC,oFMyrath,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F08")
{
}
if (sFaction == "ZK_F09")
{
/*AdjustReputation(oPC,oFKalarokbndt,80);
AdjustReputation(oPC,oFKalarok,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F10")
{
/*AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F11")
{
}
if (sFaction == "ZK_F12")
{
}
if (sFaction == "ZK_F13")
{
/*AdjustReputation(oPC,oFKalarokbndt,80);
AdjustReputation(oPC,oFKalarok,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);

}
if (sFaction == "ZK_F14")
{
}
if (sFaction == "ZK_F15")
{
/*AdjustReputation(oPC,oFKayketh,80);
AdjustReputation(oPC,oFSthrnallnce,-100);
AdjustReputation(oPC,oFDuergar,-100);
}
if (sFaction == "ZK_F16")
{
}
if (sFaction == "ZK_F17")
{
}
if (sFaction == "ZK_F18")
{
}
AssignCommand (oPC,ActionJumpToObject(oJump));
[/list]}
[/list]}
[/list]}
               
               

               
            

Legacy_Drakantus

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #2 on: September 01, 2010, 02:59:18 am »


               Sorry about the mess, nice cleaning.  Code tags don't work I see.  Anyway, I don't think the exact contents of the script are all that important, because of the nature of it working in a local game but not on a dedicated server hosted game.

In particular, the script checks if the entering character has a "faction item" in the creature armor slot, and if not it destroy all of the players gear and gives them some xp and gold.

Here is the relevant part of the script with the rest cut out:

object oPC = GetEnteringObject();    
object oFaction = GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);

if (oFaction == OBJECT_INVALID)
   {
   object item = GetFirstItemInInventory(oPC);
   if(GetXP(oPC) == 0)
      {
      while (item != OBJECT_INVALID)
         {
         DestroyObject(item);
         item = GetNextItemInInventory(oPC);
         }
      GiveXPToCreature(oPC, 700);
      GiveGoldToCreature( oPC, 300);
      }
   AssignCommand(oPC,ActionJumpToObject(oStart00));
   }
else

It's very obvious if this part works, because you enter with a new character and suddenly your gear is gone, but you have 700 xp and some gold.  Even if the rest of the script is broken I can't see what could mess this up.  Yet, on my dedicated server, even this part doesn't work and the character just sits in the starting area without the trigger firing and with all of his starting gear intact.
               
               

               


                     Modifié par Drakantus, 01 septembre 2010 - 02:04 .
                     
                  


            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #3 on: September 01, 2010, 03:10:07 am »


               Is it leaving all their starting gear or just the stuff they have equipped?
               
               

               
            

Legacy_Redunct

  • Jr. Member
  • **
  • Posts: 85
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #4 on: September 01, 2010, 03:10:41 am »


               EDIT :  Crappy new forums double post.
               
               

               


                     Modifié par Redunct, 01 septembre 2010 - 02:11 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #5 on: September 01, 2010, 03:12:35 am »


               Is there a reason you aren't calling this script in the module's OnClientEnter event?



-420
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #6 on: September 01, 2010, 03:17:44 am »


               If you are using some of the newer scripts "x3_mod_def_XXX" the player will get the "pc properties" skin as soon as they log in which is equipped in the carmor slot. So it won't be invalid and it wont have a specific tag that you are looking for.



Not sure if this is the case. Just an idea. Hope it helps.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #7 on: September 01, 2010, 03:43:58 am »


               In truth I have never used the ActionJumpToObject function much.  First I dont like it because it is an action.  second I dont like it because of the int bWalkStraightLineToPoint=TRUE paramater.  Even if you change it to false I guess he would run.  



So why it is working in your single player game I do not know.  



You are better off with.



#include "X0_I0_TRANSPORT"

...

TransportToWaypoint(oPC,oStart00);

...



Most of the scripts in X0_I0_TRANSPORT end up useing JumpToLocation()  with the added benifit of taking the players henchmen and compainions with him.
               
               

               
            

Legacy_Drakantus

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #8 on: September 01, 2010, 04:26:51 am »


               

GhostOfGod wrote...

If you are using some of the newer scripts "x3_mod_def_XXX" the player will get the "pc properties" skin as soon as they log in which is equipped in the carmor slot. So it won't be invalid and it wont have a specific tag that you are looking for.

Not sure if this is the case. Just an idea. Hope it helps.


Good idea, but I am running the exact same module in the dedicated server & single player mode.  In single player it works, dedicated server it doesn't, if it was a script on the module messing stuff up shouldn't it mess up both cases?  I'll check anyway...

Lightfoot8 wrote...
You are better off with. 

#include "X0_I0_TRANSPORT"
...
TransportToWaypoint(oPC,oStart00);
...

Most of the scripts in X0_I0_TRANSPORT end up useing JumpToLocation() with the added benifit of taking the players henchmen and compainions with him.


Well, that part worked.  Now it's failing before it even gets to that point...  I may well make the change anyway, but it doesn't look like that would fix my real problem.



420 wrote...

Is there a reason you aren't calling this script in the module's OnClientEnter event?

-420


Here is the basic setup:

Starting area is in a minimum size empty 2X2 zone.  The trigger covers most of the zone, fully including the starting area.  The idea is to do the following:

1 if character is new, strip of all gear, give some gold, give some xp, give a default faction item in the creature skin slot, and send character to the default first bindstone.

2 if the character is not new, read the tag of the ceature skin slot item to determine what bindstone the character is bound to, and send character to that bindstone, if none set than send to default bindstone.

The problem with making it a oncliententer script is that, my understanding is, the script would fire whenever a player disconnects and reconnects, which would make it trivial to return to the bindstone at any time without effort.  Also it could unfairly punish characters who had travelled a long way to do something, but got disconnected, and came back sent to the bindstone again.

I *could* split up the two tasks into two different scripts, but this trigger would still be broken so I don't see the advantage right now.

Redunct wrote...

Is it leaving all their starting gear or just the stuff they have equipped?


Leaving everything, doesn't seem to be doing anything at all on the dedicated server.
               
               

               
            

Legacy_Drakantus

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #9 on: September 01, 2010, 04:30:13 am »


               Okay further testing...



Single Player mode- script works fine.

Server hosted by full game- script works fine.

Dedicated server- script fails.



Now I am wondering if I messed something up when I setup the dedicated server, I thought I just had to unzip it and run it.  This is really puzzling to me.
               
               

               
            

Legacy_Drakantus

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #10 on: September 01, 2010, 04:59:53 am »


               

Drakantus wrote...

GhostOfGod wrote...

If you are using some of the newer scripts "x3_mod_def_XXX" the player will get the "pc properties" skin as soon as they log in which is equipped in the carmor slot. So it won't be invalid and it wont have a specific tag that you are looking for.

Not sure if this is the case. Just an idea. Hope it helps.


Good idea, but I am running the exact same module in the dedicated server & single player mode.  In single player it works, dedicated server it doesn't, if it was a script on the module messing stuff up shouldn't it mess up both cases?  I'll check anyway...


Another update.  I checked this.  On the local full game server, (where script works)  I do see that I get the "PC Properties" item, but then the script triggers and it is destroyed.  On the dedicated server I see the "you got item PC Properties" line, but the script doesn't trigger.
               
               

               
            

Legacy_Drakantus

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Script works in a local game but not on dedicated server?
« Reply #11 on: September 01, 2010, 05:32:26 am »


               

GhostOfGod wrote...

If you are using some of the newer scripts "x3_mod_def_XXX" the player will get the "pc properties" skin as soon as they log in which is equipped in the carmor slot. So it won't be invalid and it wont have a specific tag that you are looking for.

Not sure if this is the case. Just an idea. Hope it helps.



SOLVED!

I removed the unused default scripts and now it works on a dedicated server.  It doesn't make any sense to me that the scripts would be okay when I run the server from within the game, but fail only on a dedicated server, but whatever- it works now!


Thanks for the suggestion.