Playerstats loading
#1

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
Reply
#2

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.
Reply
#3

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.
Reply
#4

I'm to start scripting with MySQL. Is it hard?
Reply
#5

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.
Reply
#6

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.
Reply
#7

i change the plugin and now i have at the moment nothing problems
pls close
thanks for your help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)