Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////////////////////////////////////
- ///////// FS - Taser - by TiNCH010 //////////////////////
- //////// www.forum.sa-mp.com ////////////////////////////
- /////////////////////////////////////////////////////////
- #define FILTERSCRIPT
- #include <a_samp>
- #pragma tabsize 0 // We avoid the warning 'loose identiation'.
- //|________________ Configuration ________________|
- #define Taser_Time 5000 // Number of milliseconds that lasts the paralyzation of the taser, change if desired.
- #define WEAPON 23 // Weapon ID that we are gonna use.
- #define R_SOUND 50.0 // The radius of the sound of the taser that will sound.
- #define WHITE -1 // White colour by default.
- #define YELLOW 0xFFFF00AA // Yellow colour.
- // |______________________________________________|
- new ContinueTaser[MAX_PLAYERS];
- forward GetClosestPlayer(p1);
- forward Float:GetDistanceBetweenPlayers(p1,p2);
- main()
- {
- }
- public OnPlayerConnect(playerid)
- {
- ContinueTaser[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- ContinueTaser[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- ContinueTaser[playerid] = 0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- ContinueTaser[playerid] = 0;
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys & KEY_FIRE) // If you push left click you're gonna play the taser.
- {
- new victimid = GetClosestPlayer(playerid);
- if(IsPlayerConnected(victimid))
- {
- if(ContinueTaser[playerid] == 1)
- {
- TogglePlayerControllable(playerid, 0);
- TogglePlayerControllable(victimid, 0);
- ContinueTaser[playerid] = 1;
- SendClientMessage(playerid, WHITE, "You used your {FFCC33}taser{FFFFFF} again!");
- SendClientMessage(playerid, YELLOW, "You can continue to shoot the taser and the victim will return to receive electricity.");
- SendClientMessage(victimid, WHITE, "You have received again a {FFCC33}taser{FFFFFF} dart!");
- ApplyAnimation(victimid,"PED","KO_skid_front",4.1,0,1,1,1,0);
- ApplyAnimation(victimid,"PED","KO_skid_front",4.1,0,1,1,1,0);
- SetTimerEx("TaserTime", Taser_Time, 0, "d", victimid);
- SetTimerEx("StopTaser", Taser_Time, 0, "d", playerid);
- }
- }
- return 1;
- }
- return 1;
- }
- public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
- {
- if(issuerid != INVALID_PLAYER_ID)
- {
- new Float:Chaleco, Float:Vida; GetPlayerArmour(playerid, Chaleco); GetPlayerHealth(playerid, Vida);
- if(weaponid == WEAPON)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- return 1;
- }
- GameTextForPlayer(playerid, "~r~paralyzed by the taser again", Taser_Time, 3);
- TogglePlayerControllable(playerid, 0);
- TogglePlayerControllable(issuerid, 0);
- ContinueTaser[issuerid] = 1;
- new Float:Audio_X, Float:Audio_Y, Float:Audio_Z;
- GetPlayerPos(playerid, Audio_X, Audio_Y, Audio_Z);
- StopAudioStreamForPlayer(playerid);
- PlayAudioStreamForPlayer(playerid, "http://k004.kiwi6.com/hotlink/9s19772cbe/taser_sound.mp3", Audio_X, Audio_Y, Audio_Z, R_SOUND, 1);
- SendClientMessage(issuerid, WHITE, "You used your {FFCC33}taser{FFFFFF}!");
- SendClientMessage(issuerid, YELLOW, "You can continue to shoot the taser and the victim will return to receive electricity.");
- SendClientMessage(playerid, WHITE, "You have received {FFCC33}taser{FFFFFF} dart!");
- ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);
- ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);
- SetTimerEx("TaserTime", Taser_Time, 0, "d", playerid);
- SetTimerEx("StopTaser", Taser_Time, 0, "d", issuerid);
- }
- }
- return 1;
- }
- forward TaserTime(playerid);
- public TaserTime(playerid)
- {
- TogglePlayerControllable(playerid, 1);
- ClearAnimations(playerid);
- return 1;
- }
- forward StopTaser(playerid);
- public StopTaser(playerid)
- {
- TogglePlayerControllable(playerid, 1);
- ClearAnimations(playerid);
- ContinueTaser[playerid] = 0;
- return 1;
- }
- public GetClosestPlayer(p1)
- {
- new x,Float:dis,Float:dis2,player2;
- player2 = -1;
- dis = 99999.99;
- for (x=0;x<MAX_PLAYERS;x++)
- {
- if(IsPlayerConnected(x))
- {
- if(x != p1)
- {
- dis2 = GetDistanceBetweenPlayers(x,p1);
- if(dis2 < dis && dis2 != -1.00)
- {
- dis = dis2;
- player2 = x;
- }
- }
- }
- }
- return player2;
- }
- 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));
- }
- // Keep the credits!
- // © 2012
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement