score string.
#1

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 : /
Reply
#2

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.
Reply
#3

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;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)