SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/07/2018, 02:12 PM   #1
Filbert
Huge Clucker
 
Join Date: May 2016
Posts: 251
Reputation: 1
Question /stats error

Code:
D:\SA-MP Servers\Test Server\gamemodes\Test.pwn(23346) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
PHP Code:
CMD:stats(playerid,params[]) {
    new 
player1;
    if(
sscanf(params,"i",player1)) {
       new 
string[500],Registered1[10],LoggedIn1[10],AdminLevel1[10],h,m,s,pDeaths;
       new 
HourMinuteSecondgettime(HourMinuteSecond);
       
TotalGameTime(playeridhms);
       if(
PlayerInfo[playerid][Registered] == 1){Registered1 "Yes";} else {Registered1 "No";}
       if(
PlayerInfo[playerid][LoggedIn] == 1){LoggedIn1 "Yes";} else {LoggedIn1 "No";}
       if(
PlayerInfo[playerid][Hide] == 1){AdminLevel1 "0";} else {AdminLevel1 PlayerInfo[playerid][Level];} // <<< Line 23346
       
if(PlayerInfo[playerid][Deaths] == 0pDeaths 1; else pDeaths PlayerInfo[playerid][Deaths];
       
format(string,sizeof string,"{ff4d4d}Stats of %s\n\n{FFFFFF}Registered: %s\nLoggedIn: %s\nAdmin Level: %d\nScore: %d\nTime: %d hrs %d mins %d secs\nPing: %d\nCountry: %s\
       \n\n{33AA33}Cash: $%d\nBank: $%d\n\n{FFFFFF}Skin: %d\nWanted level: %d\n\n{FFFF00}Kills and Deaths\n{FFFFFF}Kills: %d\nDeaths: %d\nRatio: %f"
,
       
pName(playerid),Registered1,LoggedIn1,AdminLevel1,GetPlayerScore(playerid),h,m,s,GetPlayerPing(playerid),GetPlayerCountryName(playerid),
       
GetPlayerMoney(playerid),PlayerInfo[playerid][Bank],GetPlayerSkin(playerid),GetPlayerWantedLevel(playerid),PlayerInfo[playerid][Kills],PlayerInfo[playerid][Deaths],
       
Float:PlayerInfo[playerid][Kills]/Float:pDeaths);
       return 
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Stats"string"Ok","");
    }
    new 
string[500],Registered1[10],LoggedIn1[10],h,m,s,pDeaths;
    new 
HourMinuteSecondgettime(HourMinuteSecond);
    
TotalGameTime(player1hms);
    if(
PlayerInfo[player1][Registered] == 1){Registered1 "Yes";} else {Registered1 "No";}
    if(
PlayerInfo[player1][LoggedIn] == 1){LoggedIn1 "Yes";} else {LoggedIn1 "No";}
    if(
PlayerInfo[player1][Deaths] == 0pDeaths 1; else pDeaths PlayerInfo[player1][Deaths];
    
format(string,sizeof string,"{ff4d4d}Stats of %s\n\n{FFFFFF}Registered: %s\nLoggedIn: %s\nAdmin Level: %d\nScore: %d\nTime: %d hrs %d mins %d secs\nPing: %d\nCountry: %s\
    \n\n{33AA33}Cash: $%d\nBank: $%d\n\n{FFFFFF}Skin: %d\nWanted level: %d\n\n{FFFF00}Kills and Deaths\n{FFFFFF}Kills: %d\nDeaths: %d\nRatio: %0.2f"
,
    
pName(player1),Registered1,LoggedIn1,PlayerInfo[player1][Level],GetPlayerScore(player1),h,m,s,GetPlayerPing(player1),GetPlayerCountryName(player1),
    
GetPlayerMoney(player1),PlayerInfo[player1][Bank],GetPlayerSkin(player1),GetPlayerWantedLevel(player1),PlayerInfo[player1][Kills],PlayerInfo[player1][Deaths],
    
Float:PlayerInfo[player1][Kills]/Float:pDeaths);
    return 
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Stats"string"Ok","");

Filbert is offline   Reply With Quote
Old 02/07/2018, 02:37 PM   #2
Mike861
Huge Clucker
 
Join Date: Feb 2018
Posts: 233
Reputation: 16
Default Re: /stats error

Try to put those [10] numbers inside a tag in message formatting, like instead of LoggedIn1 try LoggedIn1[10]
Mike861 is offline   Reply With Quote
Old 02/07/2018, 02:41 PM   #3
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,227
Reputation: 205
Default Re: /stats error

AdminLevel1 should be an integer.

When you have repeated code, make it a function.
You can use ternary operator for "Yes"/"No".
Based on its name, when "Hide" is 1 shouldn't have been admin level 0? If not, change it in the code.

PHP Code:
CMD:stats(playeridparams[]) 
{
    new 
player1;

    if (
sscanf(params"i"player1)) player1 playerid;

    
ShowStatsForPlayer(playeridplayer1);
    return 
1;
}

ShowStatsForPlayer(viewertarget)
{
    new 
string[500], hms;

    
TotalGameTime(targethms);

    
format(stringsizeof string,
        
"{ff4d4d}Stats of %s\n\n{FFFFFF}Registered: %s\nLoggedIn: %s\nAdmin Level: %d\nScore: %d\nTime: %d hrs %d mins %d secs\nPing: %d\nCountry: %s\
        \n\n{33AA33}Cash: $%d\nBank: $%d\n\n{FFFFFF}Skin: %d\nWanted level: %d\n\n{FFFF00}Kills and Deaths\n{FFFFFF}Kills: %d\nDeaths: %d\nRatio: %f"

        
pName(target),
        
PlayerInfo[target][Registered] == ? ("Yes") : ("No"),
        
PlayerInfo[target][LoggedIn] == ? ("Yes") : ("No"),
        
PlayerInfo[target][Hide] == PlayerInfo[target][Level],
        
GetPlayerScore(target),
        
hms,
        
GetPlayerPing(target),
        
GetPlayerCountryName(target),
        
GetPlayerMoney(target),
        
PlayerInfo[target][Bank],
        
GetPlayerSkin(target),
        
GetPlayerWantedLevel(target),
        
PlayerInfo[target][Kills],
        
PlayerInfo[target][Deaths],
        
PlayerInfo[target][Deaths] == ? (FloatPlayerInfo[target][Kills] / Float1) : (FloatPlayerInfo[target][Kills] / FloatPlayerInfo[target][Deaths]));

    return 
ShowPlayerDialog(playerid0DIALOG_STYLE_MSGBOX"Stats"string"Ok""");

Calisthenics is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/stats error boy Server Support 3 11/10/2014 10:07 AM
/stats error boy Scripting Help 6 11/10/2014 02:13 AM
/stats Error WhiteAngels Scripting Help 6 12/04/2014 04:23 PM
Stats Error R4mpage Scripting Help 5 23/12/2013 05:44 PM


All times are GMT. The time now is 05:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.