//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);
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]);
}
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;
}
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);
new szUnload[30];
db_get_field_assoc(Result, "ADMIN", szUnload, sizeof(szUnload));
pInfo[playerid][pAdmin] = strval(szUnload);
db_get_field_assoc(Result, "VIP", szUnload, sizeof(szUnload));
pInfo[playerid][pVip] = strval(szUnload);
db_get_field_assoc(Result, "CASH", szUnload, sizeof(szUnload));
pInfo[playerid][pCash] = strval(szUnload);
db_get_field_assoc(Result, "SCORE", szUnload, sizeof(szUnload));
pInfo[playerid][pScore] = strval(szUnload);
You should know that db_get_field_assoc() returns a string, the code you have here:
pawn Код:
pawn Код:
|