Author Topic: messageclient(); does not work?  (Read 3229 times)

it works like the script is error free but when i do /message deathrider hi in game nothing shows up. This is really starting to piss me off.
Code: [Select]
function servercmdmessage(%client, %user, %message)
{
%name = findclientbyname(%user);
  if(isobject(%user))
    {
    messageclient(%user,'',"Message from :" @ %client.name @ ": message: " @ %message);
    }
    else
    {
    messageclient(%client,'',"The username " @ %user @ " does not exist!");
    }
}

i also need to know how to let a variable use more than one word see when i make the message only one word will come i also need this for the user.

you are getting your %user and %name mixed up.  Take a deep breath and look carefully at when you want it to use %user, which is just a word that you type in, or %name, which is the client found from the function findclientbyname(%user);

Code: [Select]
function servercmdmessage(%client, %user, %message)
{
%name = findclientbyname(%user);
  if(isobject(%name))
    {
        messageclient(%user,'',"Message from :" @ %client.name @ ": message: " @ %message);
    }
    else
    {
        messageclient(%client,'',"The username " @ %user @ " does not exist!");
    }
}


Code: [Select]
function servercmdmessage(%client, %user, %message)
{
%name = findclientbyname(%user);
  if(isobject(%name))
    {
        messageclient(%name,'',"Message from :" @ %client.name @ ": message: " @ %message);
    }
    else
    {
        messageclient(%client,'',"The username " @ %user @ " does not exist!");
    }
}

Code: [Select]
function servercmdmessage(%client, %user, %message)
{
%name = findclientbyname(%user);
  if(isobject(%name))
    {
        messageclient(%name,'',"Message from :" @ %client.name @ ": message: " @ %message);
    }
    else
    {
        messageclient(%client,'',"The username " @ %user @ " does not exist!");
    }
}
ok i se what i did wrong i was trying to see if a word exists not the player so every single time it would go tell me that my word does not exist

ok i se what i did wrong i was trying to see if a word exists not the player so every single time it would go tell me that my word does not exist

Exactly.  A good way to make sure you don't make that mistake again is by having %user = findclientbyname(%user); at the beginning of the function so you know that it is going to be an object and don't have an extra variable floating around just to confuse you

Exactly.  A good way to make sure you don't make that mistake again is by having %user = findclientbyname(%user); at the beginning of the function so you know that it is going to be an object and don't have an extra variable floating around just to confuse you
ok, now i just look at other scripts on how they add colors to their text

how do i get this to only do it once when you spawn in the server not every time you spawn
Code: [Select]
function gameConnection::spawnplayer(%client)
{
  messageClient(%client, '', '\c6This server is running the Personal Message mod \c6use \c3/message USER MESSAGE \c6to send them a personal message.');
}

Use gameConnection::onClientEnterGame.
But parent it, and package it.

how do i get this to only do it once when you spawn in the server not every time you spawn
Code: [Select]
function gameConnection::spawnplayer(%client)
{
  messageClient(%client, '', '\c6This server is running the Personal Message mod \c6use \c3/message USER MESSAGE \c6to send them a personal message.');
}

you should use regular "quotes" instead of 'apostrophes' around the words you want people to read, because apostrophes work differently.  Honestly I myself don't really understand it entirely, but generally:
If you are sending a command, it goes in apostrophes.
If you are sending a string for the player to read, it goes in quotes.

If someone could clarify it better that would be nice.

you should use regular "quotes" instead of 'apostrophes' around the words you want people to read, because apostrophes work differently.  Honestly I myself don't really understand it entirely, but generally:
If you are sending a command, it goes in apostrophes.
If you are sending a string for the player to read, it goes in quotes.

If someone could clarify it better that would be nice.
i think it needs to be ' as /c6 is a command if i have read right from other scrips this one i learnt from cell phone mod

Use gameConnection::onClientEnterGame.
But parent it, and package it.

i have no idea how to package i know its a command no topics how to

i only need one thing, how to allow the var to allow more than one word

i only need one thing, how to allow the var to allow more than one word
You can add more variables, like this:

function servercmdmessage(%client,%user,%msg1,%msg2,%msg3,etc)

Be careful though, I think the limit for arguments is around 13 or 15

You can add more variables, like this:

function servercmdmessage(%client,%user,%msg1,%msg2,%msg3,etc)

Be careful though, I think the limit for arguments is around 13 or 15
aw i was thinking i could do it like batch the more words you type it ads 1 to a var so it be

you say hi
code:%message

you say hello how are you
code: message message2 message 3