Author Topic: clientsided stuff  (Read 633 times)

I'm curious as to how clientside stuff works.

Let's say I create a function
Code: [Select]
function saywords(%words)
{
     echo('Words: ' @ %words);
}
How does TS know that I want this executed clientside? Is there a different function syntax clientside?

Also, do variables work exactly the same way clientside? Or are there differences?

Thanks.

If you execute that stuff on a pure client, it will be client-sided.

If you execute stuff on a pure server, it will be server-sided.

If you execute it on a hybrid (hosting from the client), it will be both.

When you start a server, code that makes it able to be a server is loaded.
When you load a client, code that makes it a client and not a server is loaded.

function saywords(%words)
{
     echo('Words: ' @ %words);
}

//===================
//You would have to make /(whatever you want)
//===================

//so...

function clientcmd[whatever](%client, %words)
{
      saywords("Hello");
}

//That would make it say:
//
//Words: Hello
//
//It would say that in the client's console.

If you execute that stuff on a pure client, it will be client-sided.

If you execute stuff on a pure server, it will be server-sided.

If you execute it on a hybrid (hosting from the client), it will be both.

When you start a server, code that makes it able to be a server is loaded.
When you load a client, code that makes it a client and not a server is loaded.
So if I put that code in a server.cs, upon joining a server I can use the function?

Can you be a tad more specific? I'm new to all this clientside business.

function saywords(%words)
{
     echo('Words: ' @ %words);
}

//===================
//You would have to make /(whatever you want)
//===================

//so...

function clientcmd[whatever](%client, %words)
{
      saywords("Hello");
}

//That would make it say:
//
//Words: Hello
//
//It would say that in the client's console.
I'm not sure what you're trying to do, so I can't be sure, but it looks like you don't know what you're talking about.

Serverside refers to a task that should be carried out on a server, and as such, clientside refers to a task that should be carried out on a client, serverside scripting is put in a server.cs file or a file that is executed by one, and likewise, clientside material in a client.cs or it's executions.

I'm not sure what you're trying to do, so I can't be sure, but it looks like you don't know what you're talking about.

Serverside refers to a task that should be carried out on a server, and as such, clientside refers to a task that should be carried out on a client, serverside scripting is put in a server.cs file or a file that is executed by one, and likewise, clientside material in a client.cs or it's executions.
That's essentially what I wanted to know. So anything I put in a client.cs is clientsided - I don't want the functions of client.cs getting mixed with the same named functions of the server.cs, which is packaged with it. That should be okay right?

As far as thaky's code goes, I think he was trying to show me how to do a clientside slash command. Which I don't need, but thanks anyways.

why why WHY WHY WHY WHY WHY WHY WHY WHY WHY WHY WHY WHY are you naming the stuff for both client and server sided functions the same? There is no reason to do that, EVER.

:/

'Nother question then, if I make a clientside variable ($dontshowtheserver) in client.cs, then connect to a server, can the server get $dontshowtheserver? Or is the variable only accessible clientside?

:/

'Nother question then, if I make a clientside variable ($dontshowtheserver) in client.cs, then connect to a server, can the server get $dontshowtheserver? Or is the variable only accessible clientside?
the latter.

here's how ZAPT communicates a value in a meaningful way.

GameMode_ZAPT/scripts/package.cs
Code: [Select]
function GameConnection::autoAdminCheck(%client)
{
%client.hasZAPT = false;
%client.zaptVersion = 0;
%client.zombieHudCells = -1;

commandToClient(%client, 'ZAPT_MOD_Resgister', $ZAPT::Version, ZombieMutations.getMutationList());
return parent::autoAdminCheck(%client);
}

GameMode_ZAPT/client.cs
Code: [Select]
function clientCmdZAPT_MOD_Resgister(%version, %mutations)
{
echo("\c5ZAPT has been registered with this server.");

if(%version > $ZAPT_Client::Version)
{
echo("\c2 +- Warning: You are running an outdated version of ZAPT.");
}
else if(%version < $ZAPT_Client::Version)
{
echo("\c2 +- Warning: The server is running an outdated version of ZAPT.");
}

%x = getWord(getRes(), 0);
%x -= 275;

%i = mFloor(%x / 205);

commandToServer('ZAPT_Register', $ZAPT_Client::Version);
commandToServer('ZAPT_CellCount', %i);

ZAPTC_addMinigamePanels();
ZAPTC_addMutations(%mutations);
}

GameMode_ZAPT/scripts/functions.cs
Code: [Select]
function serverCmdZAPT_Register(%client, %version)
{
%client.hasZAPT = true;
%client.zaptVersion = %version;
}