25.09.2009, 17:11
Good evening,
Thanks to anyone whos willing to give me a hand here, I only need help so I know how to do it in the future, I'm a slow learner, however I am willing.
I use G-Styleez example pwn script as a base for my own, just so I learn MYSQL, I tried adding more fields in to my table, after I had WAMP working that is.
I'd appreciate it if someone could tell me how to get that to retrieve the registered users data, at the moment it just crashes the server, I know the error is somewhere within here.
Thanks a lot for anyone who helps, it is greatly appreciated.
Thanks to anyone whos willing to give me a hand here, I only need help so I know how to do it in the future, I'm a slow learner, however I am willing.
I use G-Styleez example pwn script as a base for my own, just so I learn MYSQL, I tried adding more fields in to my table, after I had WAMP working that is.
pawn Код:
LoginPlayer(playerid,pass[])
{
new
pName[MAX_PLAYER_NAME],
query[256],
string[256];
GetPlayerName(playerid,pName,sizeof(pName));
MySQLCheck();
mysql_real_escape_string(pName,pName);
mysql_real_escape_string(pass,pass);
format(query,sizeof(query),"SELECT * FROM `"TABLENAME"` WHERE Username = '%s' AND Password = md5('%s') LIMIT 1",pName,pass);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() == 1)
{
new pName1[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName1,sizeof(pName1));
format(query,sizeof(query),"SELECT * FROM `"TABLENAME"` WHERE Username = '%s' LIMIT 1", pName1);
mysql_query(query);
new datafield[10],row[100];
mysql_fetch_row(row);
mysql_fetch_field_row(datafield,"Money");
PlayerInfo[playerid][Money] = strval(datafield);
mysql_store_result();
mysql_fetch_field_row(datafield,"Admin");
PlayerInfo[playerid][Admin] = strval(datafield);
mysql_store_result();
mysql_fetch_field_row(datafield,"VIP");
PlayerInfo[playerid][VIP] = strval(datafield);
mysql_store_result();
GivePlayerMoney(playerid,PlayerInfo[playerid][Money]);
mysql_free_result();
LoggedIn[playerid] = true;
format(string,sizeof(string)," You are now logged in!");
SendClientMessage(playerid,NOTICE,string);
return 1;
}
else
{
Wrongattempt[playerid] += 1;
printf("Bad log in attempt by %s (Total attempts: %d)",pName,Wrongattempt[playerid]);
if(Wrongattempt[playerid] >= 3)
{
mysql_free_result();
return KickEx(playerid, "System", "3 Bad Login Attempts");
}
mysql_free_result();
SendClientMessage(playerid,ERROR," Wrong Password!");
}
return 1;
}
pawn Код:
new pName1[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName1,sizeof(pName1));
format(query,sizeof(query),"SELECT * FROM `"TABLENAME"` WHERE Username = '%s' LIMIT 1", pName1);
mysql_query(query);
new datafield[10],row[100];
mysql_fetch_row(row);
mysql_fetch_field_row(datafield,"Money");
PlayerInfo[playerid][Money] = strval(datafield);
mysql_store_result();
mysql_fetch_field_row(datafield,"Admin");
PlayerInfo[playerid][Admin] = strval(datafield);
mysql_store_result();
mysql_fetch_field_row(datafield,"VIP");
PlayerInfo[playerid][VIP] = strval(datafield);
mysql_store_result();
GivePlayerMoney(playerid,PlayerInfo[playerid][Money]);
mysql_free_result();