Have Problem please help
#1

Hey people tried to do a check command but it did nothing to try it on another player shows my stats I need for an RP I'm doing
PHP код:
CMD:check(playeridparams[])
{
    new 
gamer;
    new 
atext[128];
    new 
atext2[128];
    new 
nivo PlayerInfo[playerid][Hungry];
    new 
nivo2 PlayerInfo[gamer][Hungry];
    if(!
IsPlayerAdmin(playerid))
        return 
SendClientMessage(playeridCOLOR_RED"Достъп отказан.");
    if (
sscanf(params"u"gamer)) SendClientMessage(playeridCOLOR_RED"Използвай: \"/check <Играч>");
    else if (
gamer == INVALID_PLAYER_IDSendClientMessage(playeridCOLOR_RED"Играча на е намерен");
    else
    {
        
format (atextsizeof(atext), "Hungry on player:%d",nivo);
        
format (atext2sizeof(atext2), "Hungry on player:%d",nivo2);
        
SendClientMessage(playeridCOLOR_PURPLEatext2);
        
SendClientMessage(playeridCOLOR_PURPLEatext);
    }
    return 
1;

Reply
#2

Let me show you what you do here:
pawn Код:
new gamer;
new nivo2 = PlayerInfo[gamer][Hungry];

if(sscanf(params, "u", gamer)) // ...
The problem here is that you get the value of PlayerInfo[gamer][Hungry] before you even know what the gamer is supposed to be. So it always takes the Hungry value of player 0 (new variables are initialized with a 0 value).

What you need to do instead is:
pawn Код:
new gamer;
if(sscanf(params, "u", gamer))
{
    // ...
}
new nivo2 = PlayerInfo[gamer][Hungry];
This way, nivo2 will have a proper value.

Also what you do here:
pawn Код:
format (atext, sizeof(atext), "Hungry on player:%d",nivo);
format (atext2, sizeof(atext2), "Hungry on player:%d",nivo2);
SendClientMessage(playerid, COLOR_PURPLE, atext2);
SendClientMessage(playerid, COLOR_PURPLE, atext);
This uses 2 arrays to send these text lines, you could instead use only one:
pawn Код:
format(atext, sizeof(atext), "Hungry on player: %d", nivo);
SendClientMessage(playerid, COLOR_PURPLE, atext);
format(atext, sizeof(atext), "Hungry on player: %d", nivo2);
SendClientMessage(playerid, COLOR_PURPLE, atext);
Reply
#3

Quote:
Originally Posted by AndreT
Посмотреть сообщение
Let me show you what you do here:
pawn Код:
new gamer;
new nivo2 = PlayerInfo[gamer][Hungry];

if(sscanf(params, "u", gamer)) // ...
The problem here is that you get the value of PlayerInfo[gamer][Hungry] before you even know what the gamer is supposed to be. So it always takes the Hungry value of player 0 (new variables are initialized with a 0 value).

What you need to do instead is:
pawn Код:
new gamer;
if(sscanf(params, "u", gamer))
{
    // ...
}
new nivo2 = PlayerInfo[gamer][Hungry];
This way, nivo2 will have a proper value.

Also what you do here:
pawn Код:
format (atext, sizeof(atext), "Hungry on player:%d",nivo);
format (atext2, sizeof(atext2), "Hungry on player:%d",nivo2);
SendClientMessage(playerid, COLOR_PURPLE, atext2);
SendClientMessage(playerid, COLOR_PURPLE, atext);
This uses 2 arrays to send these text lines, you could instead use only one:
pawn Код:
format(atext, sizeof(atext), "Hungry on player: %d", nivo);
SendClientMessage(playerid, COLOR_PURPLE, atext);
format(atext, sizeof(atext), "Hungry on player: %d", nivo2);
SendClientMessage(playerid, COLOR_PURPLE, atext);
thanks i will try it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)