Getstats problem
#1

Hello guys, I've a "little" problem with my getstat fonction.. I've created it afternoon, it work perferctley but... only on me. I explain, if I make /getstats ID of a player connecting, I've always, my stats, and not his stats.. Someone can help me? Here the code:

pawn Код:
COMMAND:getstats(playerid, params[])
{
        if(PlayerInfo[playerid][AdminLevel] >= 2)
        {
            new tmp[MAX_STRING];
            new Index;
            tmp = strtok(params, Index);
            new id = strval(tmp);
            if(isnull(tmp))
            return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /getstats <ID>");
            if(!IsPlayerConnected(id))
            return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
            new string[128];
            new stringB[128];
            new stringC[128];
            new stringD[128];
            new stringE[128];
            new stringF[128];
            new stringG[128];
            new stringH[128];
            new stringI[128];
            new stringJ[128];
            new pName[MAX_PLAYER_NAME];
            new pip[16];
            new Float:ratio;
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            format(file, sizeof(file), "/Accounts/%s.ini", pName);
            PlayerInfo[playerid][Kills] = dini_Int(file, "Kills");
            PlayerInfo[playerid][Deaths] = dini_Int(file, "Deaths");
            PlayerInfo[playerid][Warns] = dini_Int(file, "Warns");
            PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][Credit] = dini_Int(file, "Credit");
            PlayerInfo[playerid][VIP] = dini_Int(file, "VIP");
            ratio = floatdiv(PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths]);
            GetPlayerIp(playerid, pip, sizeof(pip));
            format(stringB, 128, "Name : %s", pName);
            SendClientMessage(playerid, COLOR_WHITE, stringB);
            format(string, 128, "PlayerIP: %s", pip);
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(stringC, 128, "Score: %d", GetPlayerScore(playerid));
            SendClientMessage(playerid, COLOR_WHITE, stringC);
            format(stringD, 128, "Kills: %i", PlayerInfo[playerid][Kills]);
            SendClientMessage(playerid, COLOR_WHITE, stringD);
            format(stringE, 128, "Deaths: %i", PlayerInfo[playerid][Deaths]);
            SendClientMessage(playerid, COLOR_WHITE, stringE);
            format(stringF, 128, "Ratio: %f", ratio);
            SendClientMessage(playerid, COLOR_WHITE, stringF);
            format(stringG, 128, "Warns: %i", PlayerInfo[playerid][Warns]);
            SendClientMessage(playerid, COLOR_WHITE, stringG);
            format(stringH, 128, "AdminLevel: %i", PlayerInfo[playerid][AdminLevel]);
            SendClientMessage(playerid, COLOR_WHITE, stringH);
            format(stringI, 128, "Credits: %i", PlayerInfo[playerid][Credit]);
            SendClientMessage(playerid, COLOR_WHITE, stringI);
            format(stringJ, 128, "VIP: %i", PlayerInfo[playerid][VIP]);
            SendClientMessage(playerid, COLOR_WHITE, stringJ);
            return 1;
        }
        else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not allowed to use this command.");
}
Thank's.
Reply
#2

PHP код:
COMMAND:getstats(playeridparams[])
{
    if(
PlayerInfo[playerid][AdminLevel] < 2) return SendClientMessage(playerid0xD8D8D8FF"You are not allowed to use this command.");
    new 
tmp[256], idx;
    
tmp strtok(paramsidx);
    new 
id strval(tmp);
    if(
isnull(tmp)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /getstats <ID>");
    if(!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_WHITE"Invalid ID");
    new 
string[128], pName[MAX_PLAYER_NAME], pip[16];
    
GetPlayerName(idpNameMAX_PLAYER_NAME);
    
format(filesizeof(file), "/Accounts/%s.ini"pName);
    
GetPlayerIp(idpipsizeof(pip));
    
format(string128"Name : %s"pName);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(string128"PlayerIP: %s"pip);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(string128"Score: %d"GetPlayerScore(id));
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(string128"Kills: %i"dini_Int(file"Kills"));
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(string128"Deaths: %i"dini_Int(file"Deaths"));
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(string128"Ratio: %f"floatdiv(PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths]));
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(string128"Warns: %i"dini_Int(file"Warns"));
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(string128"AdminLevel: %i"dini_Int(file"AdminLevel"));
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(string128"Credits: %i"dini_Int(file"Credit"));
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(string128"VIP: %i"dini_Int(file"VIP"));
    
SendClientMessage(playeridCOLOR_WHITEstring);
    return 
1;

Reply
#3

Thank's man, that work perfectly
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)