Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ______________________________________________
- You might edit this filterscript to your fits,
- but please do not remove credits, since there
- are not any credits appearing in-game, which
- is better to call this this filterscript yours.
- I don't care if you call this yours or not, I just want that my name is kept
- in here because my hard work counts a lot for me.
- ________________________________________________*/
- //Credits to Y_Less, Dracoblue and Kush. for most of includes
- #include <a_samp>
- #include <YSI\y_ini>
- #include <zcmd>
- #include <sscanf2>
- #include <foreach>
- // ------ Dialogs ----- //
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- // ------- Accounts ------//
- #define PATH "/Users/%s.ini"
- // ------- Colors ------ //
- #define COL_WHITE "{FFFFFF}"
- #define COL_RED "{F81414}"
- #define COL_GREEN "{00FF22}"
- #define COL_LIGHTBLUE "{00CED1}"
- #define COLOR_GREY 0xADADADFF
- #define COLOR_RED 0xFF3D3DFF
- #define COLOR_LIGHTRED 0xFF6347FF
- #define COLOR_PURPLE 0xFF2E6DFF
- enum pInfo
- {
- pPass,
- pCash,
- pAdmin
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- 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]);
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),PATH,playername);
- return string;
- }
- /*Credits to Dracoblue*/
- stock udb_hash(buf[]) {
- new length=strlen(buf);
- new s1 = 1;
- new s2 = 0;
- new n;
- for (n=0; n<length; n++)
- {
- s1 = (s1 + buf[n]) % 65521;
- s2 = (s2 + s1) % 65521;
- }
- return (s2 << 16) + s1;
- }
- main()
- {
- print("\n----------------------------------");
- print(" Admin system by iPrivate");
- print("----------------------------------\n");
- }
- public OnFilterScriptInit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new name[MAX_PLAYER_NAME+1];
- GetPlayerName(playerid, name, sizeof(name));
- SetPlayerCameraPos(playerid, 1061.1375, -1348.5317, 72.5953);
- SetPlayerCameraLookAt(playerid, 1062.0928, -1348.8217, 72.5754);
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Authentication","{FFFFFF}Welcome to {FF0000}Basic Roleplay\n{FFFFFF}Please type your password to login.","Login","Quit");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Authentication","{FFFFFF}Welcome to {FF0000}Basic Roleplay\n{FFFFFF}Please type your password to register.","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_Close(File);
- 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));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Password",udb_hash(inputtext));
- INI_WriteInt(File,"Cash",0);
- INI_WriteInt(File,"Admin",0);
- INI_Close(File);
- }
- }
- 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);
- }
- else
- {
- Kick(playerid);
- }
- return 1;
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- if(PlayerInfo[clickedplayerid][pAdmin] > 0)
- {
- new string[128];
- format(string, sizeof(string), "{FFFFFF}This player is an level {FF0000}%d{FFFFFF} admin.", PlayerInfo[clickedplayerid][pAdmin]);
- SendClientMessage(playerid, COLOR_RED, string);
- }
- return 1;
- }
- // ____________________ ADMIN COMMANDS _________________ //
- COMMAND:skin(playerid, params[], help)
- {
- new id;
- if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_RED, "[SREVER]You must be admin to use this commands");
- if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]{FFFFFF}Command: /skin id");
- if(id<0 || id>299) return SendClientMessage(playerid, COLOR_RED, "[SERVER]{FFFFFF}Please use IDs from 0 to 299");
- SetPlayerSkin(playerid,id);
- new msg[50];
- format(msg,sizeof(msg),"[SERVER]{FFFFFF}Your skin has been set to ID %d",id);
- return SendClientMessage(playerid,COLOR_RED,msg);
- }
- COMMAND:acmds(playerid, params[])
- {
- if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- else if(PlayerInfo[playerid][pAdmin] == 1) return SendClientMessage(playerid, COLOR_RED, "Level 1: /kick - /armour - /health - /camera - /freeze - /unfreeze - /skin - /slap");
- else if(PlayerInfo[playerid][pAdmin] == 2)
- {
- SendClientMessage(playerid, COLOR_RED, "Level 1: /kick - /armour - /health - /camera - /freeze - /unfreeze - /skin - /slap");
- SendClientMessage(playerid, COLOR_RED, "Level 2: /get - /goto - /ban - /announce - /givecar");
- }
- else if(PlayerInfo[playerid][pAdmin] == 3)
- {
- SendClientMessage(playerid, COLOR_RED, "Level 1: /kick - /armour - /health - /camera - /freeze - /unfreeze - /skin - /slap");
- SendClientMessage(playerid, COLOR_RED, "Level 2: /get - /goto - /ban - /announce - /givecar");
- SendClientMessage(playerid, COLOR_RED, "Level 3: /givegun - /kickall - /resetguns");
- }
- else if(PlayerInfo[playerid][pAdmin] == 4)
- {
- SendClientMessage(playerid, COLOR_RED, "Level 1: /kick - /armour - /health - /camera - /freeze - /unfreeze - /skin - /slap");
- SendClientMessage(playerid, COLOR_RED, "Level 2: /get - /goto - /ban - /announce - /givecar");
- SendClientMessage(playerid, COLOR_RED, "Level 3: /givegun - /kickall - /resetguns");
- SendClientMessage(playerid, COLOR_RED, "Level 4: /setlevel");
- }
- return 1;
- }
- COMMAND:kick(playerid, params[])
- {
- new id, reason[128];
- if(id==playerid)SendClientMessage(playerid,COLOR_RED,"Error: You can not kick yourself!");
- else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /kick [id/part of name][reason]");
- else if(PlayerInfo[playerid][pAdmin] >= 1)
- {
- new Name[MAX_PLAYER_NAME], KickMessage[128];
- new Name2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- GetPlayerName(id, Name2, sizeof(Name2));
- format(KickMessage, sizeof(KickMessage), "%s(%d) has kicked player %s(%d). Reason: %s", Name, playerid, Name2, id);
- SendClientMessageToAll(COLOR_RED, KickMessage);
- Kick(id);
- }
- else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- return 1;
- }
- COMMAND:ban(playerid, params[])
- {
- new id, reason[128];
- if(id==playerid)SendClientMessage(playerid,COLOR_RED,"Error: You can not kick yourself!");
- else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /kick [id/part of name][reason]");
- else if(PlayerInfo[playerid][pAdmin] >= 2)
- {
- new Name[MAX_PLAYER_NAME], KickMessage[128];
- new Name2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- GetPlayerName(id, Name2, sizeof(Name2));
- format(KickMessage, sizeof(KickMessage), "%s(%d) has banned player %s(%d). Reason: %s", Name, playerid, Name2, id);
- SendClientMessageToAll(COLOR_RED, KickMessage);
- Ban(id);
- }
- else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- return 1;
- }
- COMMAND:slap(playerid, params[])
- {
- new id, reason[128];
- if(id==playerid)SendClientMessage(playerid,COLOR_RED,"Error: You can not kick yourself!");
- else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /kick [id/part of name][reason]");
- else if(PlayerInfo[playerid][pAdmin] >= 1)
- {
- new Float: x, Float: y, Float: z;
- new string[256];
- new Name[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- GetPlayerName(playerid, Name2, sizeof(Name2));
- GetPlayerPos(id, x, y, z);
- format(string, sizeof(string), "%s(%d) has slapped %s(%d).", Name, playerid, Name2, id);
- SendClientMessageToAll(COLOR_RED, string);
- SetPlayerPos(id, x, y, z+2);
- GameTextForPlayer(id, "~r~SLAPPED!", 3000, 5);
- }
- else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- return 1;
- }
- COMMAND:armour(playerid, params[])
- {
- new id,reason[128];
- if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /armour [id/part of name]");
- else if(PlayerInfo[playerid][pAdmin] >= 1)
- {
- new Name[MAX_PLAYER_NAME], ArmourMessage[128];
- new Name2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- GetPlayerName(id, Name2, sizeof(Name2));
- format(ArmourMessage, sizeof(ArmourMessage), "%s(%d) has given player %s(%d) full armour.", Name, playerid, Name2, id);
- SendClientMessageToAll(COLOR_RED, ArmourMessage);
- SetPlayerArmour(id, 100);
- }
- else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- return 1;
- }
- COMMAND:health(playerid, params[])
- {
- new id,reason[128];
- if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /armour [id/part of name]");
- else if(PlayerInfo[playerid][pAdmin] >= 1)
- {
- new Name[MAX_PLAYER_NAME], HealthMessage[128];
- new Name2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- GetPlayerName(id, Name2, sizeof(Name2));
- format(HealthMessage, sizeof(HealthMessage), "%s(%d) has given player %s(%d) full health.", Name, playerid, Name2, id);
- SendClientMessageToAll(COLOR_RED, HealthMessage);
- SetPlayerHealth(id, 100);
- }
- else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- return 1;
- }
- COMMAND:camera(playerid, params[])
- {
- new id,reason[128];
- if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /camera [id/part of name]");
- else if(PlayerInfo[playerid][pAdmin] >= 1)
- {
- new Name[MAX_PLAYER_NAME], Message[128];
- new Name2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- GetPlayerName(id, Name2, sizeof(Name2));
- format(Message, sizeof(Message), "%s(%d) has given player %s(%d) a camera.", Name, playerid, Name2, id);
- SendClientMessageToAll(COLOR_RED, Message);
- SetPlayerHealth(id, 100);
- }
- else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- return 1;
- }
- COMMAND:freeze(playerid, params[])
- {
- new id,reason[128];
- if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /freeze [id/part of name]");
- else if(PlayerInfo[playerid][pAdmin] >= 1)
- {
- new Name[MAX_PLAYER_NAME], Message[128];
- new Name2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- GetPlayerName(id, Name2, sizeof(Name2));
- format(Message, sizeof(Message), "%s(%d) has frozen player %s(%d).", Name, playerid, Name2, id);
- SendClientMessageToAll(COLOR_RED, Message);
- TogglePlayerControllable(id, 0);
- }
- else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- return 1;
- }
- COMMAND:unfreeze(playerid, params[])
- {
- new id,reason[128];
- if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /unfreeze [id/part of name]");
- else if(PlayerInfo[playerid][pAdmin] >= 1)
- {
- new Name[MAX_PLAYER_NAME], Message[128];
- new Name2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- GetPlayerName(id, Name2, sizeof(Name2));
- format(Message, sizeof(Message), "%s(%d) has unfrozen player %s(%d).", Name, playerid, Name2, id);
- SendClientMessageToAll(COLOR_RED, Message);
- TogglePlayerControllable(id, 1);
- }
- else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- return 1;
- }
- COMMAND:get(playerid,params[])
- {
- if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Error: You have to be admin or you are not high level enoguh in order to use this command!");
- new id;
- new string[128];
- if(sscanf(params,"i",id)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /get [playerid]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- SetPlayerPos(id ,x,y,z);
- format(string, sizeof(string), "You have been teleported to ID %d", id);
- SendClientMessage(playerid, COLOR_RED, string);
- return 1;
- }
- COMMAND:goto(playerid,params[])
- {
- if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Error: You have to be admin or you are not high level enoguh in order to use this command!");
- new id;
- new string[128];
- if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /goto [playerid]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- SetPlayerPos(playerid,x,y,z);
- format(string, sizeof(string), "You have been teleported to ID %d", id);
- SendClientMessage(playerid, COLOR_RED, string);
- return 1;
- }
- COMMAND:setlevel(playerid,params[])
- {
- if(PlayerInfo[playerid][pAdmin] < 4 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- new id,level, name[MAX_PLAYER_NAME+4], string[148];
- GetPlayerName(id, name, sizeof(name));
- if(sscanf(params,"ii",id,level)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /setlevel [playerid] [level 0-5]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
- if(level > 5) return SendClientMessage(playerid,COLOR_RED,"Error! You can only pick between level 0/5 (0: Player - 1: Moderator - 2: Administrator - 3: Global Moderator - 4: Server Scripter - 5: Owner)");
- if(PlayerInfo[id][pAdmin] < level)
- {
- PlayerInfo[id][pAdmin] = level;
- format(string, sizeof(string), "You have been promoted to %d level succesfully.", level);
- SendClientMessage(id, COLOR_RED, string);
- format(string, sizeof(string), "You have promoted %s succesfully to level %d.", name, level);
- SendClientMessage(playerid, COLOR_RED, string);
- }
- else
- {
- PlayerInfo[id][pAdmin] = level;
- format(string, sizeof(string), "You have been demoted to %d level.", level);
- SendClientMessage(id, COLOR_RED, string);
- format(string, sizeof(string), "You have demoted %s succesfully to level %d.", name, level);
- SendClientMessage(playerid, COLOR_RED, string);
- }
- return 1;
- }
- COMMAND:givegun(playerid,params[])
- {
- if(PlayerInfo[playerid][pAdmin] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
- new id,weapon, name[MAX_PLAYER_NAME+4], string[148];
- GetPlayerName(id, name, sizeof(name));
- if(sscanf(params,"ii",id,weapon)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /givegun [playerid] [weaponid 1-45]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
- if(weapon > 45 && weapon < 1) return SendClientMessage(playerid,COLOR_RED,"Error! You may only choose weapons between 1 and 45.");
- if(PlayerInfo[id][pAdmin] < weapon)
- {
- GivePlayerWeapon(id, weapon, 50000);
- format(string, sizeof(string), "You have been given weapon with ID %d succesfully by administrator %s", weapon, name);
- SendClientMessage(id, COLOR_RED, string);
- }
- return 1;
- }
- COMMAND:resetguns(playerid,params[])
- {
- if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_RED, "Error: You have to be admin or you are not high level enoguh in order to use this command!");
- new id;
- new string[128];
- if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /resetguns [playerid]");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- SetPlayerPos(playerid,x,y,z);
- format(string, sizeof(string), "You have been reseted guns for ID %d", id);
- ResetPlayerWeapons(id);
- return 1;
- }
- CMD:givecar(playerid, params[])
- {
- new id, car, string[128];
- if(sscanf(params, "ud", id, car)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givecar [playerid] [vehicleid]");
- if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Error: You must be at least admin level 2 to use this command");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Error: That user ain't connected");
- new Float: x, Float: y, Float: z, Float: a;
- new name[MAX_PLAYER_NAME], names[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- GetPlayerName(id, names, sizeof(names));
- GetPlayerPos(id, x, y, z);
- GetPlayerFacingAngle(id, a);
- new rd1 = random(20);
- new rd2 = random(20);
- format(string, sizeof(string), "You have given %s(%d) vehicle with ID %d", names, id, car);
- SendClientMessage(playerid, COLOR_RED, string);
- format(string, sizeof(string), "%s(%d) has given you vehicle with ID %d", name, playerid, car);
- SendClientMessage(id, COLOR_RED, string);
- new veh = CreateVehicle(car, x, y, z, a, rd1, rd2, -1);
- PutPlayerInVehicle(id, veh, 0);
- return 1;
- }
- CMD:kickall(playerid, params[])
- {
- if(PlayerInfo[playerid][pAdmin] >= 3)
- {
- new string[128], name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- format(string, sizeof(string), "%s(%d) has kicked all players on the server.", name, playerid);
- SendClientMessageToAll(COLOR_RED, string);
- foreach(Player, i)
- {
- if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] == 0)
- {
- Kick(i);
- }
- }
- }
- return 1;
- }
- CMD:announce(playerid, params[])
- {
- new text[64], time, style, string[128];
- if(sscanf(params, "s[64]dd", text, time, style)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ann [text] [time(ms)] [style(0-5)]");
- if(strlen(text) < 0) return SendClientMessage(playerid, COLOR_RED, "Error: You didn't enter text.");
- if(!time) return SendClientMessage(playerid, COLOR_RED, "Error: You didn't add lasting time.");
- if(!style) return SendClientMessage(playerid, COLOR_RED, "Error: You didn't enter style.");
- if(PlayerInfo[playerid][pAdmin] < 3)
- {
- format(string, sizeof(string), "%s", text);
- foreach(Player, i)
- {
- if(IsPlayerConnected(i))
- {
- GameTextForPlayer(i, string, time, style);
- }
- }
- }
- else SendClientMessage(playerid, COLOR_RED, "Error: You are not an admin or your level is not high enough to use this command.");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement