SA-MP Forums Archive
Ostats - 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: Ostats (/showthread.php?tid=634437)



Ostats - Loinal - 19.05.2017

So, iam trying to get the player stats from the data base

But not working fine gives me errors

PHP код:
IRCCMD:ostats(botidchannel[], user[], host[], params[])
{
    new 
account[24],Query[72];
    if(
sscanf(params"s[24]"account))
         return 
IRC_Say(groupIDchannel"7Usage: 1!ostats [Account]");
    if(
<= strlen(account) >= 24) return IRC_Say(groupIDchannel"7Error: 1Player name cannot exceed 24 characters!");
    
mysql_format(mysqlQuerysizeof(Query), "SELECT Hours,Minutes,SkinID,Admin,Tokens,RaceWon,Kills,Deaths,Score,Money,Rdate FROM `players` WHERE `Username` = '%e'"account);
    
mysql_query(mysqlQuery);
    if(
cache_num_rows() >= 1)
    {
            new 
score,string[143];
            
cache_get_value_name_int(0"SkinID"pData[account][Skin]);
            
cache_get_value_name_int(0"Admin"pData[account][Admin]); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
            
cache_get_value_name_int(0"Money"pData[account][Money]);//Above
            
cache_get_value_name_int(0,"Kills"pData[account][Kills]);
            
cache_get_value_name_int(0,"Tokens"pData[account][Tokens]);
            
cache_get_value_name_int(0"Deaths"pData[account][Deaths]);
            
cache_get_value_name_int(0"Hours"pData[account][pHours]);
            
cache_get_value_name_int(0"Minutes"pData[account][pMinutes]);
            
cache_get_value_name_int(0"RaceWon"pData[account][RaceWon]);
            
//cache_get_value_name_int(0, "Score", score);
            //SetPlayerScore(playerid, score);
    
}
    else 
IRC_Say(groupIDchannel"7Error: 1this name not exists on database");
    return 
1;

Errors

Код:
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12484) : error 033: array must be indexed (variable "account")
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12485) : error 033: array must be indexed (variable "account")
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12486) : error 033: array must be indexed (variable "account")
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12487) : error 033: array must be indexed (variable "account")
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12488) : error 033: array must be indexed (variable "account")
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12489) : error 033: array must be indexed (variable "account")
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12490) : error 033: array must be indexed (variable "account")
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12491) : error 033: array must be indexed (variable "account")
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12492) : error 033: array must be indexed (variable "account")



Re: Ostats - coool - 19.05.2017

your 'account' variable is indexed and so the usage will also be indexed e.g
Quote:

pData[account[]][Skin] //Note the brackets in account[]




Re: Ostats - Loinal - 19.05.2017

Quote:
Originally Posted by coool
Посмотреть сообщение
your 'account' variable is indexed and so the usage will also be indexed e.g
now giving this
Код:
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12484) : error 029: invalid expression, assumed zero
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12485) : error 029: invalid expression, assumed zero
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12486) : error 029: invalid expression, assumed zero
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12487) : error 029: invalid expression, assumed zero
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12488) : error 029: invalid expression, assumed zero
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12489) : error 029: invalid expression, assumed zero
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12490) : error 029: invalid expression, assumed zero
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12491) : error 029: invalid expression, assumed zero
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12492) : error 029: invalid expression, assumed zero



Re: Ostats - aoky - 19.05.2017

Change "account" to "Account"


Re: Ostats - Loinal - 19.05.2017

Quote:
Originally Posted by aoky
Посмотреть сообщение
Change "account" to "Account"
Same


Re: Ostats - RxErT - 19.05.2017

Try this

PHP код:
pData[account[0]][Skin



Re: Ostats - Loinal - 19.05.2017

Quote:
Originally Posted by RxErT
Посмотреть сообщение
Try this

PHP код:
pData[account[0]][Skin
sameee


Re: Ostats - oMa37 - 19.05.2017

You're using the variable 'account' which is string as integer for player id in your pData array.


Re: Ostats - Loinal - 19.05.2017

Quote:
Originally Posted by oMa37
Посмотреть сообщение
You're using the variable 'account' which is string as integer for player id in your pData array.
What do you mean by that? i should change account?


Re: Ostats - oMa37 - 19.05.2017

What are you going to do after you load the player's stats? If you are going to show it in your IRC by a message, you should assign the values of the loaded data to new variables.