Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <CopTools>
- //________Colors_________
- #define GREEN 0x21DD00FF
- //________Dialogs________
- #define POLICE 8000
- #define POLICE2 8001
- #define POLICE3 8002
- //________Random Shit_________
- new Tazer[MAX_PLAYERS];
- new CantUseTazer[MAX_PLAYERS];
- forward Float:GetDistanceBetweenPlayers(p1,p2);
- forward TazerFade(playerid);
- forward TazerOn(playerid);
- new Float:x, Float:y, Float:z;
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Police Panel by [SWE]Alexzz");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" Police Panel by [SWE]Alexzz unloaded");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- Tazer[playerid] = 0;
- CantUseTazer[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- Tazer[playerid] = 0;
- CantUseTazer[playerid] = 0;
- return 1;
- }
- public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
- {
- if(Tazer[playerid] == 1 && GetPlayerWeapon(playerid) == 23)
- {
- new Float:health;
- GetPlayerHealth(damagedid,health);
- if(CantUseTazer[playerid] == 1)
- {
- SendClientMessage(playerid, GREEN, "Please wait before using your tazer again!");
- return 1;
- }
- GetPlayerPos(damagedid, x, y, z);
- TogglePlayerControllable(damagedid, 0);
- SetPlayerHealth(damagedid, health - 2);
- SendClientMessage(damagedid, GREEN, "You have been tazed for 20 seconds");
- SetTimerEx("TazerFade", 20000, false, "i", damagedid);
- SetTimerEx("TazerOn", 9000, false, "i", playerid);
- CantUseTazer[playerid] = 1;
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys & KEY_FIRE)
- {
- if(Tazer[playerid] == 2)
- {
- new tazervictim = GetClosestPlayer(playerid);
- new Float:health;
- if(CantUseTazer[playerid] == 1)
- {
- SendClientMessage(playerid, GREEN, "Please wait before using your tazer again!");
- return 1;
- }
- if(GetDistanceBetweenPlayers(playerid,tazervictim) < 2)
- {
- ApplyAnimation(playerid,"KNIFE","knife_3",4.1,0,1,1,0,0,1);
- TogglePlayerControllable(tazervictim, 0);
- ApplyAnimation(tazervictim, "PED","FLOOR_hit_f", 4.0, 1, 0, 0, 0, 0);
- GetPlayerHealth(tazervictim, health);
- SetPlayerHealth(tazervictim, health - 2);
- SendClientMessage(tazervictim, GREEN, "You have been tazed for 20 seconds");
- SetTimerEx("TazerFade", 20000, false, "i", tazervictim);
- SetTimerEx("TazerOn", 9000, false, "i", playerid);
- CantUseTazer[playerid] = 1;
- }
- }
- return 1;
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == POLICE)
- {
- if(response)
- {
- if(listitem == 0)
- {
- ShowPlayerDialog(playerid, POLICE2, DIALOG_STYLE_MSGBOX, "Riot Shield","Do you wish to put your riot shield on the back or on your arm?","Back","Arm");
- }
- if(listitem == 1)
- {
- GiveFlashLight(playerid);
- SendClientMessage(playerid, GREEN, "Flashlight has been attached");
- }
- if(listitem == 2)
- {
- ShowPlayerDialog(playerid, POLICE3, DIALOG_STYLE_MSGBOX, "Tazer","Do you want a ranged or melee tazer?","Ranged","Melee");
- }
- if(listitem == 3)
- {
- RemoveItems(playerid);
- SendClientMessage(playerid, GREEN, "All items have been deattached");
- Tazer[playerid] = 0;
- }
- }
- if(dialogid == POLICE3)
- {
- if(response)
- {
- SendClientMessage(playerid, GREEN, "Ranged tazer has been given to you!");
- GivePlayerWeapon(playerid,23,10);
- Tazer[playerid] = 1;
- }
- if(!response)
- {
- GiveTazer(playerid);
- SendClientMessage(playerid, GREEN, "Melee tazer has been given to you!");
- Tazer[playerid] = 2;
- }
- }
- if(dialogid == POLICE2)
- {
- if(response)
- {
- PutRiotShieldOnBack(playerid);
- SendClientMessage(playerid, GREEN, "Riot Shield have been attached to your back!");
- }
- if(!response)
- {
- PutRiotShieldOnArm(playerid);
- SendClientMessage(playerid, GREEN, "Riot Shield have been attached to your arm!");
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- CMD:police(playerid, params[])
- {
- if(IsPlayerConnected(playerid))
- {
- if(GetPlayerSkin(playerid) == 280 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 282 || GetPlayerSkin(playerid) == 283 || GetPlayerSkin(playerid) == 288 || GetPlayerSkin(playerid) == 284)
- {
- ShowPlayerDialog(playerid, POLICE, DIALOG_STYLE_LIST, "Police Panel","Riot Shield\nFlashlight\nTazer\nRemove Items","Choose","Close");
- }
- else
- {
- SendClientMessage(playerid, GREEN, "You are not connected");
- }
- }
- else
- {
- SendClientMessage(playerid, GREEN, "You need to be a cop to use that command!");
- }
- return 1;
- }
- public TazerOn(playerid)
- {
- CantUseTazer[playerid] = 0;
- return 1;
- }
- public TazerFade(playerid)
- {
- new tazervictim = GetClosestPlayer(playerid);
- TogglePlayerControllable(tazervictim, 1);
- SendClientMessage(playerid, GREEN, "Tazer effect has been removed");
- return 1;
- }
- stock GetClosestPlayer(playerid)
- {
- new Float:cdist, targetid = -1;
- for(new i; i<MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i) && playerid != i && (targetid < 0 || cdist > GetDistanceBetweenPlayers(playerid, i)))
- {
- targetid = i;
- cdist = GetDistanceBetweenPlayers(playerid, i);
- }
- }
- return targetid;
- }
- public Float:GetDistanceBetweenPlayers(p1,p2)
- {
- new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
- if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
- {
- return -1.00;
- }
- GetPlayerPos(p1,x1,y1,z1);
- GetPlayerPos(p2,x2,y2,z2);
- return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement