/stats
#1

I use this script but i want if the player is CIA , Army , Regular Player etc. it write Yes and if he isn't it write No

PHP код:
dcmd_stats(playerid,params[])
{
    
#pragma unused params
    
new Float:gihpFloat:giar;
    
GetPlayerHealth(playeridgihp);
    
GetPlayerArmour(playeridgiar);
    
GetPlayerWantedLevel(playerid);
    new 
string[128];
    new 
temp[1000];
    new 
info[1000];
    if(
IsSpawned[playerid] != 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 
1;
    }
    
format(tempsizeof(temp), "Name: %s(%d)\n",PlayerName(playerid),playerid);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Score: %i\n",GetPlayerScore(playerid));
    
strcat(infotemp);
    
format(tempsizeof(temp), "Cash: %d$\n",GetPlayerMoney(playerid));
    
strcat(infotemp);
    
format(tempsizeof(temp), "Bank Cash: %d$\n",BankCash[playerid]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Admin Level: %d\n",AdminLevel[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Army: %d\n",CanUseArmy[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "CIA: %d\n",CanUseCIA[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Regular Player: %d\n",IsRegularPlayer[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Trusted Regular Player: %d\n",IsTRP[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Warns: %d\n",Warns[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Terrorist Skill: %d\n",TerroristSkill[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Rob Skill: %d\n",RobSkill[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Cop Rank: %d\n",CopRank[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Has C4: %d\n",HasC4[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Secure Wallet: %d\n",HasSecureWallet[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Condoms: %d\n",HasCondoms[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Ropes: %d\n",HasRope[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Scissors: %d\n",HasScissors[playerid]);
    
strcat(infotemp);
    
    
format(tempsizeof(temp), "Kills: %d\n",Kills[playerid]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Deaths: %d\n",Deaths[playerid]);
    
strcat(infotemp);
    
ShowPlayerDialog(playerid,DIALOG_STATSDIALOG_STYLE_MSGBOX,"{53C506}Stats",info,"Close","");
    
format(string,sizeof(string),"[ADMIN SPY] %s(%d) has typed /stats.",PlayerName(playerid),playerid);
    
SendClientMessageToAllAdmins(string);
    return 
true;

Reply
#2

Add this to your command.

pawn Код:
new variable[4];
if(CanUseCIA[playerid]) format(variable, sizeof(variable), "Yes");
else format(variable, sizeof(variable), "No");
return variable;
Then replace this
pawn Код:
format(temp, sizeof(temp), "Army: %d\n",CanUseArmy[playerid]);
strcat(info, temp);
with

pawn Код:
format(temp, sizeof(temp), "Army: %s\n", variable);
strcat(info, temp);
Reply
#3

or with this one stock

Код:
stock YesNo(playerid)
{
      new string[5];
      switch(CanUseCIA[playerid])
      {
             case 0: string = "No";
             case 1: string = "Yes";
      }
      return string;
}
then use simply this

Код:
format(temp, sizeof(temp), "CIA: %s\n",YesNo(playerid));
strcat(info, temp);
Reply
#4

Quote:
Originally Posted by Boolean
Посмотреть сообщение
Add this to your command.

pawn Код:
new variable[4];
if(CanUseCIA[playerid]) format(variable, sizeof(variable), "Yes");
else format(variable, sizeof(variable), "No");
return variable;
Then replace this
pawn Код:
format(temp, sizeof(temp), "Army: %d\n",CanUseArmy[playerid]);
strcat(info, temp);
with

pawn Код:
format(temp, sizeof(temp), "Army: %s\n", variable);
strcat(info, temp);
PHP код:
dcmd_getstats(playerid,params[])
{
    new 
ID;
    new 
Float:gihpFloat:giar;
    
GetPlayerHealth(IDgihp);
    
GetPlayerArmour(IDgiar);
    
GetPlayerWantedLevel(ID);
    new 
temp[1000];
    new 
info[1000];
    
    if(
sscanf(params"u"ID))
    {
        
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /tinfo (Player Name/ID)");
        return 
1;
    }
    if(
IsSpawned[playerid] != 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 
1;
    }
    
format(tempsizeof(temp), "Name: %s(%d)\n",PlayerName(ID),ID);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Score: %i\n",GetPlayerScore(ID));
    
strcat(infotemp);
    
format(tempsizeof(temp), "Cash: %d$\n",GetPlayerMoney(ID));
    
strcat(infotemp);
    
format(tempsizeof(temp), "Bank Cash: %d$\n",BankCash[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Admin Level: %d\n",AdminLevel[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Army: %d\n",CanUseArmy[ID]);
    
strcat(infotemp);
    new 
variable[4];
    if(
CanUseCIA[playerid] == 1337format(variablesizeof(variable), "Yes");
    else 
format(variablesizeof(variable), "No");
    return 
variable;
    
    
format(tempsizeof(temp), "CIA: %d\n",variable);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Regular Player: %d\n",IsRegularPlayer[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Trusted Regular Player: %d\n",IsTRP[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Warns: %d\n",Warns[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Terrorist Skill: %d\n",TerroristSkill[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Rob Skill: %d\n",RobSkill[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Cop Rank: %d\n",CopRank[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Has C4: %d\n",HasC4[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Secure Wallet: %d\n",HasSecureWallet[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Condoms: %d\n",HasCondoms[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Ropes: %d\n",HasRope[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Scissors: %d\n",HasScissors[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Kills: %d\n",Kills[ID]);
    
strcat(infotemp);
    
format(tempsizeof(temp), "Deaths: %d\n",Deaths[ID]);
    
strcat(infotemp);
    
ShowPlayerDialog(playerid,DIALOG_STATSDIALOG_STYLE_MSGBOX,"{53C506}Stats",info,"Close","");
    return 
true;

ERRORS:
PHP код:
D:\Games\SFCRRPGv1.1\Best\gamemodes\SFCRRPG.pwn(4424) : error 033: array must be indexed (variable "dcmd_tinfo")
D:\Games\SFCRRPGv1.1\Best\gamemodes\SFCRRPG.pwn(5716) : error 079inconsistent return types (array & non-array)
D:\Games\SFCRRPGv1.1\Best\gamemodes\SFCRRPG.pwn(5721) : error 079inconsistent return types (array & non-array)
D:\Games\SFCRRPGv1.1\Best\gamemodes\SFCRRPG.pwn(5746) : warning 225unreachable code
D
:\Games\SFCRRPGv1.1\Best\gamemodes\SFCRRPG.pwn(5789) : error 079inconsistent return types (array & non-array)
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

and dEcoor's one , shows numbers , don't show words .
Reply
#5

remove "return" from here:
Код:
    if(CanUseCIA[playerid] == 1337) format(variable, sizeof(variable), "Yes"); 
    else format(variable, sizeof(variable), "No"); 
    return variable;
to
Код:
    if(CanUseCIA[playerid] == 1337) format(variable, sizeof(variable), "Yes"); 
    else format(variable, sizeof(variable), "No");
what is the logic of this?

Код:
    new ID; 
    new Float:gihp, Float:giar; 
    GetPlayerHealth(ID, gihp); 
    GetPlayerArmour(ID, giar); 
    GetPlayerWantedLevel(ID); 
    new temp[1000]; 
    new info[1000]; 
     
    if(sscanf(params, "u", ID)) 
    { 
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /tinfo (Player Name/ID)"); 
        return 1; 
    }
You first get player health and armour of ID 0 then take an ID

Код:
    new ID; 
    new Float:gihp, Float:giar; 

    new temp[1000]; 
    new info[1000]; 
     
    if(sscanf(params, "u", ID)) 
    { 
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /tinfo (Player Name/ID)"); 
        return 1; 
    } 
    GetPlayerHealth(ID, gihp); 
    GetPlayerArmour(ID, giar); 
    GetPlayerWantedLevel(ID);
GetPlayerWantedLevel return wanted level, but you dont store it anywhere

Why

Код:
    new temp[1000]; 
    new info[1000];
?
temp dont store so much info, so why 1000? temp lose his old value so just 30 (or more)


Код:
    if(CanUseCIA[playerid] == 1337) format(temp, sizeof(temp), "Yes"); 
    else format(temp, sizeof(temp), "No"); 
strcat(info, temp); // you miss this,
Another variable :/, we already have temp.


This error

inconsistent return types (array & non-array)

will be fixed when you remove "return variable" anyway take care of what i said.
Reply
#6

pawn Код:
#define Y(%0)   ((%0) ? 1 : 0)

GetPlayerStats(user)
{
    new str[1000];
    static const YesOrNo[][] = {"No","Yes"};
    new Score = GetPlayerScore(user);
    new Cash = GetPlayerMoney(user);
    new Lvl = AdminLevel[user];
    new Army = CanUseArmy[user];
    new CIA = CanUseCIA[user];
    new RegPla = IsRegularPlayer[user];
    new Trust = IsTRP[user];
    new C4 = HasC4[user];
    new Wallet = HasSecureWallet[user];
    new Con = HasCondoms[user];
    new Rope = HasRope[user];
    new Sci = HasScissors[user];
    new Kill = Kills[user];
    new Dead = Deaths[user];

    format(str, sizeof(str), "Name: %s(%d)\nScore: %d\nCash: %d$\nAdmin Level: %d\n\
    Army: %s\nCIA: %s\nRegular Player: %s\nTrusted Regular Player: %s\nWarns: %d\n\
    Terrorist Skill: %d\nRob Skill: %d\nCop Rank: %d\nHas C4: %s\nSecure Wallet: %s\n\
    Condoms: %s\nRopes: %s\nScissors: %s\nKills: %d\nDeaths: %d"
,
    PlayerName(user),user,Score,Cash,Lvl,YesOrNo[Y(Army)],YesOrNo[Y(CIA)],
    YesOrNo[Y(RegPla)],YesOrNo[Y(Trust)],Warns[user],TerroristSkill[user],
    RobSkill[user],CopRank[user],YesOrNo[Y(C4)],YesOrNo[Y(Wallet)],
    YesOrNo[Y(Con)],YesOrNo[Y(Rope)],YesOrNo[Y(Sci)],Kill,Dead);
    return str;
}

dcmd_stats(playerid,params[])
{
    #pragma unused params
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    new string[128];
    ShowPlayerDialog(playerid,DIALOG_STATS, DIALOG_STYLE_MSGBOX,"{53C506}Stats",GetPlayerStats(playerid),"Close","");
    format(string,sizeof(string),"[ADMIN SPY] %s(%d) has typed /stats.",PlayerName(playerid),playerid);
    SendClientMessageToAllAdmins(string);
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)