Author Topic: Server activated Client function?  (Read 564 times)

How would one go about making an event that executed a client function? I need an example, as I'm lost.

ie: onActivate > Client > functionhere (Variable)

Thanks - Jeep

Client Sided:
Code: [Select]
function clientCmdfunctionName() {
   //code for the client
}

Server Sided:
Code: [Select]
function functionName(%client) {
   commandToClient(%client,'functionName');
}

You can't run non clientCmd functions from the server to the client to prevent the server from abusing the client.

How do you add a variable to that? For example:

functionhere("test");

For the client command define a variable, like so.
Code: [Select]
function clientCmdtestFunction(%var) {
   echo(%var);
}

Then for the server command, have it send a variable, like so.
Code: [Select]
function randomFunction(%client) {
   commandToClient(%client,'testFunction',%var);
}

Now I have another issue.

When an admin types /postmessage Lorem Ipsum whawtoijawt, it should display to the client. However, I only get the first word. How do you do a servercmd to post more than one words in a variable?

Create multiple variables such as %a, %b, %c, %d, %e, %f, %g, %h, %i (one for each word) and concatenate + trim them together.

Each word typed into a chat / command will show up as a new argument in the servercmd function.  However, single word arguments cannot be guaranteed because clients can also do commandtoserver('command', "hey look", "multiple words");

Isn't it just the same as using the ServerCmd? Using the same variables and stuff.

Example,

function ServerCmdTest(%client , %a , %b , %c)
{
        announce("The user " @ %client @ " has announced \"test\"! " @ %a SPC %b SPC %c);
}

 upon messagesending /test star fish star fish star fish it'll announce The user Darren has announced star fish star fish star fish


function ClientCmdTest(%a , %b , %c)
{
      echo("The server has sent a message to the client saying " @ %a SPC %b SPC %c);
}

upon the server sending commandToClient(%client , 'test' , "star fish" , "star fish" , "star fish"); it'll echo to the client "star fish star fish star fish"

i am not sure what you are trying to find out, i td;lr'd it because i cba to read today
« Last Edit: June 21, 2012, 02:14:40 PM by Wordy »