Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- _____ _____
- |_ _| | __ \
- | | __ _ ___ ___ _ __ | | \/_ _ _ __
- | |/ _` / __|/ _ \ '__| | | __| | | | '_ \
- | | (_| \__ \ __/ | | |_\ \ |_| | | | |
- \_/\__,_|___/\___|_| \____/\__,_|_| |_|
- Filterscript made by Boar.
- */
- #define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <foreach>
- #define TASER_EFFECT_TIME 5000 // The time during which the hit player is under the effect of the taser.
- #define TASER_GIVING_TIME 3000 // The time after which the taser will be given again.
- #define TASER_WEAPON WEAPON_SILENCED // The weapon which will work as a taser.
- #define TASER_WEAPON_SLOT 2 // The slot of the chosen weapon.
- #define TASER_WEAPON_OBJECT 347 // The ID of the object of the chosen weapon.
- new bool:taser[MAX_PLAYERS];
- new GiveTaserAgainTimer[MAX_PLAYERS];
- new lastWeapon[MAX_PLAYERS];
- public OnPlayerConnect(playerid)
- {
- taser[playerid] = false;
- GiveTaserAgainTimer[playerid] = 0;
- lastWeapon[playerid] = 0;
- // Preload the animation libraries used.
- ApplyAnimation(playerid, "SWORD", "null", 0.0, 0, 0, 0, 0, 0);
- ApplyAnimation(playerid, "CRACK", "null", 0.0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- taser[playerid] = false;
- GiveTaserAgainTimer[playerid] = 0;
- lastWeapon[playerid] = 0;
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- new w = GetPlayerWeapon(playerid);
- if (w != lastWeapon[playerid]) OnPlayerChangeWeapon(playerid, w, lastWeapon[playerid]);
- lastWeapon[playerid] = w;
- return 1;
- }
- forward OnPlayerChangeWeapon(playerid, newWeap, oldWeap);
- public OnPlayerChangeWeapon(playerid, newWeap, oldWeap)
- {
- if (IsPlayerAttachedObjectSlotUsed(playerid, 0) && taser[playerid]) SetPlayerArmedWeapon(playerid, 0);
- return 1;
- }
- public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
- {
- if (weaponid == TASER_WEAPON)
- {
- if (taser[issuerid])
- {
- new Float:health;
- GetPlayerHealth(playerid, health);
- SetPlayerHealth(playerid, health+amount);
- }
- }
- return 1;
- }
- public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
- {
- if (weaponid == TASER_WEAPON)
- {
- if (taser[playerid])
- {
- GiveTaserAgainTimer[playerid] = SetTimerEx("GiveTaserAgain", TASER_GIVING_TIME, 0, "i", playerid);
- ApplyAnimation(playerid, "SWORD", "sword_block", 50.0, 0, 1, 0, 1, 1, 1);
- SetPlayerAttachedObject(playerid, 0, TASER_WEAPON_OBJECT, 6);
- SetPlayerArmedWeapon(playerid, 0);
- if (hittype == BULLET_HIT_TYPE_PLAYER) {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(hitid, x, y, z);
- foreach(Player, i) if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z)) PlayAudioStreamForPlayer(i, "https://a.clyp.it/b0w3dcsr.mp3", x, y, z, 30.0, 1);
- ApplyAnimation(hitid, "CRACK", "crckdeth2", 4.1, 0, 1, 1, 1, TASER_EFFECT_TIME, 1);
- SetPlayerDrunkLevel(hitid, 5000);
- SetTimerEx("EndTaserEffect", TASER_EFFECT_TIME, 0, "i", hitid);
- }
- }
- }
- return 1;
- }
- forward EndTaserEffect(playerid);
- public EndTaserEffect(playerid)
- {
- new skin = GetPlayerSkin(playerid);
- SetPlayerSkin(playerid, skin);
- ClearAnimations(playerid, 1);
- SetPlayerDrunkLevel(playerid, 0);
- return 1;
- }
- forward GiveTaserAgain(playerid);
- public GiveTaserAgain(playerid)
- {
- RemovePlayerAttachedObject(playerid, 0);
- GivePlayerWeapon(playerid, TASER_WEAPON, 1);
- new skin = GetPlayerSkin(playerid);
- SetPlayerSkin(playerid, skin);
- ClearAnimations(playerid, 1);
- return 1;
- }
- CMD:taser(playerid, params[])
- {
- new weapon, ammo;
- GetPlayerWeaponData(playerid, TASER_WEAPON_SLOT, weapon, ammo);
- GivePlayerWeapon(playerid, weapon, -ammo);
- if (taser[playerid])
- {
- taser[playerid] = false;
- if (GiveTaserAgainTimer[playerid]) KillTimer(GiveTaserAgainTimer[playerid]);
- if (IsPlayerAttachedObjectSlotUsed(playerid, 0)) {
- new skin = GetPlayerSkin(playerid);
- SetPlayerSkin(playerid, skin);
- ClearAnimations(playerid, 1);
- RemovePlayerAttachedObject(playerid, 0);
- }
- }
- else
- {
- taser[playerid] = true;
- GivePlayerWeapon(playerid, TASER_WEAPON, 1);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement