SendClientMessage Help
#1

I'm new to all of this and am still fiddling with bits and pieces but I need help on some testing..
For example I made a test command that is /test and I want it to say the players id and then say "is testing".
So basically I want to know how to put a playerid into a client message.

Thank you very much, and sorry if this is in the wrong section.
Reply
#2

pawn Код:
new string[22];
format(string, sizeof(string), "( %d ), said testing", playerid);
SendClientMessage(playerid, 0xFFFFFFAA, string);
Reply
#3

Quote:
Originally Posted by Retardedwolf
Посмотреть сообщение
pawn Код:
new string[22];
format(string, sizeof(string), "( %d ), said testing", playerid);
SendClientMessage(playerid, 0xFFFFFFAA, string);
it ends up saying ( 0 ), said testing, how do I make it say their name?

Thankyou for the help man
Reply
#4

I believe you change %d to %s, I'm not exactly sure though, sorry!
Reply
#5

Quote:
Originally Posted by Brickwood
Посмотреть сообщение
it ends up saying ( 0 ), said testing, how do I make it say their name?

Thankyou for the help man
new string[22];
new plrname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plrname, sizeof(plrname));
format(string, sizeof(string), "( %s ), said testing", plrname);
SendClientMessage(playerid, 0xFFFFFFAA, string);
Reply
#6

Woohoo, I was right
Reply
#7

Quote:
Originally Posted by Andrus
Посмотреть сообщение
new string[22];
new plrname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plrname, sizeof(plrname));
format(string, sizeof(string), "( %s ), said testing", plrname);
SendClientMessage(playerid, 0xFFFFFFAA, string);
I have this;
Quote:

if(KillingSpree[killerid] == 5)
{
new string[22];
new plrname[MAX_PLAYER_NAME];
GetPlayerName(killerid, plrname, sizeof(plrname));
format(string, sizeof(string), "( %s ) got 5 kills in a row!", plrname);
SendClientMessage(killerid, 0xFFFFFFAA, string);
}

but it says "( their name ) go" :S
do i need the string[22] to be larger?
Reply
#8

Quote:
Originally Posted by Brickwood
Посмотреть сообщение
do i need the string[22] to be larger?
pawn Код:
new string[MAX_PLAYER_NAME];
Reply
#9

Use this function for names it makes life easier place at bottom of script.
pawn Код:
stock playername(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    return pName;
}
Then wherever you put this (onplayerdeath?)
pawn Код:
if(KillingSpree[killerid] == 5)
{
    new string[64];
    format(string, sizeof(string), "( %s ) got 5 kills in a row!", playername(playerid));//this is how yopu use the playername function.
    SendClientMessage(killerid, 0xFFFFFFAA, string);
}
Ps the array you mentioned should have been larger.
Reply
#10

Thank you all for the help, it's done me some good.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)