Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Police Officer Job Filterscript made by eddy
- // Version 1.1
- #include <a_samp>
- #define COLOR_BLUE 0x0000BBAA
- #define COLOR_RED 0xFF0000AA
- #define COLOR_TRANSPARENT 0xFFFFFF00
- #define MAX_POLICE_OFFICERS 3
- #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]))))) return 1
- enum PlayerInfo
- {
- PoliceOfficer
- }
- new PlayerData[MAX_PLAYERS][PlayerInfo];
- new PoliceOfficerLimit;
- new PlayerScore;
- new SpawnSkin;
- new SpawnColor;
- public OnPlayerConnect(playerid)
- {
- PlayerData[playerid][PoliceOfficer] = 0;
- SendClientMessage(playerid, COLOR_BLUE, "Type /police to become a Police Officer! (Your score must be 15 or higher)");
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- if(PlayerData[playerid][PoliceOfficer] == 1)
- {
- new string[256];
- new PlayerName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
- format(string, sizeof(string), "%s got demoted from his/her Police Officer Job! (Left Game)", PlayerName);
- PlayerData[playerid][PoliceOfficer] = 0;
- PoliceOfficerLimit--;
- return 1;
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SpawnSkin = GetPlayerSkin(playerid);
- SpawnColor = GetPlayerColor(playerid);
- PlayerData[playerid][PoliceOfficer] = 0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(PlayerData[playerid][PoliceOfficer] == 1)
- {
- DemotePlayerFromPoliceOfficer(playerid);
- return 1;
- }
- return 1;
- }
- dcmd_police(playerid, params[])
- {
- #pragma unused params
- PlayerScore = GetPlayerScore(playerid);
- if(PlayerData[playerid][PoliceOfficer] == 1)
- {
- SendClientMessage(playerid, COLOR_RED, "You are already a Police Officer");
- return 1;
- }
- if(PoliceOfficerLimit >= MAX_POLICE_OFFICERS)
- {
- SendClientMessage(playerid, COLOR_RED, "The limit of Police Officers has been reached");
- return 1;
- }
- if(PlayerScore >= 15)
- {
- PromotePlayerToPoliceOfficer(playerid);
- return 1;
- }
- else return SendClientMessage(playerid, COLOR_RED, "Your score must be 15 or higher before you can become a Police Officer");
- }
- dcmd_quitpolice(playerid, params[])
- {
- #pragma unused params
- if(PlayerData[playerid][PoliceOfficer] == 1)
- {
- QuitPoliceOfficerJob(playerid);
- return 1;
- }
- else return SendClientMessage(playerid, COLOR_RED, "You are not a Police Officer");
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(police, 6, cmdtext);
- dcmd(quitpolice, 10, cmdtext);
- return 0;
- }
- forward PromotePlayerToPoliceOfficer(playerid);
- public PromotePlayerToPoliceOfficer(playerid)
- {
- new string[256];
- new string2[256];
- new PlayerName[MAX_PLAYER_NAME];
- PlayerScore = GetPlayerScore(playerid);
- GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
- SetPlayerSkin(playerid, 285);
- GivePlayerWeapon(playerid, 29, 1000);
- GivePlayerWeapon(playerid, 31, 1000);
- GivePlayerWeapon(playerid, 35, 20);
- SetPlayerHealth(playerid, 500);
- SetPlayerArmour(playerid, 500);
- SetPlayerColor(playerid, COLOR_TRANSPARENT);
- format(string, sizeof(string), "%s became a Police Officer! Watch out, he/she could be everywhere... Ready to kill you...", PlayerName);
- format(string2, sizeof(string2), "Type /quitjob to quit your Job as a Police Officer");
- SendClientMessageToAll(COLOR_BLUE, string);
- SendClientMessage(playerid, COLOR_BLUE, string2);
- SetPlayerScore(playerid, PlayerScore -15);
- PlayerData[playerid][PoliceOfficer] = 1;
- PoliceOfficerLimit++;
- return 1;
- }
- forward DemotePlayerFromPoliceOfficer(playerid);
- public DemotePlayerFromPoliceOfficer(playerid)
- {
- new string[256];
- new PlayerName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
- SetPlayerHealth(playerid, 100);
- SetPlayerArmour(playerid, 0);
- SetPlayerSkin(playerid, SpawnSkin);
- SetPlayerColor(playerid, SpawnColor);
- format(string, sizeof(string), "%s got demoted from his/her Police Officer Job! (Died)", PlayerName);
- SendClientMessageToAll(COLOR_BLUE, string);
- PlayerData[playerid][PoliceOfficer] = 0;
- PoliceOfficerLimit--;
- return 1;
- }
- forward QuitPoliceOfficerJob(playerid);
- public QuitPoliceOfficerJob(playerid)
- {
- new string[256];
- new PlayerName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
- SetPlayerHealth(playerid, 100);
- SetPlayerArmour(playerid, 0);
- SetPlayerSkin(playerid, SpawnSkin);
- SetPlayerColor(playerid, SpawnColor);
- format(string, sizeof(string), "%s is not a Police Officer anymore! (Left Job)", PlayerName);
- SendClientMessageToAll(COLOR_BLUE, string);
- PlayerData[playerid][PoliceOfficer] = 0;
- PoliceOfficerLimit--;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment