score string. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: score string. (
/showthread.php?tid=92100)
score string. -
[mad]MLK - 18.08.2009
hey how would i make it so that it tells the player there score i made this but it dont work :/
Код:
if(strcmp(cmdtext, "/score", true) == 0)
{
new pscore[24], string[128];
GetPlayerScore(playerid);
format(string, sizeof(string), "You're current score is: %s", pscore);
SendClientMessage(playerid, 0xFFFFFFFF, string);
return 1;
}
It just says "You're current score is:" then nothing : /
Re: score string. -
Weirdosport - 18.08.2009
pawn Код:
if(strcmp(cmdtext, "/score", true) == 0)
{
new string[50];
new pscore = GetPlayerScore(playerid);
format(string, sizeof(string), "You're current score is: %d", pscore);
SendClientMessage(playerid, 0xFFFFFFFF, string);
return 1;
}
That should work.
GetPlayerScore returns an integer, and you need to save it, hence "pscore = GetPlayerScore(playerid);" (although as JaToch showed you don't HAVE to save it)
As pscore is an integer, you use either %d or %i to represent it in the format().
I also shortened your string as the players score + the text you have will never be longer than 50 characters. However, if you make the string longer you might have to increase the size.
Re: score string. -
JaTochNietDan - 18.08.2009
Well, first of all the "pscore" should be a variable not a string, and it's not defined when printing it. And the %s should be %d. Plus there is no need for it anyway, like so:
pawn Код:
if(strcmp(cmdtext, "/score", true) == 0)
{
new string[128];
format(string, sizeof(string), "You're current score is: %d", GetPlayerScore(playerid));
SendClientMessage(playerid, 0xFFFFFFFF, string);
return 1;
}