Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Admin saving/loading script using DOF2*/
- #include <a_samp>
- #include <DOF2>
- #include <zcmd>
- #include <sscanf2>
- /*Defines for writing faster*/
- #define SCM SendClientMessage
- /*Colors defined*/
- #define COLOR_RED 0xFF0000FF
- main()
- {
- print("Admin System + Commands using DOF2, ZCMD, SSCANF2 - by OxigEN.(Ox1gEN)");
- print("Credits for the include owners are above");
- }
- enum pStats
- {
- pAdmin
- }
- new pInfo[MAX_PLAYERS][pStats];
- public OnGameModeInit()
- {
- print("Admin Saving/Loading script by OxigEN (Ox1gEN) using DOF2, sscanf2 && zcmd");
- print("Credits to Double-O-Seven for DOF2");
- print("Credits to ZeeX for zcmd");
- print("Credits to Y_Less for sscanf2");
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetSpawnInfo(playerid, 0, 2, -851.9666,1555.6249,24.2900,260.1801, 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)
- {
- if(DOF2_FileExists(pFile(playerid)))
- {
- SpawnPlayer(playerid);
- LoadPstats(playerid);
- }
- else //It is suggested to create a login/register system in order to keep people's player safe and no one could hack it (unless they have the password ofcourse).
- {
- DOF2_CreateFile(pFile(playerid));
- DOF2_SetInt(pFile(playerid), "AdminLevel", 0);
- DOF2_SaveFile();
- SpawnPlayer(playerid);
- }
- return 1;
- }
- /*Setting someone an admin*/
- CMD:setadmin(playerid, params[])
- {
- new id, string[128], levels;
- if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1, "You're not an admin! Therefore you may not use this command"); //Admin RCON only.
- else if(sscanf(params, "ud", id, levels)) return SCM(playerid, -1, "USAGE: /setadmin [ID] [AdminLevel]");
- else if(id == INVALID_PLAYER_ID) return SCM(playerid, -1, "The id you've entered is either incorrect or invalid");
- else if(levels > 5) return SCM(playerid, COLOR_RED, "There are only FIVE availiable admin levels!");
- if(levels <= 5)
- {
- format(string, sizeof(string), "Lead Admin %s(%d) has set your admin level %d. Congratulations!", GetName(playerid), playerid, levels);
- SCM(id, COLOR_RED, string);
- pInfo[id][pAdmin] = levels;
- DOF2_SetInt(pFile(id), "AdminLevel", levels);
- format(string, sizeof(string), "You have set %s(%d) admin level of %d.", GetName2(id), id, levels);
- SCM(playerid, COLOR_RED, string);
- DOF2_SaveFile();
- }
- return 1;
- }
- /*Removing someone's admin permissions*/
- CMD:removeadmin(playerid, params[])
- {
- new id, string[128], reason[128];
- if(DOF2_GetInt(pFile(playerid), "AdminLevel") < 5) return SCM(playerid, -1, "You're not an admin! Therefore you may not use this command");
- else if(sscanf(params, "us[50]", id, reason)) return SCM(playerid, -1, "USAGE: /removeadmin [ID] [REASON]");
- else if(id == INVALID_PLAYER_ID) return SCM(playerid, -1, "The ID you've entered is either incorrect or invalid!");
- else if(pInfo[id][pAdmin] == 0) return SCM(playerid, COLOR_RED, "That player isn't an admin!");
- else
- {
- format(string, sizeof(string), "Lead Admin %s(%d) has removed your admin level - Reason: %s", GetName(playerid), playerid, reason);
- SCM(id, COLOR_RED, string);
- format(string, sizeof(string), "You have removed %s(%d)'s administrator position! Reason: %s", GetName2(id), id, reason);
- SCM(playerid, COLOR_RED, string);
- pInfo[id][pAdmin] = 0;
- DOF2_SetInt(pFile(id), "AdminLevel", 0);
- DOF2_SaveFile();
- }
- return 1;
- }
- /*Simple adming commands*/
- CMD:kick(playerid, params[])
- {
- new id, reason[126], string[128];
- if(!DOF2_GetInt(pFile(playerid), "AdminLevel")) return SCM(playerid, -1, "You're not an admin! Therefore you may not use this command");
- else if(sscanf(params, "us[50]", id, reason)) return SCM(playerid, -1, "USAGE: /kick [ID] [REASON]");
- else if(id == INVALID_PLAYER_ID) return SCM(playerid, -1, "The id you've entered is either incorrect or invalid");
- else
- {
- format(string, sizeof(string), "[KICK]: %s(%d) has been kicked by %s(%d) - Reason: %s", GetName2(id), id, GetName(playerid), playerid, reason);
- SendClientMessageToAll(COLOR_RED, string);
- Kick(id);
- }
- return 1;
- }
- CMD:ban(playerid, params[])
- {
- new id, reason[126], string[128];
- if(!DOF2_GetInt(pFile(playerid), "AdminLevel")) return SCM(playerid, -1, "You're not an admin! Therefore you may not use this command");
- else if(sscanf(params, "us[50]", id, reason)) return SCM(playerid, -1, "USAGE: /ban [ID] [REASON]");
- else if(id == INVALID_PLAYER_ID) return SCM(playerid, -1, "The id you've entered is either incorrect or invalid");
- else
- {
- format(string, sizeof(string), "[BAN]: %s(%d) has been banned by %s(%d) - Reason: %s", GetName2(id), id, GetName(playerid), id, reason);
- SendClientMessageToAll(COLOR_RED, string);
- Ban(id);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- DOF2_SetInt(pFile(playerid), "AdminLevel",pInfo[playerid][pAdmin]);
- DOF2_SaveFile();
- return 1;
- }
- public OnGameModeExit()
- {
- DOF2_SaveFile(); /* Here you must DOF2_SaveFile(); in order to save the file */
- DOF2_Exit(); /* Here you must DOF2_Exit(); in order to close DOF2 */
- }
- /*Useful stocks*/
- stock pFile(playerid)
- {
- new pName[MAX_PLAYER_NAME +1];
- new File[50];
- GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
- format(File,sizeof(File),"%s.ini",pName);
- return File;
- }
- stock LoadPstats(playerid)
- {
- pInfo[playerid][pAdmin] = DOF2_GetInt(pFile(playerid), "AdminLevel");
- }
- stock GetName(playerid)
- {
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- return pName;
- }
- stock GetName2(playerid)
- {
- new pName2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName2, sizeof(pName2));
- return pName2;
- }
Advertisement
Add Comment
Please, Sign In to add comment