Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Sending multiple trigger actions (https://forums.graalonline.com/forums/showthread.php?t=86383)

Cubes 06-16-2009 09:48 AM

Sending multiple trigger actions
 
Is it possible to send multiple trigger actions to the same thing? This is just an example of what i'm mean by sending from client->serverside. It is only doing the first one I try to send.

PHP Code:

function onKeyPressed(keycodecharscancode) {
  if(
keycode == 192) {
    
triggerserver("gui""-loltest""flip"1);     
    
triggerserver("gui""-loltest""flip"2);    
    
triggerserver("gui""-loltest""flip"3);    
  }



cbk1994 06-16-2009 09:49 AM

Yes, it should work fine. I don't know why it isn't for you.

Chompy 06-16-2009 09:49 AM

send 1, 2, 3 as an array instead of having 3 triggers.

Cubes 06-16-2009 09:53 AM

I got it to work but i had to put sleeps between each one, any suggestions on something to prevent the delay? @chompy its not really like that it has more than one param, the code i posted was just an example of what i meant.
edit: i'm retarded and had a typo ;[ works now.

Pelikano 06-16-2009 10:34 AM

You can also loop if you want it to look kewl D:

Gambet 06-16-2009 06:29 PM

Quote:

Originally Posted by Cubes (Post 1499853)
@chompy its not really like that it has more than one param, the code i posted was just an example of what i meant.


That still doesn't mean that you should be sending so many triggers to the same action so consecutively--use arrays. If you don't want to clutter the trigger command then set up temp. vars that store the information for you and send the temp. vars over as the params to make it look cleaner.

Cubes 06-16-2009 07:12 PM

So I should do it like this?
PHP Code:

triggerserver("gui""-loltest""flip", {1,2,3}); 

or like this

PHP Code:

temp.= {1,2,3}
triggerserver("gui""-loltest""flip"temp.i); 


[email protected] 06-16-2009 07:17 PM

top ^^

Gambet 06-17-2009 08:43 PM

Quote:

Originally Posted by Cubes (Post 1499940)
So I should do it like this?
PHP Code:

triggerserver("gui""-loltest""flip", {1,2,3}); 

or like this

PHP Code:

temp.= {1,2,3}
triggerserver("gui""-loltest""flip"temp.i); 



Depends on the length of the array, if it really is just 3 numbers then save the extra line and just send the trigger using {1,2,3}, but if it's a rather large string array of some sort then it would be better to use a temp. var.

cbk1994 06-17-2009 08:48 PM

Quote:

Originally Posted by Gambet (Post 1500042)
Depends on the length of the array, if it really is just 3 numbers then save the extra line and just send the trigger using {1,2,3}, but if it's a rather large string array of some sort then it would be better to use a temp. var.

It's really personal preference. Some people always stick things in a variable, even if they only plan to use it once and could have inserted it there. Others always put it directly in the function.

Ronnie 06-25-2009 06:05 AM

Is -loltest , the name of the weapon?

salesman 06-25-2009 06:42 AM

Quote:

Originally Posted by Ronnie (Post 1501554)
Is -loltest , the name of the weapon?

Yes.

fowlplay4 06-25-2009 06:42 AM

Quote:

Originally Posted by Ronnie (Post 1501554)
Is -loltest , the name of the weapon?

In the example above yes it would be, and here's some usage of triggerserver.

PHP Code:

// Weapon Name: -loltest
function onActionServerSide() {
  echo(
"i luld " params[0]);
}
//#CLIENTSIDE
function onCreated() {
  
triggerserver("gui""-loltest""lolparam");
  
// Alternatively you can do..
  
triggerserver("gui"this.name"lolparam");


Edit: Looks like salesman was a few seconds earlier than I was..

Paradoxical 06-25-2009 10:04 PM

Quote:

Originally Posted by Gambet (Post 1499934)
That still doesn't mean that you should be sending so many triggers to the same action so consecutively--use arrays. If you don't want to clutter the trigger command then set up temp. vars that store the information for you and send the temp. vars over as the params to make it look cleaner.

Yeah, save some bandwidth and don't send un-nessisary data between client and server, hell, you could even cache all the data you need on the client, and then do a verification check on the server here and there to check for unauthorized changing of clientsided data, but that's a bit extremist.


All times are GMT +2. The time now is 04:06 AM.

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