08.06.2012, 08:55
Here is my code,my command dosent work,it dosent reads my Admin dini number....
I dont know what to do anymore please can u help me? the command is /givemoney, i want it to work only if it has in dini admin lvl 2....
here is my code please can somebody help me so i can finally understand how to add a new dini value...and how to do an expresion like "if in dini Admin=2 then...."
I dont know what to do anymore please can u help me? the command is /givemoney, i want it to work only if it has in dini admin lvl 2....
here is my code please can somebody help me so i can finally understand how to add a new dini value...and how to do an expresion like "if in dini Admin=2 then...."
Code:
// This is a comment // uncomment the line below if you want to write a filterscript #include <a_samp> #include <dini> #include <Sscanf> #define RED 0xF0182DFF #define GREEN 0x0FCD18FF #define WHITE 0xFFFDFDFF #define ORANGE 0xF6A113FF #define FORCE_LOGIN 0 //Force the player to login to spawn? Change to '1' to force login #define USERS_FILE "/Users/%s.ini" //The directory of which the files will be saved #define MAX_PASS_SIZE 16 //The maximum password length #define MIN_PASS_SIZE 4 //The minimum password length #define LOGIN_ATTEMPTS 3 //The maximum allowed false login attempts before being kicked #define KILLS_DEATHS 1 #define SKIN 1 #define CASH 1 #define SCORE 1 #define POSITION 1 #define WEAPONS 1 //May be slightly bugged #define HEALTH 1 #define ARMOUR 1 #define DRUNK_LEVEL 1 #define FIGHT_STYLE 1 #define VIRTUAL_WORLD 0 #define PLAYER_TIME 1 #define WANTED_LEVEL 1 #define TEAM 0 #define CLOCK 0 #define ADMIN #define USE_DIALOGS 1 //Use dialogs? Change to '1' to use them #define REGISTER 1 #define LOGIN 2 #define CHANGE_PASS 3 #define SetPlayerAdmin ////////inca in lucru enum pInfo { Float:x, Float:y, Float:z, Float:a, Wep1, Wep2, Wep3, Wep4, Wep5, Wep6, Wep7, Wep8, Ammo1, Ammo2, Ammo3, Ammo4, Ammo5, Ammo6, Ammo7, Ammo8, Hour, Min, Password[MAX_PASS_SIZE+1], Logged, FalseLogins, Admin, } new PlayerInfo[MAX_PLAYERS][pInfo]; new file[128]; new str[256]; main() { print("\n----------------------------------"); print(" Blank Gamemode by your name here"); print("----------------------------------\n"); } public OnGameModeInit() { ShowPlayerMarkers(0); return 1; } public OnGameModeExit() { return 1; } public OnPlayerRequestClass(playerid, classid) { SetPlayerColor(playerid, WHITE); SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746); SetSpawnInfo(playerid, 0, 60, 1480.8102, -1758.8420, 17.5313, 342.1488, 0, 0, 0, 0, 0, 0); SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); return 1; } public OnPlayerConnect(playerid) { format(file, sizeof(file), USERS_FILE, PlayerName(playerid)); if(!dini_Exists(file)) { #if USE_DIALOGS == 1 format(str, sizeof(str), "You do not have a registered account %s!\n\nPlease insert your desired password into the line below and click \"Submit\".\n\n Click \"Cancel\" to cancel registration.", PlayerName(playerid)); ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "Register An Account", str, "Submit", "Cancel"); #elseif USE_DIALOGS == 0 SendClientMessage(playerid, WHITE, "Server: You do not have a registered account! Please register. (/register <password>)"); #endif } else { #if USE_DIALOGS == 1 format(str, sizeof(str), "Welcome back %!Please login to your account.\n\nPlease insert your password into the line below and click \"Submit\". \n\n Click \"Cancel\" to cancel.", PlayerName(playerid)); ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login to Your Account", str, "Submit", "Cancel"); #elseif USE_DIALOGS == 0 SendClientMessage(playerid, WHITE, "Server: You have a registered account! Please login or re-connect with a different name. (/login <password>)"); #endif } return 1; } public OnPlayerDisconnect(playerid, reason) { format(file, sizeof(file), USERS_FILE, PlayerName(playerid)); if(PlayerInfo[playerid][Logged] == 1) { #if SKIN == 1 dini_IntSet(file, "Skin", GetPlayerSkin(playerid)); #endif #if CASH == 1 dini_IntSet(file, "Cash", GetPlayerMoney(playerid)); #endif #if SCORE == 1 dini_IntSet(file, "Score", GetPlayerScore(playerid)); #endif #if POSITION == 1 GetPlayerPos(playerid, PlayerInfo[playerid][x], PlayerInfo[playerid][y], PlayerInfo[playerid][z]); GetPlayerFacingAngle(playerid, PlayerInfo[playerid][a]); dini_FloatSet(file, "X", PlayerInfo[playerid][x]); dini_FloatSet(file, "Y", PlayerInfo[playerid][y]); dini_FloatSet(file, "Z", PlayerInfo[playerid][z]); dini_FloatSet(file, "A", PlayerInfo[playerid][a]); dini_IntSet(file, "Int", GetPlayerInterior(playerid)); #endif #if WEAPONS == 1 GetPlayerWeaponData(playerid, 0, PlayerInfo[playerid][Wep1], PlayerInfo[playerid][Ammo1]); GetPlayerWeaponData(playerid, 1, PlayerInfo[playerid][Wep2], PlayerInfo[playerid][Ammo2]); GetPlayerWeaponData(playerid, 2, PlayerInfo[playerid][Wep3], PlayerInfo[playerid][Ammo3]); GetPlayerWeaponData(playerid, 3, PlayerInfo[playerid][Wep4], PlayerInfo[playerid][Ammo4]); GetPlayerWeaponData(playerid, 4, PlayerInfo[playerid][Wep5], PlayerInfo[playerid][Ammo5]); GetPlayerWeaponData(playerid, 5, PlayerInfo[playerid][Wep6], PlayerInfo[playerid][Ammo6]); GetPlayerWeaponData(playerid, 6, PlayerInfo[playerid][Wep7], PlayerInfo[playerid][Ammo7]); GetPlayerWeaponData(playerid, 7, PlayerInfo[playerid][Wep8], PlayerInfo[playerid][Ammo8]); dini_IntSet(file, "Wep1", PlayerInfo[playerid][Wep1]); dini_IntSet(file, "Wep2", PlayerInfo[playerid][Wep2]); dini_IntSet(file, "Wep3", PlayerInfo[playerid][Wep3]); dini_IntSet(file, "Wep4", PlayerInfo[playerid][Wep4]); dini_IntSet(file, "Wep5", PlayerInfo[playerid][Wep5]); dini_IntSet(file, "Wep6", PlayerInfo[playerid][Wep6]); dini_IntSet(file, "Wep7", PlayerInfo[playerid][Wep7]); dini_IntSet(file, "Ammo1", PlayerInfo[playerid][Ammo1]); dini_IntSet(file, "Ammo2", PlayerInfo[playerid][Ammo2]); dini_IntSet(file, "Ammo3", PlayerInfo[playerid][Ammo3]); dini_IntSet(file, "Ammo4", PlayerInfo[playerid][Ammo4]); dini_IntSet(file, "Ammo5", PlayerInfo[playerid][Ammo5]); dini_IntSet(file, "Ammo6", PlayerInfo[playerid][Ammo6]); dini_IntSet(file, "Ammo7", PlayerInfo[playerid][Ammo7]); #endif #if HEALTH == 1 new Float:health; dini_FloatSet(file, "Health", GetPlayerHealth(playerid, health)); #endif #if ARMOUR == 1 new Float:armour; dini_FloatSet(file, "Armour", GetPlayerArmour(playerid, armour)); #endif #if DRUNK_LEVEL == 1 dini_IntSet(file, "DrunkLevel", GetPlayerDrunkLevel(playerid)); #endif #if FIGHT_STYLE == 1 dini_IntSet(file, "FightStyle", GetPlayerFightingStyle(playerid)); #endif #if VIRTUAL_WORLD == 1 dini_IntSet(file, "VirtualWorld", GetPlayerVirtualWorld(playerid)); #endif #if PLAYER_TIME == 1 GetPlayerTime(playerid, PlayerInfo[playerid][Hour], PlayerInfo[playerid][Min]); dini_IntSet(file, "pTime_Hour", PlayerInfo[playerid][Hour]); dini_IntSet(file, "pTime_Min", PlayerInfo[playerid][Min]); #endif #if WANTED_LEVEL == 1 dini_IntSet(file, "WantedLevel", GetPlayerWantedLevel(playerid)); #endif #if TEAM == 1 dini_IntSet(file, "Team", GetPlayerTeam(playerid)); #endif #if CLOCK == 1 dini_IntSet(file, "Clock", 1); #elseif CLOCK == 0 dini_IntSet(file, "Clock", 0); #endif } return 1; } public OnPlayerSpawn(playerid) { format(file, sizeof(file), USERS_FILE, PlayerName(playerid)); if(PlayerInfo[playerid][Logged] == 1) { #if POSITION == 1 if(dini_Float(file, "X") == 0 && dini_Float(file, "Y") == 0 && dini_Float(file, "Z") == 0) return 1; SetPlayerPos(playerid, dini_Float(file, "X"), dini_Float(file, "Y"), dini_Float(file, "Z")); SetPlayerFacingAngle(playerid, dini_Float(file, "A")); SetPlayerInterior(playerid, dini_Int(file, "Int")); #endif #if SKIN == 1 SetPlayerSkin(playerid, dini_Int(file, "Skin")); SetPlayerHealth(playerid, 100.0); #endif } return 1; } public OnPlayerDeath(playerid, killerid, reason) { #if KILLS_DEATHS == 1 if(PlayerInfo[killerid][Logged] == 1) { format(file, sizeof(file), USERS_FILE, PlayerName(killerid)); GivePlayerMoney(killerid, 10000); SendClientMessage(killerid,RED, "You killed an innocent person!, wanted level has been increased."); SendClientMessage(killerid,RED, "You stole $10,000 from your victim."); SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1); } if(PlayerInfo[playerid][Logged] == 1) { format(file, sizeof(file), USERS_FILE, PlayerName(playerid)); GivePlayerMoney(playerid, -10000); SendClientMessage(playerid,RED, "You were killed by an murderer."); SendClientMessage(playerid,RED, "You lost $10,000."); } #endif return 1; } public OnVehicleSpawn(vehicleid) { return 1; } public OnVehicleDeath(vehicleid, killerid) { return 1; } public OnPlayerText(playerid, text[]) { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256]; new idx; cmd = strtok(cmdtext, idx); format(file, sizeof(file), USERS_FILE, PlayerName(playerid)); if(strcmp(cmd, "/givemoney", true) == 0) { if(PlayerInfo[playerid][Admin] >= 2) { new tmp[30]; tmp = strtok(cmdtext, idx); new otherplayer = strval(tmp); if(IsPlayerConnected(otherplayer)) { GivePlayerMoney(otherplayer, 50000); } } else { SendClientMessage(playerid, -1, "You are not an admin!"); } return 1; } if(strcmp(cmd, "/register", true) == 0) { #if USE_DIALOGS == 0 new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, ORANGE, "Usage: /register <password>"); if(dini_Exists(file)) return SendClientMessage(playerid, RED, "Error: You are already registered! Please login. (/login <password>)"); if(PlayerInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "Error: You are already logged in!"); if(strlen(tmp) < MIN_PASS_SIZE || strlen(tmp) > MAX_PASS_SIZE) return format(str, sizeof(str), "Error: Password length must be between %d and %d characters long!", MIN_PASS_SIZE, MAX_PASS_SIZE); SendClientMessage(playerid, RED, str); dini_Create(file); dini_Set(file, "Password", encrypt(tmp)); SendClientMessage(playerid, GREEN, "Successfully registered! You have been automatically logged in!"); PlayerInfo[playerid][Logged] = 1; return 1; #elseif USE_DIALOGS == 1 if(dini_Exists(file)) return SendClientMessage(playerid, RED, "Error: You are already registered! Please login. (/login)"); if(PlayerInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "Error: You are already logged in!"); format(str, sizeof(str), "You do not have a registered account %s!\n\nPlease insert your desired password into the line below and click \"Submit\".\n\n Click \"Cancel\" to cancel registration.", PlayerName(playerid)); ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "Register An Account", str, "Submit", "Cancel"); return 1; #endif } if(strcmp(cmd, "/login", true) == 0) { #if USE_DIALOGS == 0 new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, ORANGE, "Usage: /login <password>"); if(!dini_Exists(file)) return SendClientMessage(playerid, RED, "Error: You are not registered! Please register. (/register <password>)"); if(PlayerInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "Error: You are already logged in!"); new pass_confirm[256]; pass_confirm = dini_Get(file, "Password"); if(strcmp(encrypt(tmp), pass_confirm, true) == 0) { PlayerInfo[playerid][Logged] = 1; SendClientMessage(playerid, GREEN, "Successfully logged in!"); #if POSITION == 1 if(dini_Float(file, "X") == 0 && dini_Float(file, "Y") == 0 && dini_Float(file, "Z") == 0) return 1; SetPlayerPos(playerid, dini_Float(file, "X"), dini_Float(file, "Y"), dini_Float(file, "Z")); SetPlayerFacingAngle(playerid, dini_Float(file, "A")); SetPlayerInterior(playerid, dini_Int(file, "Int")); #endif #if CASH == 1 GivePlayerMoney(playerid, dini_Int(file, "Cash")); #endif #if SKIN == 1 SetPlayerSkin(playerid, dini_Int(file, "Skin")); #endif #if SCORE == 1 SetPlayerScore(playerid, dini_Int(file, "Score")); #endif #if WEAPONS == 1 GivePlayerWeapon(playerid, dini_Int(file, "Wep1"), dini_Int(file, "Ammo1")); GivePlayerWeapon(playerid, dini_Int(file, "Wep2"), dini_Int(file, "Ammo2")); GivePlayerWeapon(playerid, dini_Int(file, "Wep3"), dini_Int(file, "Ammo3")); GivePlayerWeapon(playerid, dini_Int(file, "Wep4"), dini_Int(file, "Ammo4")); GivePlayerWeapon(playerid, dini_Int(file, "Wep5"), dini_Int(file, "Ammo5")); GivePlayerWeapon(playerid, dini_Int(file, "Wep6"), dini_Int(file, "Ammo6")); GivePlayerWeapon(playerid, dini_Int(file, "Wep7"), dini_Int(file, "Ammo7")); #endif #if HEALTH == 1 SetPlayerHealth(playerid, dini_Float(file, "Health")); #endif #if ARMOUR == 1 SetPlayerArmour(playerid, dini_Float(file, "Armour")); #endif #if DRUNK_LEVEL == 1 SetPlayerDrunkLevel(playerid, dini_Int(file, "DrunkLevel")); #endif #if FIGHT_STYLE == 1 SetPlayerFightingStyle(playerid, dini_Int(file, "FightStyle")); #endif #if VIRTUAL_WORLD == 1 SetPlayerVirtualWorld(playerid, dini_Int(file, "VirtualWorld")); #endif #if PLAYER_TIME == 1 SetPlayerTime(playerid, dini_Int(file, "pTime_Hour"), dini_Int(file, "pTime_Min")); #endif #if WANTED_LEVEL == 1 SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel")); #endif #if TEAM == 1 SetPlayerTeam(playerid, dini_Int(file, "Team")); #endif #if CLOCK == 1 TogglePlayerClock(playerid, dini_Int(file, "Clock")); #endif #if ADMIN == 1 SetPlayerAdmin(playerid, dini_Int(file, "Admin")); #endif } else { PlayerInfo[playerid][FalseLogins]++; if(PlayerInfo[playerid][FalseLogins] >= LOGIN_ATTEMPTS) { format(str, sizeof(str), "Admin: %s has been kicked. [Reason: %d false login attempts]", PlayerName(playerid), LOGIN_ATTEMPTS); SendClientMessageToAll(RED, str); Kick(playerid); } else { SendClientMessage(playerid, RED, "Error: Incorrect password."); } } #elseif USE_DIALOGS == 1 if(!dini_Exists(file)) return SendClientMessage(playerid, RED, "Error: You are not registered! Please register. (/register)"); if(PlayerInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "Error: You are already logged in!"); format(str, sizeof(str), "Welcome back %!Please login to your account.\n\nPlease insert your password into the line below and click \"Submit\". \n\n Click \"Cancel\" to cancel.", PlayerName(playerid)); ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login to Your Account", str, "Submit", "Cancel"); return 1; #endif } if(strcmp(cmd, "/changepass", true) == 0) { if(PlayerInfo[playerid][Logged] == 0) return SendClientMessage(playerid, RED, "Error: You need to be logged in to change your password."); if(!dini_Exists(file)) return SendClientMessage(playerid, RED, "Error: Loading your player file failed. Cannot continue."); #if USE_DIALOGS == 0 new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, ORANGE, "Usage: /changepass <password>"); if(strlen(tmp) < MIN_PASS_SIZE || strlen(tmp) > MAX_PASS_SIZE) { format(str, sizeof(str), "Error: Password must be between %d and %d characters long!", MIN_PASS_SIZE, MAX_PASS_SIZE); SendClientMessage(playerid, RED, str); return 1; } dini_Set(file, "Password", encrypt(tmp)); SendClientMessage(playerid, GREEN, "Success: Password changed!"); #elseif USE_DIALOGS == 1 ShowPlayerDialog(playerid, CHANGE_PASS, DIALOG_STYLE_INPUT, "Change your password..", "Please insert the password you would like and click \"Submit\".\nClick \"Cancel\" to cancel.", "Submit", "Cancel"); #endif return 1; } return 0; } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { return 1; } public OnPlayerEnterCheckpoint(playerid) { return 1; } public OnPlayerLeaveCheckpoint(playerid) { return 1; } public OnPlayerEnterRaceCheckpoint(playerid) { return 1; } public OnPlayerLeaveRaceCheckpoint(playerid) { return 1; } public OnRconCommand(cmd[]) { return 1; } public OnPlayerRequestSpawn(playerid) { #if FORCE_LOGIN == 1 if(PlayerInfo[playerid][Logged] == 0) return SendClientMessage(playerid, RED, "Error: Must be logged in to spawn! (/login <password>)"); #endif return 1; } public OnObjectMoved(objectid) { return 1; } public OnPlayerObjectMoved(playerid, objectid) { return 1; } public OnPlayerPickUpPickup(playerid, pickupid) { return 1; } public OnVehicleMod(playerid, vehicleid, componentid) { return 1; } public OnVehiclePaintjob(playerid, vehicleid, paintjobid) { return 1; } public OnVehicleRespray(playerid, vehicleid, color1, color2) { return 1; } public OnPlayerSelectedMenuRow(playerid, row) { return 1; } public OnPlayerExitedMenu(playerid) { return 1; } public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) { return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { return 1; } public OnRconLoginAttempt(ip[], password[], success) { return 1; } public OnPlayerUpdate(playerid) { return 1; } public OnPlayerStreamIn(playerid, forplayerid) { return 1; } public OnPlayerStreamOut(playerid, forplayerid) { return 1; } public OnVehicleStreamIn(vehicleid, forplayerid) { return 1; } public OnVehicleStreamOut(vehicleid, forplayerid) { return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { format(file, sizeof(file), USERS_FILE, PlayerName(playerid)); if(dialogid == REGISTER) { if(response == 1) { if(strlen(inputtext) < MIN_PASS_SIZE || strlen(inputtext) > MAX_PASS_SIZE) { format(str, sizeof(str), "Error: Password length must be between %d and %d characters long!", MIN_PASS_SIZE, MAX_PASS_SIZE); SendClientMessage(playerid, RED, str); format(str, sizeof(str), "You do not have a registered account %s!\n\nPlease insert your desired password into the line below and click \"Submit\".\n\n Click \"Cancel\" to cancel registration.", PlayerName(playerid)); ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "Register An Account", str, "Submit", "Cancel"); return 1; } dini_Create(file); dini_Set(file, "Password", encrypt(inputtext)); dini_IntSet(file, "Admin", 0); SendClientMessage(playerid, GREEN, "Successfully registered! You have been automatically logged in!"); PlayerInfo[playerid][Logged] = 1; } else { SendClientMessage(playerid, RED, "Error: You have cancelled registration!"); } } if(dialogid == LOGIN) { if(response == 1) { new pass_confirm[256]; pass_confirm = dini_Get(file, "Password"); if(strcmp(encrypt(inputtext), pass_confirm, true) == 0) { PlayerInfo[playerid][Logged] = 1; SendClientMessage(playerid, GREEN, "Successfully logged in!"); #if POSITION == 1 if(dini_Float(file, "X") == 0 && dini_Float(file, "Y") == 0 && dini_Float(file, "Z") == 0) return 1; SetPlayerPos(playerid, dini_Float(file, "X"), dini_Float(file, "Y"), dini_Float(file, "Z")); SetPlayerFacingAngle(playerid, dini_Float(file, "A")); SetPlayerInterior(playerid, dini_Int(file, "Int")); #endif #if CASH == 1 GivePlayerMoney(playerid, dini_Int(file, "Cash")); #endif #if SKIN == 1 SetPlayerSkin(playerid, dini_Int(file, "Skin")); #endif #if SCORE == 1 SetPlayerScore(playerid, dini_Int(file, "Score")); #endif #if WEAPONS == 1 GivePlayerWeapon(playerid, dini_Int(file, "Wep1"), dini_Int(file, "Ammo1")); GivePlayerWeapon(playerid, dini_Int(file, "Wep2"), dini_Int(file, "Ammo2")); GivePlayerWeapon(playerid, dini_Int(file, "Wep3"), dini_Int(file, "Ammo3")); GivePlayerWeapon(playerid, dini_Int(file, "Wep4"), dini_Int(file, "Ammo4")); GivePlayerWeapon(playerid, dini_Int(file, "Wep5"), dini_Int(file, "Ammo5")); GivePlayerWeapon(playerid, dini_Int(file, "Wep6"), dini_Int(file, "Ammo6")); GivePlayerWeapon(playerid, dini_Int(file, "Wep7"), dini_Int(file, "Ammo7")); #endif #if HEALTH == 1 SetPlayerHealth(playerid, dini_Float(file, "Health")); #endif #if ARMOUR == 1 SetPlayerArmour(playerid, dini_Float(file, "Armour")); #endif #if DRUNK_LEVEL == 1 SetPlayerDrunkLevel(playerid, dini_Int(file, "DrunkLevel")); #endif #if FIGHT_STYLE == 1 SetPlayerFightingStyle(playerid, dini_Int(file, "FightStyle")); #endif #if VIRTUAL_WORLD == 1 SetPlayerVirtualWorld(playerid, dini_Int(file, "VirtualWorld")); #endif #if PLAYER_TIME == 1 SetPlayerTime(playerid, dini_Int(file, "pTime_Hour"), dini_Int(file, "pTime_Min")); #endif #if WANTED_LEVEL == 1 SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel")); #endif #if TEAM == 1 SetPlayerTeam(playerid, dini_Int(file, "Team")); #endif #if CLOCK == 1 TogglePlayerClock(playerid, dini_Int(file, "Clock")); #endif } else { PlayerInfo[playerid][FalseLogins]++; if(PlayerInfo[playerid][FalseLogins] >= LOGIN_ATTEMPTS) { format(str, sizeof(str), "Admin: %s has been kicked. [Reason: %d false login attempts]", PlayerName(playerid), LOGIN_ATTEMPTS); SendClientMessageToAll(RED, str); Kick(playerid); } else { SendClientMessage(playerid, RED, "Error: Incorrect password."); format(str, sizeof(str), "Welcome back %!Please login to your account.\n\nPlease insert your password into the line below and click \"Submit\". \n\n Click \"Cancel\" to cancel.", PlayerName(playerid)); ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login to Your Account", str, "Submit", "Cancel"); } } } else { SendClientMessage(playerid, RED, "Error: You have cancelled!"); } } if(dialogid == CHANGE_PASS) { if(response == 1) { if(!strlen(inputtext)) return SendClientMessage(playerid, RED, "Error: You didn't enter a password!"); if(strlen(inputtext) < MIN_PASS_SIZE || strlen(inputtext) > MAX_PASS_SIZE) { format(str, sizeof(str), "Error: Password must be between %s and %s characters long!", MIN_PASS_SIZE, MAX_PASS_SIZE); SendClientMessage(playerid, RED, str); return 1; } dini_Set(file, "Password", encrypt(inputtext)); SendClientMessage(playerid, GREEN, "Success: Password changed!"); } else { SendClientMessage(playerid, RED, "Error: You have cancelled!"); } } return 1; } PlayerName(playerid) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); return name; } encrypt(pass[]) { static charset[] = "qwertyaQWERTYUIOPZXCVBNMLKJHGFDSAsdfghzxcvbnuiopjklm1324657809_"; static css = 63; new target[MAX_PASS_SIZE + 1]; new j = strlen(pass); new sum = j; new tmpp = 0; new i; new mod; for (i = 0; i < MAX_PASS_SIZE || i < j; i++) { mod = i % MAX_PASS_SIZE; tmpp = (i >= j) ? charset[(7 * i) % css] : pass[i]; sum = (sum + chrfind(tmpp, charset) + 1) % css; target[mod] = charset[(sum + target[mod]) % css]; } target[MAX_PASS_SIZE] = '\0'; return target; } stock chrfind(needle, haystack[], start = 0) { while(haystack[start]) { if(haystack[start++] == needle) { return start-1; } } return -1; } strtok(const st[], &index) { new length = strlen(st); while ((index < length) && (st[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (st[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = st[index]; index++; } result[index - offset] = EOS; return result; } public OnPlayerClickPlayer(playerid, clickedplayerid, source) { return 1; }