Questions about stats.
#1

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?
Reply
#2

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.
Reply
#3

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

sorry for the double post but please help.
Reply
#5

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);
Reply
#6

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 . .
Reply
#7

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
Reply
#8

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
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)