CMD help
#1

pawn Код:
dcmd_getinfo(playerid, params[])
{
    if(PInfo[playerid][Level] >= 1)
    {
        new str[256], pid, pveh, pping, pcash, Float:phealth, Float:parmour, plevel;
        if(!strval(params)) return SendClientMessage(playerid, RED, "USAGE: /getinfo <playerid>");
        pid = strval(params);
        if(IsPlayerConnected(pid) && pid != INVALID_PLAYER_ID)
        {
            pveh = GetPlayerVehicleID(pid);
            pping = GetPlayerPing(pid);
            pcash = GetPlayerMoney(pid);
            GetPlayerHealth(pid, phealth);
            GetPlayerArmour(pid, parmour);
            plevel = PInfo[pid][Level];
            format(str, sizeof(str), "Player ID: %d \n\n Vehicle ID: %d \n\n Player Ping: %d \n\n Player Cash: %d \n\n Player Health: %d \n\n Player Armour: %d, Player Level: %d", pid, pveh, pping, pcash, phealth, parmour, plevel);
            SendClientMessage(playerid, YELLOW, str);
            return 1;
        }
        else return SendClientMessage(playerid, RED, "USAGE: /getinfo <playerid>");
    }
    else return 0;
}
When i type "/getinfo 1" it shows me the info of playerid 1 if (s)he is connected. But if i type "/getinfo 0" When (s)he is connected it comes back saying "USAGE: /getinfo <playerid>"

Please help
Reply
#2

Use if(!strlen(params))
Instead of if(!strval(params))

because when params equals "0"
then the strval of params will be 0, and the if structure would be true
Reply
#3

oh. =D Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)