[Include] STInclude
#3

pawn Код:
stock GetPlayerID(const Name[])
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(i, pName, sizeof(pName));
            if(strcmp(Name, pName, true)==0)
            {
                return i;
            }
        }
    }
    return -1;
}
- You shouldn't create a variable/array inside of a loop, so move new pName[MAX_PLAYER_NAME] and place it above the loop.

- You shouldn't use i < MAX_PLAYERS as if MAX_PLAYERS is defined as 32, it will never get to 32, 31 would be the max.


pawn Код:
stock pnome(playerid)
{
    new nomeplayer[50];
    GetPlayerName(playerid, nomeplayer, sizeof(nomeplayer));
    return nomeplayer;
}
Why is "nomeplayer" 's size 50? MAX_PLAYER_NAME is 24.


pawn Код:
stock GetPlayerIP(playerid)
{
    new ip[24];
    GetPlayerIp(playerid, ip, sizeof ip);
    return ip;
}
Why is ip's size 24? It should be 16.
Reply


Messages In This Thread
STInclude - by [XPG]MarlonCS - 01.12.2014, 11:11
Re: STInclude - by Airblog - 01.12.2014, 11:38
Re: STInclude - by Stinged - 01.12.2014, 12:55
Re: STInclude - by Hirsw0w - 01.12.2014, 12:56

Forum Jump:


Users browsing this thread: 1 Guest(s)