Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define FILTERSCRIPT
- #if defined FILTERSCRIPT
- #define RED 0xFF0000FF
- new Rocket[MAX_PLAYERS];
- new RocketFiring[MAX_PLAYERS];
- new IsInRustler[MAX_PLAYERS];
- stock 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;
- }
- stock Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
- {
- new Float:a;
- GetPlayerPos(playerid, x, y, a);
- if (IsPlayerInAnyVehicle(playerid))
- GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
- else
- GetPlayerFacingAngle(playerid, a);
- x += (distance * floatsin(-a, degrees));
- y += (distance * floatcos(-a, degrees));
- return a;
- }
- public OnFilterScriptInit()
- {
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n--------------------------------------");
- print("Fire rockets with a rustler ");
- print(" by SpiderPork ");
- print("--------------------------------------\n");
- }
- #endif
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/fire", cmdtext, true, 10) == 0)
- {
- if(RocketFiring[playerid] == 0)
- {
- if(IsInRustler[playerid] == 1)
- {
- new Float:X, Float:Y, Float:Z, Float:Angle, Float:X2, Float:Y2, vehicleid;
- vehicleid = GetPlayerVehicleID(playerid);
- GetPlayerPos(playerid, X, Y, Z);
- GetVehicleZAngle(vehicleid, Angle);
- Rocket[playerid] = CreateObject(3790, X, Y, Z-3.0, 0, 0, Angle+90);
- GetXYInFrontOfPlayer(playerid, X2, Y2, 100.0);
- MoveObject(Rocket[playerid], X2, Y2, Z, 100.0);
- RocketFiring[playerid] = 1;
- }
- }
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid)
- {
- if(GetVehicleModel(vehicleid) == 476)
- {
- IsInRustler[playerid] = 1;
- }
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- if(GetVehicleModel(vehicleid) == 476)
- {
- IsInRustler[playerid] = 0;
- }
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- new playerid;
- if(objectid == Rocket[playerid])
- {
- new Float:X, Float:Y, Float:Z;
- GetObjectPos(Rocket[playerid], X, Y, Z);
- DestroyObject(Rocket[playerid]);
- CreateExplosion(X, Y, Z, 6, 10.0);
- RocketFiring[playerid] = 0;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- RocketFiring[playerid] = 0;
- IsInRustler[playerid] = 0;
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys == KEY_FIRE)
- {
- if(RocketFiring[playerid] == 0)
- {
- if(IsInRustler[playerid] == 1)
- {
- new Float:X, Float:Y, Float:Z, Float:Angle, Float:X2, Float:Y2, vehicleid;
- vehicleid = GetPlayerVehicleID(playerid);
- GetPlayerPos(playerid, X, Y, Z);
- GetVehicleZAngle(vehicleid, Angle);
- Rocket[playerid] = CreateObject(3790, X, Y, Z-3.0, 0, 0, Angle+90);
- GetXYInFrontOfPlayer(playerid, X2, Y2, 100.0);
- MoveObject(Rocket[playerid], X2, Y2, Z, 100.0);
- RocketFiring[playerid] = 1;
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment