20.04.2012, 11:03
Hello, I was making SQL lite admin system, then i noticed that i had somekind wierd bug that it returns me number 48 from nothing...
a bits of code:
//loging in
//and saving on OnPlayerDisconnect
More info:
The issue comes when i try to login...
I haven't messed with integers but still why does it set my VIP level to 48 if i haven't even messed with it before.
I only set it to 0 before...
Thanks for help...
a bits of code:
pawn Код:
//under on filtserscript init
database = db_open("AdminSys.db");
db_query(database, "CREATE TABLE IF NOT EXISTS `USERS` (`NAME`, `PASSWORD`, `IP`, `SCORE`, `CASH`, `ADMIN`,`VIP`)");
//registring
format(Query, sizeof(Query), "INSERT INTO `USERS` (`NAME`, `PASSWORD`, `IP`, `SCORE`, `CASH`, `ADMIN`, `VIP`) VALUES('%s','%s','%s', '%i', '%i', '0', '0')", DB_Escape(name), DB_Escape(pass), DB_Escape(ip),GetPlayerScore(playerid),GetPlayerMoney(playerid));
db_query(database, Query);
pawn Код:
format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(pass));
Result = db_query(database, Query);
if(db_num_rows(Result))
{
SendClientMessage(playerid,0xFFFFFFAA,""COL_GREEN"You are not registred, Please register! /register");
db_get_field_assoc(Result, "ADMIN", pInfo[playerid][pAdmin], 30);
db_get_field_assoc(Result, "VIP", pInfo[playerid][pVip], 30);
db_get_field_assoc(Result, "CASH", pInfo[playerid][pCash], 30);
db_get_field_assoc(Result, "SCORE", pInfo[playerid][pScore], 30);
pInfo[playerid][pLogged] = 1;
if(pInfo[playerid][pAdmin] >= 1)
{
switch(pInfo[playerid][pAdmin])
{
case 1: aRank = ARANK1;
case 2: aRank = ARANK2;
case 3: aRank = ARANK3;
case 4: aRank = ARANK4;
case 5: aRank = ARANK5;
case 6: aRank = ARANK6;
case 7: aRank = ARANK7;
}
format(string, sizeof(string), ""COL_GREEN"You have been successfully logged in, "COL_BLUE"Level: %i (Rank: %s)", pInfo[playerid][pAdmin],aRank);
SendClientMessage(playerid,0xFFFFFFAA,string);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,pInfo[playerid][pCash]);
SetPlayerScore(playerid,pInfo[playerid][pScore]);
} else if(pInfo[playerid][pAdmin] == 0 && pInfo[playerid][pVip] >= 1)
{
switch(pInfo[playerid][pVip])
{
case 1: vRank = VRANK1;
case 2: vRank = VRANK2;
case 3: vRank = VRANK3;
}
format(string, sizeof(string), ""COL_GREEN"You have been successfully logged in, "COL_BLUE"Vip Level: %i (Rank: %s)", pInfo[playerid][pVip],vRank);
SendClientMessage(playerid,0xFFFFFFAA,string);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,pInfo[playerid][pCash]);
SetPlayerScore(playerid,pInfo[playerid][pScore]);
} else if(pInfo[playerid][pAdmin] == 0 && pInfo[playerid][pVip] == 0)
{
format(string, sizeof(string), ""COL_GREEN"You have been successfully logged in,");
SendClientMessage(playerid,0xFFFFFFAA,string);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,pInfo[playerid][pCash]);
SetPlayerScore(playerid,pInfo[playerid][pScore]);
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
pInfo[playerid][pLogged] = 0;
pInfo[playerid][pRegistred] = 0;
new Query[ 300 ],DBResult: Result,name[ MAX_PLAYER_NAME ],ip[16];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerIp(playerid, ip, sizeof(ip));
format(Query, sizeof(Query), "SELECT `NAME` FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE", DB_Escape(name));
Result = db_query(database, Query);
if(db_num_rows(Result))
{
format(Query,sizeof(Query),"UPDATE `USERS` SET SCORE = '%d', CASH = '%d', ADMIN = '%d', VIP = '%d' WHERE `NAME` = '%s' COLLATE NOCASE",GetPlayerScore(playerid),GetPlayerMoney(playerid),pInfo[playerid][pAdmin],pInfo[playerid][pVip]);
db_query(database, Query);
}
return 1;
}
More info:
The issue comes when i try to login...
I haven't messed with integers but still why does it set my VIP level to 48 if i haven't even messed with it before.
I only set it to 0 before...
Thanks for help...