SA-MP Forums Archive
Questions about stats. - 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: Questions about stats. (/showthread.php?tid=363326)



Questions about stats. - TaLhA XIV - 27.07.2012

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/stats"cmdtexttrue10) == 0)
    {
        new 
DIALOG_STATS;
        new 
str[256];
        new 
money;
        new 
name;
        new 
score;
    
money PlayerInfo[playerid][pMoney],
    
name PlayerInfo[playerid][pName],
    
score PlayerInfo[playerid][pScore],
    
format(strsizeof(str), "Name:[ %s ]\nLevel:[ %d ]\nMoney: [ %d ] "money,name,score);
    
ShowPlayerDialog(playeridDIALOG_STATSDIALOG_STYLE_MSGBOX "PlayerStats"str"Close""");
        return 
1;
    }

why don't it display names?
I also wanted to ask that how to dsplay player weapons in this?


Re: Questions about stats. - Misiur - 27.07.2012

pawn Код:
new name;
//to
new name[MAX_PLAYER_NAME+1];

format(str, sizeof(str), "Name:[ %s ]\nLevel:[ %d ]\nMoney: [ %d ] ", money,name,score);
//to
format(str, sizeof(str), "Name:[ %s ]\nLevel:[ %d ]\nMoney: [ %d ] ", name, score, money);
You don't have anywhere level variable so I just put the score as it. The variables order in format is important.


Re: Questions about stats. - TaLhA XIV - 27.07.2012

How can I get the weapons in player hand with this format?


Re: Questions about stats. - TaLhA XIV - 27.07.2012

sorry for the double post but please help.


Re: Questions about stats. - Misiur - 27.07.2012

pawn Код:
//Insert this
new current_gun[32];
GetWeaponName(GetPlayerWeapon(playerid), current_gun, sizeof(current_gun));

format(str, sizeof(str), "Name:[ %s ]\nLevel:[ %d ]\nMoney: [ %d ] ", name, score, money);
//to
format(str, sizeof(str), "Name:[ %s ]\nLevel:[ %d ]\nMoney: [ %d ]\nCurrent gun: [ %s ]", name, score, money, current_gun);



Re: Questions about stats. - Devilxz97 - 27.07.2012

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/stats", cmdtext, true, 10) == 0)
    {
        new DIALOG_STATS;
        new str[256];
        new money;
        new name;
        new score;
        new weapon[32];
        new playerweapon;
        money = PlayerInfo[playerid][pMoney],
        name = PlayerInfo[playerid][pName],
        score = PlayerInfo[playerid][pScore],
        weapon = PlayerInfo[playerid][pWeapon];
        GetWeaponName(playerweapon, weapon, sizeof(weapon));
        format(str, sizeof(str), "Name:[ %s ]\nMoney: [ %d ]\nScore: [ %d ]\nWeapon: [ %s ]", name,money,score,weapon);
        ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX , "PlayerStats", str, "Close", "");
        return 1;
    }
}
try this . .


Re: Questions about stats. - TaLhA XIV - 27.07.2012

It is okay and can you tell how to add players faction?
Like if I have to check that what is players faction and then display it in that way.Like if I have many factions like
PlayerInfo[playerid][TEAM_ME]
PlayerInfo[playerid][TEAM_SE]
PlayerInfo[playerid][TEAM_TE]
how can I check his faction and display it in the format thanks for your help


Re: Questions about stats. - Misiur - 27.07.2012

pawn Код:
//Insert this
new team[32];
switch(PlayerInfo[playerid][team]) {
    case TEAM_ME:
    {
        team = "Team medic";
        break;
    }
    case TEAM_SE:
    {
        team = "Team security";
        break;
    }
    case TEAM_TE:
    {
        team = "Team terrorists";
        break;
    }
    default:
    {
        team = "No team";
    }
}


format(str, sizeof(str), "Name:[ %s ]\nLevel:[ %d ]\nMoney: [ %d ]\nCurrent gun: [ %s ]", name, score, money, current_gun);
//to
format(str, sizeof(str), "Name:[ %s ]\nLevel:[ %d ]\nMoney: [ %d ]\nCurrent gun: [ %s ]\nFraction: [ %s ]", name, score, money, current_gun, team);
@edit:

I assume you have in playerinfo field which is enum for team. But I'm not 100% certain. Also if you have exact name team, then you'll get error about shadowing variable


Re: Questions about stats. - iTzZh - 27.07.2012

Quote:
Originally Posted by Misiur
Посмотреть сообщение
pawn Код:
//Insert this
new team[32];
switch(PlayerInfo[playerid][team]) {
    case TEAM_ME:
    {
        team = "Team medic";
        break;
    }
    case TEAM_SE:
    {
        team = "Team security";
        break;
    }
    case TEAM_TE:
    {
        team = "Team terrorists";
        break;
    }
    default:
    {
        team = "No team";
    }
}


format(str, sizeof(str), "Name:[ %s ]\nLevel:[ %d ]\nMoney: [ %d ]\nCurrent gun: [ %s ]", name, score, money, current_gun);
//to
format(str, sizeof(str), "Name:[ %s ]\nLevel:[ %d ]\nMoney: [ %d ]\nCurrent gun: [ %s ]\nFraction: [ %s ]", name, score, money, current_gun, team);
@edit:

I assume you have in playerinfo field which is enum for team. But I'm not 100% certain. Also if you have exact name team, then you'll get error about shadowing variable
Set the 'new team[32]' to 'new teams[16]' because with your usage you would be using 128 bytes when you only need to use 64 bytes. You are wasting 64 bytes which over time add up which shows your script isn't optimized.


Re: Questions about stats. - Littlehelper - 27.07.2012

Quote:
Originally Posted by Devilxz97
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/stats", cmdtext, true, 10) == 0)
    {
        new DIALOG_STATS;
        new str[256];
        new money;
        new name;
        new score;
        new weapon[32];
        new playerweapon;
        money = PlayerInfo[playerid][pMoney],
        name = PlayerInfo[playerid][pName],
        score = PlayerInfo[playerid][pScore],
        weapon = PlayerInfo[playerid][pWeapon];
        GetWeaponName(playerweapon, weapon, sizeof(weapon));
        format(str, sizeof(str), "Name:[ %s ]\nMoney: [ %d ]\nScore: [ %d ]\nWeapon: [ %s ]", name,money,score,weapon);
        ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX , "PlayerStats", str, "Close", "");
        return 1;
    }
}
try this . .

How did you know he have that weapon enum or not?
And please stop posting random codes from your script.
There was not even need for string sized [256] in your heal command.