View Single Post
  #2  
Old 08-15-2008, 06:40 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Dan View Post
I'm using 20 different params and it doesn't work :S what now? [/lol]
:P

Well, some examples would be nice Invern

Btw, here are some:

PHP Code:
join("triggercontrol");

public function 
foo(baz) {
  echo(
baz);
  return 
"bar";
}

//#CLIENTSIDE
function onCreated() {
  echo(
serverfunction(this"foo""abc"));

Basically this will echo "abc" in RC and "bar" in F2 on client

---------------

PHP Code:
join("triggercontrol");

public function 
echo2(bazabc) {
  echo(
baz @" -> "abc);
}

//#CLIENTSIDE
function onCreated() {
  
serverfunction2(this"echo2""foo""bar");

This will echo "foo -> bar" in RC

---------------

PHP Code:
join("triggercontrol");

function 
onCreated() {
  
temp."You just got poisoned by a";
  
temp.@= randomstring({"n Apple"" Script"});
 
  
/* clientfunction/2/3 needs to be in the scope of
      an object (preferebly a player) */
  
with (findplayer("Chompy")) {
    
clientfunction2(this.name"f2message"temp.a);
  }
}

//#CLIENTSIDE
public function f2message(msg) {
  echo(
msg);

This will echo "You just got poisoned by an Apple" or "You just got poisoned by a Script" in F2 messages

---------------

PHP Code:
/*-- SERVERSIDE --*/

/*
  How clientfunction works is that it allows to get data from the clientside.
  Pretty neat feature I must say. Check out first example above.  */
clientfunction(
  
fobj// string or null as value, string if the function is in another wnpc (example of a string is 'this.name')
  
fname// function name
  
p0// params0
  
p1// params1 ETC
);

/*
  clientfunction2 is different from clientfunction, because clientfunction2
  because it's only job is to trigger the function on client, not to return
  any data back home to the serverside.  */
clientfunction2(
  
fobj// string or null as value, string if the function is in another wnpc (example of a string is 'this.name')
  
fname// function name
  
p0// params0
  
p1,  // params1 ETC
);

/*
  clientfunction3 is almost the same as clientfunction, but with a little
  twist. clientfunction will only wait max 5 seconds before it continues,
  wheter or not if it has got the data back from the clientside.

  Basically what's different is the wtime argument. */
clientfunction3(
  
wtime// specifies how long the function will wait for data from the clientside
  
fobj// string or null as value, string if the function is in another wnpc (example of a string is 'this.name')
  
fname// function name
  
p0// params0
  
p1,  // params1 ETC
);

/* npcfunction is to trigger an NPC in a said level with a said id. */
npcfunction(
  
p0// the level to check in
  
p1// the id of the npc to check fo
  
p2// function name to trigger
  
p3// param0
  
p4,  // param1 ETC
);


/*
  Note: When using any of the clientfunction* functions, if it's not working,
          try it within a scope.

          with(findplayer("Chompy")) {
            clientfunction2(...);
          }
          */

/*-- SERVERSIDE END --*/


/*-- CLIENTSIDE --*/

/* serverfunction is used exactly like clientfunction, but to return data from
    the serverside to the clientside. */
serverfunction(
  
fobj// string or null as value, string if the function is in another wnpc (example of a string is 'this.name')
  
fname// function name
  
p0// params0
  
p1,  // params1 ETC
);

/* serverfunction2 is used to trigger a function on the serverside, but it won't
    return any data from the serverside to the clientside. */
serverfunction2(
  
fobj// string or null as value, string if the function is in another wnpc (example of a string is 'this.name')
  
fname// function name
  
p0// params0
  
p1,  // params1 ETC
);

/* serverfunction3 is used almost exactly like the serverfunction, besides that
    serverfunction only waits a maximum 5 seconds for data from the
    serverside to arrive. */
serverfunction3(
  
wtime// Specifies how long the function should wait from data from the serverside
  
fobj// string or null as value, string if the function is in another wnpc (example of a string is 'this.name')
  
fname// function name
  
p0// params0
  
p1,  // params1 ETC
);

/* npcfunction is used to trigger a function in an NPC with a said ID */
npcfunction(
  
p0// the id of the NPC
  
p1// function name to trigger in the NPC
  
p2// param0
  
p3,  // param1 ETC
};

/*-- CLIENTSIDE END --*/


/* -- GLOSSARY -- */

/*

  wtime = wait time
  fobj = function object
  fname = function name
  p0 = parameter 0 (the first parameter)
  p1 = parameter 1 (the second parameter)

  PS: parameters start at 0

*/

/* -- GLOSSARY END -- */ 
:-)

PS: Might be some spelling mistakes, if there are, my excuse is: I'm Norwegian

If anything is wrong, let me now =o
__________________

Last edited by Chompy; 08-15-2008 at 08:32 PM.. Reason: Fixed some stuff
Reply With Quote