03.12.2015, 14:56
So this is my ban system now. But I would like to change it to a new on where it grabs from another table how would i do this.
here is my onplayerconnect
here is the SQL_Account_Check fuction
here is the dialog login response
here is the thread
here is the table i would like it to grab from
here is my onplayerconnect
Код:
public OnPlayerConnect(playerid) { new query[120]; mysql_format(mysql, query, sizeof(query),"SELECT `Pass`, `ID` FROM `players` WHERE `User` = '%e' LIMIT 1", GetUserName(playerid)); mysql_tquery(mysql, query, "SQL_Account_Check", "i", playerid); TogglePlayerSpectating(playerid, true); FixCameraPos(playerid); #if defined SQL_OnPlayerConnect return SQL_OnPlayerConnect(playerid); #else return false; #endif }
Код:
public SQL_Account_Check(playerid) { new rows, fields; cache_get_data(rows, fields, mysql); if(rows) { cache_get_field_content(0, "Pass", Player[playerid][Pass], mysql, 129); Player[playerid][ID] = cache_get_field_content_int(0, "ID"); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Authenticate", "{FFFFFF}Your account already exists. Please\nauthenticate by typing your password below.", "Login", "Quit"); FixCameraPos(playerid); LoginTimer[playerid] = SetTimerEx("PendingLogin", 1000, true, "i", playerid); LoginTimeLeft[playerid] = 30; } else ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registration", "{FFFFFF}Your account does not exist. Please register below\nbefore playing so your statistics save.", "Next", "Quit"); FixCameraPos(playerid); return true; }
Код:
case DIALOG_LOGIN: { if(!response) return Kick(playerid); WP_Hash(hpass, 129, inputtext); if(!strcmp(hpass, Player[playerid][Pass])) { mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `User` = '%e' LIMIT 1", GetUserName(playerid)); // limit result to 1 mysql_tquery(mysql, query, "SQL_Account_Load", "i", playerid); SetTimerEx("SQL_Account_BanCheck", 1000, false, "i", playerid); KillTimer(LoginTimer[playerid]); TextDrawShowForPlayer(playerid, ClockTD); StartLevelingTimer(playerid); LoginAttempt[playerid] = 0; Logged[playerid] = true; } else { if(LoginAttempt[playerid] >= 2) { SetTimerEx("KickPlayer", 1000, false, "i", playerid); SendClientMessage(playerid, COLOR_ERROR, "Too many failed login attempts!"); Logged[playerid] = false; LoginAttempt[playerid] = 0; } LoginAttempt[playerid] ++; ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Authenticate", "{FFFFFF}Your account already exists. Please\nauthenticate by typing your password below.\n\nYou have entered a {F05151}incorrect{FFFFFF} password!", "Login", "Quit"); } }
Код:
forward SQL_Account_BanCheck(playerid); public SQL_Account_BanCheck(playerid) { new string[70]; if(Player[playerid][AccountLocked]) { format(string, sizeof(string), "Your account has been locked. Please head to ---"); if(Player[playerid][AccountBanned]) { format(string, sizeof(string), "Your account is banned. Banning administrator: %s", Player[playerid][BanningAdmin]); SendClientMessage(playerid, COLOR_ERROR, string); format(string, sizeof(string), "Banning reason: %s", Player[playerid][BannedReason]); SendClientMessage(playerid, COLOR_ERROR, string); } SendClientMessage(playerid, COLOR_ERROR, string); SetTimerEx("KickPlayer", 1000, false, "i", playerid); } else if(!Player[playerid][AccountLocked]) { TogglePlayerSpectating(playerid, false); SetSpawnInfo(playerid, 0, Player[playerid][SkinID], SERVER_SPAWN_X, SERVER_SPAWN_Y, SERVER_SPAWN_Z, SERVER_SPAWN_A, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); SetCameraBehindPlayer(playerid); } return true; }
