20.10.2012, 17:29
(
Последний раз редактировалось adithegman; 20.10.2012 в 17:33.
Причина: Misstake
)
I have a problem when player gets banned. It is suposed to set a variable to 1 and when a player with that nick banned connects to kick the player but it doesn't work, no errors, no warnings, nothing, Just doesn't work! The variable sets but it doesn't kick the player
Код:
enum pInfo { pPass, pLogged, pCash, pAdmin, pKills, pDeaths, pBanned } new PlayerInfo[MAX_PLAYERS][pInfo]; public OnPlayerConnect(playerid) { if(fexist(UserPath(playerid))) { if(PlayerInfo[playerid][pBanned] == 1) return Kick(playerid); INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit"); } else { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit"); } return 1; } public OnPlayerDisconnect(playerid, reason) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)); INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]); INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]); INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]); INI_Close(File); PlayerInfo[playerid][pLogged] = 0; return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case DIALOG_REGISTER: { if(!response) return Kick(playerid); if(response) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit"); new INI:File = INI_Open(UserPath(playerid)); new Name[MAX_PLAYER_NAME],string[128]; INI_SetTag(File,"data"); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteInt(File,"Logged",0); INI_WriteInt(File,"Cash",0); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Deaths",0); INI_WriteInt(File,"Banned",0); INI_Close(File); SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! You are now registered!","Ok",""); GetPlayerName(playerid,Name,sizeof(Name)); format(string,sizeof(string),"%s has registered.",Name); print(string); PlayerInfo[playerid][pLogged] = 1; } } case DIALOG_LOGIN: { if(!response) return Kick(playerid ); if(response) { if(udb_hash(inputtext) == PlayerInfo[playerid][pPass]) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok",""); new Name[MAX_PLAYER_NAME],string[128]; GetPlayerName(playerid,Name,sizeof(Name)); format(string,sizeof(string),"%s has logged in.",Name); print(string); PlayerInfo[playerid][pLogged] = 1; } else { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit"); } return 1; } return 1; } } return 1; } public OnPlayerClickPlayer(playerid, clickedplayerid, source) { return 1; } forward LoadUser_data(playerid,name[],value[]); public LoadUser_data(playerid,name[],value[]) { INI_Int("Password",PlayerInfo[playerid][pPass]); INI_Int("Cash",PlayerInfo[playerid][pCash]); INI_Int("Admin",PlayerInfo[playerid][pAdmin]); INI_Int("Kills",PlayerInfo[playerid][pKills]); INI_Int("Deaths",PlayerInfo[playerid][pDeaths]); INI_Int("Banned",PlayerInfo[playerid][pBanned]); return 1; } CMD:ban(playerid,params[]) { if(PlayerInfo[playerid][pAdmin] > 1) { if(PlayerInfo[playerid][pLogged] == 0) return SendClientMessage(playerid,COLOR_WHITE,"*** Trebuie sa te logezi/inregistrezi mai intai."); new id,reason[128]; if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,COLOR_RED,"Usage: /ban [playerid] [Reason]"); if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"Player Doesn't Exist"); new pName[24],name[24]; GetPlayerName(playerid,pName,24); GetPlayerName(id,name,24); new string[128]; format(string,128,"You've Baned %s. Reason: %s",name,reason); SendClientMessage(playerid,COLOR_YELLOW,string); format(string,128,"You've Been Baned By %s. Reason: %s",pName,reason); SendClientMessage(id,COLOR_YELLOW,string); format(string,128,"AdmCmd: %s was baned by %s. Reason: %s",name,pName,reason); SendClientMessageToAll(COLOR_LIGHTRED,string); format(string,128,"%s",reason); PlayerInfo[id][pBanned] = 1; BanEx(playerid,string); format(string,128,"AdmCmd: %s was baned by %s. Reason: %s",name,pName,reason); print(string); } else { SendClientMessage(playerid,COLOR_WHITE,"*** You are not authorized to use that command."); return 1; } return 1; }