SA-MP Forums Archive
[Problem With my Codes] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Problem With my Codes] (/showthread.php?tid=476020)



[Problem With my Codes] - donhu789 - 16.11.2013

Guys Why my Stats doesnt show other cookies,cakes ?
pawn Код:
CMD:stats(playerid,params[])
{
    new pDeaths, player1, h, m, s,playername[MAX_PLAYER_NAME];
    if(isnull(params)) player1 = playerid;
    else player1 = strval(params);

    if(IsPlayerConnected(player1)) {
        TotalGameTime(player1, h, m, s);
        GetPlayerName(player1, playername, sizeof(playername));
        if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
        new str[20][1000];
        format(str[0],1000,"                         YG Stats For %s's\n", PlayerName2(player1));
        strcat(str[1],str[0]);
        format(str[2],1000,"Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f\n", GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths);
        strcat(str[1],str[2]);
        format(str[3],1000,"Admin Level: %d  | Skin: %d | Ping: %d | Bank: $%d | Wanted Level: %d\n", PlayerInfo[playerid][Level],GetPlayerSkin(player1),GetPlayerPing(playerid),PlayerInfo[playerid][bank],GetPlayerWantedLevel(playerid));
        strcat(str[1],str[3]);
        format(str[4],1000,"TimePlayed: [%d] hrs [%d] mins [%d] secs | Interior: %d | Country: %s\n", h, m, s, GetPlayerInterior(playerid),GetPlayerCountryName(playerid));
        strcat(str[1],str[4]);
        format(str[5],1000,"Cookies: %d, Cakes: %d\n", PlayerInfo[playerid][Cookies], PlayerInfo[playerid][Cakes]);
        strcat(str[1],str[5]);
        ShowPlayerDialog(playerid,DIALOG_STATS,DIALOG_STYLE_MSGBOX,"Player Stats",str[1],"OK","");
    } else return SendClientMessage(playerid, red, "Player Not Connected!");
    return 1;
}
Wenyt i make is only show my stats and i /stats 1 is show my cookies,cakes :\


Re: [Problem With my Codes] - Dragonsaurus - 16.11.2013

pawn Код:
CMD:stats(playerid,params[])
{
    new pDeaths, player1, h, m, s,playername[MAX_PLAYER_NAME];
    if(isnull(params)) player1 = playerid;
    else player1 = strval(params);

    if(IsPlayerConnected(player1)) {
        TotalGameTime(player1, h, m, s);
        GetPlayerName(player1, playername, sizeof(playername));
        if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
        new str[20][1000];
        format(str[0],1000,"                         YG Stats For %s's\n", PlayerName2(player1));
        strcat(str[1],str[0]);
        format(str[2],1000,"Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f\n", GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths);
        strcat(str[1],str[2]);
        format(str[3],1000,"Admin Level: %d  | Skin: %d | Ping: %d | Bank: $%d | Wanted Level: %d\n", PlayerInfo[player1][Level],GetPlayerSkin(player1),GetPlayerPing(player1),PlayerInfo[player1][bank],GetPlayerWantedLevel(player1));
        strcat(str[1],str[3]);
        format(str[4],1000,"TimePlayed: [%d] hrs [%d] mins [%d] secs | Interior: %d | Country: %s\n", h, m, s, GetPlayerInterior(player1),GetPlayerCountryName(player1));
        strcat(str[1],str[4]);
        format(str[5],1000,"Cookies: %d, Cakes: %d\n", PlayerInfo[player1][Cookies], PlayerInfo[player1][Cakes]);
        strcat(str[1],str[5]);
        ShowPlayerDialog(playerid,DIALOG_STATS,DIALOG_STYLE_MSGBOX,"Player Stats",str[1],"OK","");
    } else return SendClientMessage(playerid, red, "Player Not Connected!");
    return 1;
}
You had playerid instead of player1.


Re: [Problem With my Codes] - donhu789 - 16.11.2013

is will show both player ?


Re: [Problem With my Codes] - Dragonsaurus - 16.11.2013

Quote:
Originally Posted by donhu789
Посмотреть сообщение
is will show both player ?
I didn't get your point, but let me explain:
When you do /stats with no parameter or number after it, it will show your stats.
If you do /stats 2 it will show the stats of player ID 2, not the stats of the player who typed the command.

Edit for post below: Exactly, my above's post code does exactly what you requested.


Re: [Problem With my Codes] - donhu789 - 16.11.2013

went i preass /stats my sellf is will show my self | and i /stats 1 is show another statS?


Re: [Problem With my Codes] - donhu789 - 16.11.2013

went i preass /stats my sellf is will show my self | and i /stats 1 is show another statS? Right ?? If You SAy Yes Thanks


Re: [Problem With my Codes] - donhu789 - 16.11.2013

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
I didn't get your point, but let me explain:
When you do /stats with no parameter or number after it, it will show your stats.
If you do /stats 2 it will show the stats of player ID 2, not the stats of the player who typed the command.

Edit for post below: Exactly, my above's post code does exactly what you requested.

Hey CAn You Help My Makes THat ?