Author Topic: Telling the client to tell the server something  (Read 775 times)

server.cs
function servercmdsend(%cl, %target)
{
%t = findclientbyname(%target);
commandtoclient(%t,'sendback');
}

function servercmdrecieve(%cl)
{
talk("The message was recieved");
}


client.cs

function clientcmdsendback(%cl)
{
commandtoserver('recieve', %arg1, %arg2);
}


why wont this work?

« Last Edit: September 22, 2012, 10:16:19 PM by MARBLE MAN »

commandToServer('command')

What I mean is, in the client.cs when you use commandToServer, don't include the 'client' variable.

i know.. but it still wont work after i do that...

The code works for me, you must be doing something else incorrectly

The code works for me, you must be doing something else incorrectly
i need someone i can trust with some private code im working on :C

Have you checked the console to see if you're getting an error in your code? It's most likely a syntax error somewhere stopping this from working.

Try typing /recieve manually in chat and see if you get a message, if you don't get one there's a syntax error somewhere

Have you checked the console to see if you're getting an error in your code? It's most likely a syntax error somewhere stopping this from working.

Try typing /recieve manually in chat and see if you get a message, if you don't get one there's a syntax error somewhere
no errors
function servercmdsendstuff(%cl, %arg, %arg2)
{
commandtoclient(%arg,'%arg2',%thisdoesntseemtowork);
}

commandtoclient(%client,'sendback',%arg,%arg2); <-

function clientcmdsendback(%arg, %arg2) <-

function clientcmdsendback(%arg, %arg2) <-
what? you don't need a semicolon there
« Last Edit: September 23, 2012, 09:14:55 AM by Scars75 »

commandToClient(%client, %func, %arg1, %arg2, ...); is a server-sided function which essentially calls a function on the specified client's client equal to clientCmd(insert %func here)(%arg1, %arg2, ...);.

There is no client object passed because it won't exist on the client and there's no reason for it to. Any information about a client on the server you want to pass to a client, you have to do through individual arguments or a type of string containing all the information (e.g. having numerical values in a sequence of words wherein all words of the same index always indicate the same value)

commandToServer(%func, %arg1, %arg2, ...); is a client-sided function which essentially calls a function on the server equal to serverCmd(insert %func here)(client object that called commandToServer, %arg1, %arg2, ...);.

When you do a /cmd in chat, your client is converting that into a commandToServer call.

Keep in mind, the %func arguments have to be tags.

If this isn't for some sort of client mod verification, don't do this. The client could alter data and send back false information.

If this isn't for some sort of client mod verification, don't do this. The client could alter data and send back false information.
Here is what im trying to do.
Its for a Client saved RP, so the client has to have the mod, and i dont care what they do with the info they send back.

I want the server to ask the client for something
The client tells the server what it asked for (or what the client wants to send back)
The server tells that to another client (for trading)

A visual:
Server --> Client --> Server --> Other client

why do you have a %cl argument on the client side?  The client doesn't need to identify which server it is getting a command from like the server needs to be able to do with clients.  That would be like having a %server on the server side.

Also it is spelled "receive" although as long as you are consistent it doesn't matter, and %arg1 and %arg2 aren't defined in the client.cs