View Single Post
  #6  
Old 02-22-2011, 04:12 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
Syntax: triggerserver(type, name, param, [...])

type - Depending on what you're doing this will usually be "gui" if you're using it in a weapon script. You can also trigger DB-NPCs by specifying "npc" instead.

name - Name of object to trigger, you'll most often be specifying the weapon/npc's name by using it's this.name value.

param - Short for parameter, this is the data you are sending to the server.

... - (Optional) You can specify as many additional parameters as you want, if you need more than 10 you probably need to re-think your approach.

Example: Sending a message to the server in a weapon script.

PHP Code:
// The function that is triggered by triggerserver
function onActionServerSide() {

  
// The data from the triggerserver call is automatically placed into the 
  // params array.
  // It's stored like this:
  // params[0] = "message"
  // params[1] = "The actual message data"

  // Check if the first parameter is "message"
  // This is basically a minor security check, but also allows for more flexibility 
  // down the line if you send more than just messages to the server-side.
  
if (params[0] == "message") {
    
// Concates a message using the player's account and the
    // message data in params[1]
    
temp.msg player.account SPC "sent" SPC params[1];
    
// Displays the message on RC
    
sendtorc(temp.msg);
  }
}

//#CLIENTSIDE
function onCreated() {
  
// Sends a trigger to the server-side portion of this script.
  // It also passes "message" and "The actual message data" as params.
  // On the server-side the parameter data is placed into a params array.
  
triggerserver("gui"this.name"message""The actual message data");

__________________
Quote:
Reply With Quote