Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- STINGER SCRIPT BY GROVE!
- GO TO LINE 40 FOR THE OnPlayerCrossStinger CALLBACK AND HAVE FUN :P
- (c)Jay 2008
- To add a Stinger, Usage:
- CreateStinger(stingerid,Float:x,Float:y,Float:z);
- */
- #include <a_samp>
- #define MAX_STINGER 2 //just increase it if you add more than 20 stingers.
- #define white 0xFFFFFFAA
- new MAXPLAYERS;
- forward PlayerToPoint(Float:radi,playerid,Float:x,Float:y,Float:z);
- forward stinger();
- forward StopVehicle(playerid);
- new sting[MAX_STINGER], Float:Rot[4][MAX_STINGER];
- public OnFilterScriptInit()
- {
- //STINGERS:
- CreateStinger(0,332.2, 2503.8, 15.8);
- CreateStinger(1,332.2+15, 2503.8+15, 15.8);
- //--
- print("Stinger script 0.1 by Grove Loaded");
- SetTimer("stinger",40,1); //checks if the player is near a stinger
- MAXPLAYERS = GetMaxPlayers();
- }
- public OnFilterScriptExit()
- {
- for(new i = 0; i < MAX_STINGER; i++)
- {
- DestroyObject(sting[i]);
- }
- print("Stinger script 0.1 by Grove unloaded!");
- }
- stock CreateStinger(id,Float:X,Float:Y,Float:Z)
- {
- sting[id] = CreateObject(1593,X,Y,Z,0,0,0);
- GetObjectPos(sting[id],Rot[1][id],Rot[2][id],Rot[3][id]);
- return id;
- }
- OnPlayerCrossStinger(playerid,stingerid) //do what you like here :)
- {
- if(!IsPlayerInAnyVehicle(playerid)) return false;
- PlayerPlaySound(playerid,32000,0,0,0); //sound for popping tyres NOT SUPPORTED IN SA:MP
- SetVehicleToRespawn((GetPlayerVehicleID(playerid)));
- GameTextForPlayer(playerid,"~r~Pop goes the weasel!",5000,5);
- //Perhaps here, you could freeze the vehicle, and remove the player from it!
- #pragma unused stingerid
- /* new string[256];
- format(string,256,"DEBUG: stinger id: %d.",stingerid);
- SendClientMessage(playerid,white,string);
- */
- return true;
- }
- public stinger()
- {
- for(new i = 0; i < MAX_STINGER; i++)
- {
- for(new pi = 0; pi <MAXPLAYERS; pi++)
- {
- if(PlayerToPoint(1.2,pi,Rot[1][i],Rot[2][i],Rot[3][i]))
- {
- OnPlayerCrossStinger(pi,i);
- }
- }
- }
- }
- public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
- {
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- tempposx = (oldposx -x);
- tempposy = (oldposy -y);
- tempposz = (oldposz -z);
- if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment