Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-26-2011, 03:20 AM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
onActionClientSide Weirdness

This has happened to me on two seperate occassions, and for the life of me I cannot work out why.
What happens is that when I trigger the client from serverside, the function onActionClientSide appears to execute twice, instead of once from the trigger on the serverside.
Normally, this wouldn't be a problem for me, but for functions which add text to a list, this is quite frustrating, as I get double the amount of text that I should.
Can anyone explain this?
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #2  
Old 08-26-2011, 03:26 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Post your code (at least relevant sections, i.e. the triggers).

Also, check that the triggerClient isn't actually being called twice (add an echo near it—if you see it twice, it's something else).
__________________
Reply With Quote
  #3  
Old 08-26-2011, 03:28 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
PHP Code:
function onActionServerSide() {
  if (
params[0] == "test") {
    
player.triggerclient(this.name"msg"timevar2);
  }
}

//#CLIENTSIDE

function onCreated() {
  
triggerserver("gui"this.name"test");
}

function 
onActionClientSide() {
  if (
params[0] == "msg") {
    echo(
params[1]);
  }

Does the above only show one 'test <number>" when you apply the script?
__________________
Quote:
Reply With Quote
  #4  
Old 08-26-2011, 03:34 AM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Quote:
Originally Posted by cbk1994 View Post
Post your code (at least relevant sections, i.e. the triggers).

Also, check that the triggerClient isn't actually being called twice (add an echo near it—if you see it twice, it's something else).
I've checked the trigger on the serverside with an echo, it's being called once.

PHP Code:
if(params[0] == "LoadPlayers"){
  for(
temp.pl allplayers){
    if(
temp.pl.level != NULL){
      
temp.plyrs.add(temp.pl);
    }
    else {
      
temp.rcs.add(temp.pl);
    }
  }
  
triggerClient("gui",name,"GotPlayers",temp.plyrs,temp.rcs);

And then when this info is sent to the client, which I've checked with an echo and it executes twice:

PHP Code:
function onActionClientSide(){
  
showInterface(Category_Tabs.getSelectedText());
}

function 
showInterface(opt){
  
  
with("Operations_List"){
    switch(
opt){
    case 
"Players":
      
addRow(0,"Warpto");
      
addRow(1,"Profile");
      
addRow(2,"Summon");
      
addRow(3,"Warp Player");
      
addRow(4,"Client flags");
      for(
temp.0temp.<= 4temp.++){
        
rows[temp.r].active false;
      }
   }

This is the only way the showInterface function could be called, which is what is causing the problem.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #5  
Old 08-26-2011, 03:38 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Not sure if it would be the cause, but you're missing a closing bracket
__________________
Reply With Quote
  #6  
Old 08-26-2011, 03:42 AM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Quote:
Originally Posted by salesman View Post
Not sure if it would be the cause, but you're missing a closing bracket
That's my bad.
Was copying and pasting it out of the middle of a function and adding brackets on the forums.
It's okay in my script.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #7  
Old 08-26-2011, 03:42 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You should be verifying that params[0] is "GotPlayers" in your onActionClientSide. I question your switch statement as well because it doesn't appear you're using a break for each, which could cause a falling through and adding rows for no reason.
__________________
Quote:
Reply With Quote
  #8  
Old 08-26-2011, 03:47 AM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Quote:
Originally Posted by fowlplay4 View Post
You should be verifying that params[0] is "GotPlayers" in your onActionClientSide. I question your switch statement as well because it doesn't appear you're using a break for each, which could cause a falling through and adding rows for no reason.
Again, the break is there, I just didn't copy and paste it properly.
I was verifying params[0] after that function was called, so that the function would be called no matter what params[0] was, but it seems that placing the function after the verification fixes the problem, so thanks fowlplay.

Why would it be called twice in the first place though?
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #9  
Old 08-26-2011, 03:55 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by iBeatz View Post
Again, the break is there, I just didn't copy and paste it properly.
I was verifying params[0] after that function was called, so that the function would be called no matter what params[0] was, but it seems that placing the function after the verification fixes the problem, so thanks fowlplay.

Why would it be called twice in the first place though?
You can triggerclient any weapon from any script on the server-side so you should be validating the first parameter to make sure a rogue script isn't just sending it random data.
__________________
Quote:
Reply With Quote
  #10  
Old 08-26-2011, 03:47 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by salesman View Post
Not sure if it would be the cause, but you're missing a closing bracket
Iirc any improperly defined function will occur as a result of any other properly defined function within the script.

If you were to make an NPC script of:

PHP Code:
//#CLIENTSIDE
function onCreated(){
  
//
}

function 
onPlayerEnters(){
  
//
}

function 
onPlayerChats(){
  
//
}

//as opposed to function lol(){
lol(){
  
this.chat ++;

"lol()" would occur when the NPC is created, the player enters, the player chats etc.
So the missing bracket probably is the cause here.
Reply With Quote
  #11  
Old 08-31-2011, 08:29 AM
furry_mougle furry_mougle is offline
big heart
furry_mougle's Avatar
Join Date: Aug 2011
Posts: 42
furry_mougle is an unknown quantity at this point
I remember having a similar problem before with NPCs joined to the same class in one level, and if the player was in that level and executed a block of code with that NPC it'd execute twice. Though, I don't think that's the case here. Probably the missing bracket.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.