Quote:
Originally Posted by Engine
I thought I couldn't trigger clientside after I triggered serverside?
|
Nope. You can trigger either way back and forth as much as you want. You can create an infinite loop if you want:
PHP Code:
function onActionServerSide(cmd) {
if (cmd == "ping") {
triggerClient("gui", this.name, "ping");
}
}
//#CLIENTSIDE
function onCreated() {
triggerServer("gui", this.name, "ping"); // start the loop
}
function onActionClientSide(cmd) {
if (cmd == "ping") {
this.counter ++;
player.chat = "Pings: " @ this.counter;
triggerServer("gui", this.name, "ping");
}
}
Though obviously you wouldn't want to do something like that in practical scripting
You can also trigger weapons of other players.
PHP Code:
function onActionServerSide(cmd, target, msg) {
if (cmd == "tell") {
temp.pl = findPlayerByCommunityName(target);
if (pl == null) {
return player.chat = "(player not found)";
}
pl.triggerClient("gui", this.name, "tell", player.communityname, msg);
}
}
//#CLIENTSIDE
function onPlayerChats() {
if (player.chat.starts("tell")) { // format is: tell account "message here"
temp.tokens = player.chat.tokenize();
temp.acc = tokens[1];
temp.msg = tokens[2];
triggerServer("gui", this.name, "tell", acc, msg);
}
}
function onActionClientSide(cmd, sender, msg) {
if (cmd == "tell") {
player.chat = sender @ ": " @ msg;
}
}
To use this you would say: tell cbk1994 "Hi there ugly!"
That would trigger serverside, try to find a player with the community name 'cbk1994', and if found, trigger clientside on the same weapon for that player. Once it receives the trigger clientside, it would set my chat to 'Engine: Hi there ugly!'.
This is a bit of a silly example since you can set players' chat serverside, but it could be used, for example, if you have some kind of GUI window displaying the message.