Playerstats loading - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Playerstats loading (
/showthread.php?tid=114668)
Playerstats loading -
Tom_Dedi - 20.12.2009
Hello,
I have a problem
I want to change the save system etc. to MYSQL but when I put this function into my gamemode
than the gamemode don't load all commands actually my server load nothing
why?
Quote:
stock LoadPlayer(playerid)
{
new Data[100];
new rcnt=1;
new Field[64];
new query[128];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
MySQLCheck();
format(query,sizeof(query),"SELECT * FROM `"TABLENAME"` WHERE Username = '%s'",pname);
mysql_store_result();
mysql_fetch_row(Data);
mysql_strtok(Field, "|", Data);
while (mysql_strtok(Field, "|", "")==1)
{
if(rcnt==2)PlayerInfo[playerid][pID]=strval(Field);
if(rcnt==3)PlayerInfo[playerid][pUsername]=strval(Field);
if(rcnt==4)PlayerInfo[playerid][pKey]=strval(Field);
if(rcnt==5)PlayerInfo[playerid][pMoney]=strval(Field);
if(rcnt==6)PlayerInfo[playerid][pAuto]=strval(Field);
rcnt++;
}
return 1;
}
|
-Dedi
Re: Playerstats loading -
Marcel - 20.12.2009
Quote:
Originally Posted by Tom_Dedi
Quote:
stock LoadPlayer(playerid)
{
new Data[100];
new rcnt=1;
new Field[64];
new query[128];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
MySQLCheck();
format(query,sizeof(query),"SELECT * FROM `"TABLENAME"` WHERE Username = '%s'",pname);
mysql_store_result();
mysql_fetch_row(Data);
mysql_strtok(Field, "|", Data);
while (mysql_strtok(Field, "|", "")==1)
{
if(rcnt==2)PlayerInfo[playerid][pID]=strval(Field);
if(rcnt==3)PlayerInfo[playerid][pUsername]=strval(Field);
if(rcnt==4)PlayerInfo[playerid][pKey]=strval(Field);
if(rcnt==5)PlayerInfo[playerid][pMoney]=strval(Field);
if(rcnt==6)PlayerInfo[playerid][pAuto]=strval(Field);
rcnt++;
}
return 1;
}
|
|
format(query,sizeof(query),"SELECT * FROM `"
TABLENAME"` WHERE Username = '%s'",pname);
I don't think you have a table called TABLENAME, do you? Try looking in the example script which is with your plugin package.
Re: Playerstats loading -
s0nic - 20.12.2009
First of all you don't need the `" "` where the TABLENAME is at.
Secondly you should enhance that code..you can make it much better and make it load by there sql ID's.
Re: Playerstats loading -
Luka P. - 20.12.2009
I'm to start scripting with MySQL. Is it hard?
Re: Playerstats loading -
s0nic - 20.12.2009
Its not hard once you get used to it..im familiar with it since ive been using MySQL for a while..I used it in some of my websites that i coded, my GM and other stuff. You should check out the Moderntopia script, it uses MySql and it could help you to understand certain aspects of it.
Re: Playerstats loading -
Luka P. - 20.12.2009
Quote:
Originally Posted by Killaz/s0nic
Its not hard once you get used to it..im familiar with it since ive been using MySQL for a while..I used it in some of my websites that i coded, my GM and other stuff. You should check out the Moderntopia script, it uses MySql and it could help you to understand certain aspects of it.
|
Okay, thanks. I'll check it out.
Re: Playerstats loading -
Tom_Dedi - 20.12.2009
i change the plugin and now i have at the moment nothing problems
pls close
thanks for your help