View Single Post
  #4  
Old 02-20-2009, 08:26 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Schetti View Post
(cat, tomcat) why thats needed?
PHP Code:
function onActionserverside(cattomcat) {
  if (
tomcat == "Top Cat") {
    echo(
"Hello Top Cat!");
  }


just that I dont fail to see sense of triggerserver
it makes it able to "react" a function, right?
The 'cat, tomcat' thing defines the parameters in the serverside function, I will use a different method below to show you how else you can do it.


Triggerserver sends data that you're using on the clientside, over to the serverside.

For example, mousex/mousey are only accessible on the clientside.
PHP Code:
 player.chat mousex
If you did this serverside it would return '0' where as if you did this clientside, it would return your mouse's position on the level.

Let's say you NEED that data (mousex/ mousey) serverside so you can do certain serverside-only commands.

You can send your mousex/mousey serverside like this.

PHP Code:
// This is serverside.
function onActionserverside() {
  switch(
params[0]) {
    case 
"positions":
      
this.mouse_x params[1];
      
this.mouse_y params[2];
    break;
  }
}
// Clientside, here I come.
//#CLIENTSIDE
function onMouseDown() {
  
triggerserver("gui"this.name"positions"mousexmousey);

You will notice that everything after 'this.name,' gets sent serverside in a list (also known as array, to access this list, use 'params').
So, after doing triggerserver, this is what will be sent serverside:
PHP Code:
"positions"mousexmousey 
This is a great tool for you to know when doing client-to-server scripts.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote