/stats command
#1

Hey, I want to know how to make a /stats command to show the players state Like Name, Kills, deaths Kill/death ratio etc.
Im using Y_INI.
Reply
#2

Here is for example:

PHP Code:
    if (strcmp(cmd"/stats"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            new 
admin PlayerInfo[playerid][pAdminLevel];
            new 
vip PlayerInfo[playerid][pVIP];
            new 
money PlayerInfo[playerid][pCash];
            new 
level PlayerInfo[playerid][pScore];
            new 
vw PlayerInfo[playerid][pVw];
            new 
interior PlayerInfo[playerid][pInt];
            new 
string1[128],stats[1024];
            
format(string1sizeof string1"{44A1D0}Level: {FFFFFF}[%d] {44A1D0}Money: {FFFFFF}[$%d] {44A1D0}AdminLevel: {FFFFFF}[$%d] {44A1D0}VIP: {FFFFFF}[$%d] {44A1D0}VW: {FFFFFF}[$%d] {44A1D0}Int: {FFFFFF}[$%d]"level,money,admin,vip,vw,interior);
            
format(statssizeof stats"%s"string1);
            
ShowPlayerDialog(playerid,3,DIALOG_STYLE_MSGBOX,"Your account:",stats,"Ok","");
        }
        return 
1;
    } 
Reply
#3

mabye you could explain which did what so I know?
Reply
#4

find something like this in your mod:

PHP Code:
enum pInfo
{
    
pPass,
    
pAdminLevel,
    
pVIP,
    
pCash,
    
pScore,
    
pVw,
    
pInt
}
new 
PlayerInfo[MAX_PLAYERS][pInfo]; 
i don't know perfect english so i can't explain...i think you something understand,it's easy..
Reply
#5

I have that in my mode, I need to know why you made a new variable for each thing under the command. and what the dialog is for.
Reply
#6

Quote:
pawn Code:
format(string1, sizeof string1, "{44A1D0}Level: {FFFFFF}[%d] {44A1D0}Money: {FFFFFF}[$%d] {44A1D0}AdminLevel: {FFFFFF}[$%d] {44A1D0}VIP: {FFFFFF}[$%d] {44A1D0}VW: {FFFFFF}[$%d] {44A1D0}Int: {FFFFFF}[$%d]", level,money,admin,vip,vw,interior);
You really don't need to create new variables. You could do it as well like this:

Code:
format(string,sizeof(string),"[Adminlevel: %d || Kills: %d ]",Player[playerid][Adminlevel],Player[playerid][Kills]);
So that means: You assign a Variable, in our case the normal player variable, to a sign inside a string.

( Player[playerid][Adminlevel] = %d )

So that sign in the string will be replaced with the Adminlevel the player has.

Note:
%s = String [ex.: Player Motto]
%d // %i = Integer [ex.: Admin Level / Score]
%f = Float [ex.: Player Health]


And in his example, the dialoge is just there to make it look nicer. You can also output it to the player in form of a simple chat message (With SendClientMessage)
Reply
#7

Rep for you both.
Reply
#8

I get some errors..
PHP Code:
CMD:stats(playerid,params[]){
{
    if(
IsPlayerConnected(playerid))
    {
    new 
password PlayerInfo[playerid][pPass];
    new 
money PlayerInfo[playerid][pCash];
    new 
deaths PlayerInfo[playerid][pDeaths];
    new 
kills PlayerInfo[playerid][pKills];
    new 
score PlayerInfo[playerid][pScore];
    new 
admin PlayerInfo[playerid][pAdmin];
    new 
vip PlayerInfo[playerid][pVIP];
    new 
killpoints PlayerInfo[playerid][pKillPoints];
    new 
string[500];
    
format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d | VIP: %d | Killpoints: %d",password,money,deaths,kills,score,admin,vip,killpoints);
    
SendClientMessage(playerid,COLOR_WHITE,string);
    }
    return 
1;

Code:
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(192) : error 017: undefined symbol "UserPath"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(194) : error 017: undefined symbol "UserPath"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(205) : error 017: undefined symbol "GetName"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(217) : error 017: undefined symbol "UserPath"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(228) : error 017: undefined symbol "GetName"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(590) : error 017: undefined symbol "UserPath"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(592) : error 017: undefined symbol "udb_hash"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(613) : error 017: undefined symbol "udb_hash"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(615) : error 017: undefined symbol "UserPath"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(650) : error 079: inconsistent return types (array & non-array)
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(652) : warning 225: unreachable code
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(652) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(652) : error 017: undefined symbol "cmd_msg"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(652) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(652) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Reply
#9

pawn Code:
CMD:stats(playerid,params[])
{
    new password = PlayerInfo[playerid][pPass];
    new money = PlayerInfo[playerid][pCash];
    new deaths = PlayerInfo[playerid][pDeaths];
    new kills = PlayerInfo[playerid][pKills];
    new score = PlayerInfo[playerid][pScore];
    new admin = PlayerInfo[playerid][pAdmin];
    new vip = PlayerInfo[playerid][pVIP];
    new killpoints = PlayerInfo[playerid][pKillPoints];
    new string[500];
    format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d | VIP: %d | Killpoints: %d",password,money,deaths,kills,score,admin,vip,killpoints);
    SendClientMessage(playerid,COLOR_WHITE,string);
    return 1;
}
You were opening 3 brackets but closing only 2.
Reply
#10

I'm not seeing the reason in which why new variables are being defined and assigned to other variables. This makes no sense.

PHP Code:
format(string,sizeof(string),"Password: %s",PlayerInfo[playerid][pPass]); 
Reply
#11

Thanks smit, repped
Reply
#12

how would I get the email to display in stats, PlayerInfo[playerid][pEmail] YSI ? Thanks
Reply
#13

Guys Can You Fix This?Please!!

Код:
YCMD:stats(playerid,params[])
{
	new password = PlayerInfo[playerid][pPass];
	new money = PlayerInfo[playerid][pCash];
	new deaths = PlayerInfo[playerid][pDeaths];
	new kills = PlayerInfo[playerid][pKills];
	new score = PlayerInfo[playerid][pScore];
	new admin = PlayerInfo[playerid][pAdmin];
	new vip = PlayerInfo[playerid][pVIP];
	new killpoints = PlayerInfo[playerid][pKillPoints];
	new string[500];
	format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d | VIP: %d | Killpoints: %d",password,money,deaths,kills,score,admin,vip,killpoints); 
	SendClientMessage(playerid,COLOR_WHITE,string);
    return 1;
}
Код:
C:\Users\user\Desktop\Folder\gamemodes\test2.pwn(297) : warning 217: loose indentation
C:\Users\user\Desktop\Folder\gamemodes\test2.pwn(300) : warning 202: number of arguments does not match definition
C:\Users\user\Desktop\Folder\gamemodes\test2.pwn(306) : error 017: undefined symbol "pScore"
C:\Users\user\Desktop\Folder\gamemodes\test2.pwn(308) : error 017: undefined symbol "pVIP"
C:\Users\user\Desktop\Folder\gamemodes\test2.pwn(309) : error 017: undefined symbol "pKillPoints"
C:\Users\user\Desktop\Folder\gamemodes\test2.pwn(300) : warning 203: symbol is never used: "params"
C:\Users\user\Desktop\Folder\gamemodes\test2.pwn(497) : warning 204: symbol is assigned a value that is never used: "randMSG1"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#14

Alright first of all code is a mess.

Why would you create a new variable to show another since they are already defined? It makes no sense but we won't blame you now, it's fine but code is a mess and it's confusing.

So this is a basic command that will show your admin level
Код:
 CMD: myadminlevel(playerid, params[])
{
 new string[95]; // slightly increse value of this if some of the stats don't show up 
  format(string,sizeof(string),"My Admin Level is:  %i",PlayerInfo[playerid][pAdmin]);  
 SendClientMessage(playerid, -1, string);
 return 1;
}
%i is used to display numbers such as level of XP. STRING - %s is used to display a text, for an example your password or nickname. Float %f is used to display Coords/Health/Armor because float is a number but float is a decimal place (5.554545)

Let's focus on your case @ButlerSmcs

First of all, variables do not match the user stats system. Means pScore (inside that enum) is not affiliated with your code. Look for in your script for something like this:
Код:
enum pInfo 
{ 
   pAdmin,
}
Paste it here so we can begin with replacing it. Or you can do it alone! If your score variable is named Score instead of pScore in your command replace pScore with Score.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)