Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2])))))
- #include <a_samp>
- #include <dini>
- //
- #define COLOUR_GREEN 0x33AA33AA
- #define COLOUR_RED 0xFF0000AA
- #define COLOUR_YELLOW 0xFFFF00AA
- #define COLOUR_LIGHTBLUE 0x33CCFFAA
- #define COLOUR_ORANGE 0xFF9900AA
- #define PlayerFile "AdminScript/Users/%s.ini"
- #define SettingFile "AdminScript/Settings/MainSettings.ini"
- #define CommandFile "AdminScript/Settings/Commands.ini"
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- if(!fexist(SettingFile))
- {
- dini_Create(SettingFile);
- dini_IntSet(SettingFile, "PocketMoney", 3000);
- dini_IntSet(SettingFile, "JailCommands", 0);
- dini_IntSet(SettingFile, "AnnounceSeconds", 3);
- dini_IntSet(SettingFile, "PassMin", 3);
- dini_IntSet(SettingFile, "PassMax", 15);
- }
- gSettings[POCKET_MONEY] = dini_Int(SettingFile, "PocketMoney");
- gSettings[JAIL_COMMANDS] = dini_Int(SettingFile, "JailCommands");
- gSettings[ANNOUNCE_SECONDS] = dini_Int(SettingFile, "AnnounceSeconds");
- gSettings[PASS_MIN] = dini_Int(SettingFile, "PassMin");
- gSettings[PASS_MAX] = dini_Int(SettingFile, "PassMax");
- if(!fexist(CommandFile))
- {
- dini_Create(CommandFile);
- dini_IntSet(CommandFile, "Akill", 1);
- dini_IntSet(CommandFile, "Announce", 1);
- dini_IntSet(CommandFile, "Armourall", 3);
- dini_IntSet(CommandFile, "Ban", 1);
- dini_IntSet(CommandFile, "Explode", 2);
- dini_IntSet(CommandFile, "Telmeto", 1);
- dini_IntSet(CommandFile, "Teltome", 2);
- dini_IntSet(CommandFile, "Givearmour", 2);
- dini_IntSet(CommandFile, "Givehealth", 1);
- dini_IntSet(CommandFile, "Giveweapon", 2);
- dini_IntSet(CommandFile, "God", 4);
- dini_IntSet(CommandFile, "Healall", 2);
- dini_IntSet(CommandFile, "Imitate", 3);
- dini_IntSet(CommandFile, "Ip", 1);
- dini_IntSet(CommandFile, "Kick", 1);
- dini_IntSet(CommandFile, "Ping", 1);
- dini_IntSet(CommandFile, "Setlevel", 4);
- dini_IntSet(CommandFile, "Sban", 4);
- dini_IntSet(CommandFile, "Time", 2);
- dini_IntSet(CommandFile, "Weather", 1);
- }
- gCommands[AKILL] = dini_Int(CommandFile, "Akill");
- gCommands[ANNOUNCE] = dini_Int(CommandFile, "Announce");
- gCommands[BAN] = dini_Int(CommandFile, "Ban");
- gCommands[EXPLODE] = dini_Int(CommandFile, "Explode");
- gCommands[TELMETO] = dini_Int(CommandFile, "Telmeto");
- gCommands[TELTOME] = dini_Int(CommandFile, "Teltome");
- gCommands[GIVEARMOUR] = dini_Int(CommandFile, "Givearmour");
- gCommands[GIVEHEALTH] = dini_Int(CommandFile, "Givehealth");
- gCommands[GIVEWEAPON] = dini_Int(CommandFile, "Giveweapon");
- gCommands[HEALALL] = dini_Int(CommandFile, "Healall");
- gCommands[IMITATE] = dini_Int(CommandFile, "Imitate");
- gCommands[IP] = dini_Int(CommandFile, "Ip");
- gCommands[KICK] = dini_Int(CommandFile, "Kick");
- gCommands[SETLEVEL] = dini_Int(CommandFile, "Setlevel");
- gCommands[SBAN] = dini_Int(CommandFile, "Sban");
- gCommands[TIME] = dini_Int(CommandFile, "Time");
- gCommands[WEATHER] = dini_Int(CommandFile, "Weather");
- return 1;
- }
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- #endif
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- enum PLAYER_MAIN {
- PLAYER_NAME[MAX_PLAYER_NAME],
- PLAYER_IP[16],
- PLAYER_REGGED,
- PLAYER_PASS,
- PLAYER_LOGGED,
- PLAYER_LEVEL,
- PLAYER_WIRED,
- PLAYER_JAILED
- }
- new gPlayerInfo[MAX_PLAYERS][PLAYER_MAIN];
- enum SETTINGS_MAIN {
- POCKET_MONEY,
- JAIL_COMMANDS,
- ANNOUNCE_SECONDS,
- PASS_MIN,
- PASS_MAX
- }
- new gSettings[SETTINGS_MAIN];
- enum COMMANDS_MAIN {
- AKILL,
- ANNOUNCE,
- BAN,
- EXPLODE,
- FLIP,
- TELMETO,
- TELTOME,
- GIVEARMOUR,
- GIVEHEALTH,
- GIVEWEAPON,
- HEALALL,
- IMITATE,
- IP,
- KICK,
- PING,
- SETLEVEL,
- SBAN,
- TIME,
- WEATHER
- }
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
- if(!dini_Exists(file)) {
- dini_Create(file);
- dini_Set(file,"Name",Name);
- dini_Set(file,"Ip",Ip);
- dini_IntSet(file,"Registered",-1);
- dini_IntSet(file,"Password",0);
- dini_IntSet(file,"Level",0);
- dini_IntSet(file,"Wired",0);
- dini_IntSet(file,"Jailed",0);
- SendClientMessage(playerid,COLOUR_ORANGE,"You're username is not recognized on this server. Please /register to continue.");
- }
- strcat(gPlayerInfo[playerid][PLAYER_NAME], dini_Get(file,"Name"));
- strcat(gPlayerInfo[playerid][PLAYER_IP], dini_Get(file,"Ip"));
- gPlayerInfo[playerid][PLAYER_REGGED] = dini_Int(file,"Registered");
- gPlayerInfo[playerid][PLAYER_PASS] = dini_Int(file,"Password");
- gPlayerInfo[playerid][PLAYER_LEVEL] = dini_Int(file,"Level");
- gPlayerInfo[playerid][PLAYER_WIRED] = dini_Int(file,"Wired");
- gPlayerInfo[playerid][PLAYER_JAILED] = dini_Int(file,"Jailed");
- if(gPlayerInfo[playerid][PLAYER_REGGED] == 0) SendClientMessage(playerid,COLOUR_ORANGE,"Username is regognized but not register.Please /register to continue.");
- else if(gPlayerInfo[playerid][PLAYER_REGGED] == 1) SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server. Please /login to continue.");
- gPlayerInfo[playerid][PLAYER_REGGED] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new file[100];
- format(file,sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]);
- dini_Set(file,"Name",gPlayerInfo[playerid][PLAYER_NAME]);
- dini_Set(file,"Ip",gPlayerInfo[playerid][PLAYER_IP]);
- dini_IntSet(file,"Registered",gPlayerInfo[playerid][PLAYER_REGGED]);
- dini_IntSet(file,"Password",gPlayerInfo[playerid][PLAYER_PASS]);
- dini_IntSet(file,"Level",gPlayerInfo[playerid][PLAYER_LEVEL]);
- dini_IntSet(file,"Wired",gPlayerInfo[playerid][PLAYER_WIRED]);
- dini_IntSet(file,"Jailed",gPlayerInfo[playerid][PLAYER_JAILED]);
- gPlayerInfo[playerid][PLAYER_NAME] = 0;
- gPlayerInfo[playerid][PLAYER_IP] = 0;
- gPlayerInfo[playerid][PLAYER_REGGED] = 0;
- gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
- gPlayerInfo[playerid][PLAYER_PASS] = 0;
- gPlayerInfo[playerid][PLAYER_LEVEL] = 0;
- gPlayerInfo[playerid][PLAYER_WIRED] = 0;
- gPlayerInfo[playerid][PLAYER_JAILED] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerPrivmsg(playerid, recieverid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(register, 8, cmdtext);
- dcmd(login, 5, cmdtext);
- dcmd(password, 8, cmdtext);
- dcmd(akill, 5, cmdtext);
- return 0;
- }
- dcmd_register(playerid, params[])
- {
- if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
- return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You have already registered!");
- else if(!params[0])
- return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /register [password]");
- else if(strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
- {
- new string[200];
- format(string, sizeof(string), "ERROR: Password must be between %d and $d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
- return SendClientMessage(playerid, COLOUR_ORANGE, string);
- }
- else
- {
- new password = num_hash(params);
- gPlayerInfo[playerid][PLAYER_PASS] = password;
- gPlayerInfo[playerid][PLAYER_REGGED] = 1;
- gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
- GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
- new string[256]; format(string, sizeof(string), "You have successfully registered your account with the password \'%s\'. You have been automatically logged in.", params);
- return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
- }
- return 0;
- }
- dcmd_login(playerid, params[])
- {
- if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
- return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
- else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 1)
- return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-in.");
- else if(!params[0])
- return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /login [password]");
- else
- {
- new password = num_hash(params);
- if(gPlayerInfo[playerid][PLAYER_PASS] == password)
- {
- gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
- GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
- return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged in to your account.");
- }
- else
- return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
- }
- return 0;
- }
- dcmd_password(playerid, params[])
- {
- if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
- return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
- else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
- return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must be logged-in to do that! Use /login [password] to login.");
- else
- {
- new tmp[30],
- tmp2[30],
- index;
- tmp = strtok(params, index);
- if(!strlen(tmp))
- return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
- tmp2 = strtok(params, index);
- if(!strlen(tmp2))
- return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
- new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2);
- if(gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
- {
- if(oldpassword == newpassword)
- return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Your old password can not be the same as your new password.");
- else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
- {
- new string[100]; format(string, sizeof(string), "ERROR: Your new password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
- return SendClientMessage(playerid, COLOUR_ORANGE, string);
- }
- gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
- new string[256]; format(string, sizeof(string), "You have successfully changed your password from \'%s\' to \'%s\'.", tmp, tmp2);
- return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
- }
- else
- return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
- }
- return 0;
- }
- dcmd_akill(playerid, params[])
- {
- if(gPlayerInfo[playerid][PLAYER_LEVEL] < gCommands[AKILL])
- {
- new string[100];
- format(string, sizeof(string), "You must be administrator level %d to use that command!", gCommands[AKILL]);
- return SendClientMessage(playerid, COLOUR_ORANGE, string);
- }
- else if(!strlen(params))
- return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /akill [id | name]");
- else
- {
- new id = (isNumeric(params)) ? strval(params) : GetPlayerId(params);
- if(IsPlayerConnected(id) && id != playerid)
- {
- SetPlayerHealth(id, 0.0);
- new string[150];
- format(string, sizeof(string), "You have been admin-killed by administrator \'%s\'.", gPlayerInfo[playerid][PLAYER_NAME]);
- SendClientMessage(id, COLOUR_ORANGE, string);
- format(string, sizeof(string), "You have successfully admin-killed player \'%s\'.", gPlayerInfo[id][PLAYER_NAME]);
- return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
- }
- else
- return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You can not admin-kill yourself or a disconnected player.");
- }
- }
- public OnPlayerInfoChange(playerid)
- {
- return 1;
- }
- 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 OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement