View Single Post
  #4  
Old 02-09-2010, 06:07 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
Quote:
Originally Posted by Engine View Post
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(cmdtargetmsg) {
  if (
cmd == "tell") {
    
temp.pl findPlayerByCommunityName(target);
    
    if (
pl == null) {
      return 
player.chat "(player not found)";
    }
    
    
pl.triggerClient("gui"this.name"tell"player.communitynamemsg);
  }
}

//#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"accmsg);
  }
}

function 
onActionClientSide(cmdsendermsg) {
  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.
__________________
Reply With Quote