SendClientMessage. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SendClientMessage. (
/showthread.php?tid=627159)
SendClientMessage. -
aymane123 - 24.01.2017
Hey guys i am back with my weird errors i made this shit:
PHP код:
CMD:score(playerid, params[])
{
new string[32];
new score;
GetPlayerScore(playerid);
format(string,sizeof(string),"You Score Is : %d.",score);
SendClientMessage(playerid,COLOR_GREEN,string);
}
And when i try it it works but under the message sent its writted
SERVER:Unknow Command i dont get it the command works but why i see that thing ?
Re: SendClientMessage. -
saffierr - 24.01.2017
This should work.
PHP код:
CMD:score(playerid, params[])
{
new string[32];
format(string,sizeof(string),"You Score Is : %d.", GetPlayerScore(playerid));
SendClientMessage(playerid,COLOR_GREEN,string);
return 1;
}
Edit: You forgot to add 'return 1;'
Re: SendClientMessage. -
Eoussama - 24.01.2017
EDIT: sorry for that, didn't reload the page
Try this:
PHP код:
CMD:score(playerid)
{
new string[23];
format(string,sizeof(string),"You Score Is : %d.",GetPlayerScore(playerid));
SendClientMessage(playerid,COLOR_GREEN,string);
return 1;
}
Re: SendClientMessage. -
aymane123 - 24.01.2017
Hmm i need an explain for this please and thanks.
Re: SendClientMessage. -
Eoussama - 24.01.2017
Quote:
Originally Posted by aymane123
Hmm i need an explain for this please and thanks.
|
Quote:
Originally Posted by Eoussama
EDIT: sorry for that, didn't reload the page
Try this:
|
PHP код:
//Method 1:
CMD:score(playerid)
{
new string[23];
format(string,sizeof(string),"You Score Is : %d.",GetPlayerScore(playerid)); //The '%d' cpoesifire will be replaces by whoever the GetPlayerScore Function returns, which obviousely going to be the player's score,
SendClientMessage(playerid,COLOR_GREEN,string); //This will display the message above in green to the player who typed the commands
return 1;
}
//Method 2:
CMD:score(playerid)
{
new string[23], score = GetPlayerScore(playerid);
format(string,sizeof(string),"You Score Is : %d.",score); //The '%d' cpoesifire will be replaces by whoever the GetPlayerScore Function returns, which obviousely going to be the player's score,
SendClientMessage(playerid,COLOR_GREEN,string); //This will display the message above in green to the player who typed the commands
return 1;
}
Re: SendClientMessage. -
saffierr - 24.01.2017
You have to add 'return 1;' so the server knows that it was a valid command.
And for your formatted text, it would return score '0', because you didn't assign a value to the variable 'score'.
Re: SendClientMessage. -
aymane123 - 24.01.2017
Thx Everyone.