Advertisement
Guest User

Trooper

a guest
Jul 7th, 2009
1,839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.99 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. /*
  4. (c) Trooper 2009
  5. This is the Filterscript "Maverick Gunner",originaly written by Trooper.
  6. Please don`t miss my credits, i put a lot of work in it.
  7. If you would do your own script, you would dislike this kind of people editing and sharing scripts like one of their own !
  8.  
  9. Information:
  10. *You need to get in a Police Chopper
  11. *You need a skin from Governmental Services (Skin ID 280 to 288)
  12. *Use the arrows (to aim X & Y)
  13. *Use the keys you would use for an hydra to start (for example) to in-/decrease height
  14.  
  15. */
  16.  
  17.  
  18.  
  19. //#################### Server Settings ##############################
  20.  
  21. // ---------------- Section Performance -----------------------------
  22. new camtime = 100; //the time for refreshing the camera of the gunner
  23. new rockettime = 200; //the time to check if the rocket is at the aiming spot
  24. new keytime = 100; //the time to lookup pressed keys for gunners
  25.  
  26. // ---------------- Section Testing ---------------------------------
  27. new testing = 0; //0 = off, 1 = on || testmodus meaning teleporting to an existing chopter + getting police skin to test this script (type /testing ingame)
  28.  
  29. // --------------- Section General Options --------------------------
  30. new explosiontype = 6; //type of explosion, see wiki
  31. new Float:explosionradius = 10.0; //radius of explosion, see wiki
  32. new Float:rocketspeed = 56.0; //speed of the rocket to move
  33.  
  34. /* ---------------- Some Informations -------------------------------
  35. 1.Look at line 79/80 to change the Model of your raket (to see what model it is, use google or read the commentary at their back)
  36. 2.I used a lot of variables, i dont know anymore exactly, for what they are used ! You can delete unused Variables if you want to !
  37. 3.If your not good in scripting, just edit the values above (!!!)
  38. 4.If the message appears too often, that the Launcher is not ready, use /reload
  39. 5.Feel free to edit, but never miss out my credits in script & console-printout
  40. */
  41. //#################### End of Settings ##############################
  42.  
  43.  
  44. #define COLOR_RED 0xAA3333AA
  45. #define COLOR_GREY 0xAFAFAFAA
  46. #define COLOR_GREEN 0x33AA33AA
  47. #define COLOR_RED 0xAA3333AA
  48. #define COLOR_YELLOW 0xFFFF00AA
  49. #define COLOR_WHITE 0xFFFFFFFF
  50. forward gunnertimer(playerid);
  51. forward IsACop(killerid);
  52. new gunner[MAX_PLAYERS];
  53. new driver[MAX_PLAYERS];
  54. forward checkraket(playerid);
  55. forward funckeys(playerid);
  56. new string[128];
  57. new Missile;
  58. new Float:vx,Float:vy,Float:vz;
  59. new checkrakettimer[MAX_PLAYERS];
  60. new keychecktimer[MAX_PLAYERS];
  61. new heightz[MAX_PLAYERS];
  62. new rakready = 1;
  63. new aimplusx[MAX_PLAYERS];
  64. new aimplusy[MAX_PLAYERS];
  65. new vehicle[MAX_VEHICLES] = 0;
  66. new Float:rakshootatx[MAX_PLAYERS],Float:rakshootaty[MAX_PLAYERS],Float:rakshootatz[MAX_PLAYERS];
  67.  
  68.  
  69.  
  70. public OnFilterScriptInit()
  71. {
  72.     if(testing == 1)
  73.     {
  74.         AddStaticVehicle(497,2064.6187,2643.2661,10.6719,0,0,0);
  75.     }
  76.     print("\n--------------------------------------");
  77.     print(" Police Maverick Addon - Gunner Filter loaded ! (c) Trooper 2009");
  78.     print("--------------------------------------\n");
  79.     //Missile = CreateObject(3786,-2299.105224,1957.136596,-5000.107460,0.000000,0.000000,0.000000); //Rocket - Model (bad in cause of rotation)
  80.     Missile = CreateObject(354,-2299.105224,1957.136596,-5000.107460,0.000000,0.000000,0.000000); //Glare Missile (like area51) - Model
  81.     return 1;
  82. }
  83.  
  84. public OnFilterScriptExit()
  85. {
  86.     DestroyObject(Missile);
  87.     return 1;
  88. }
  89.  
  90. public OnPlayerConnect(playerid)
  91. {
  92.     gunner[playerid] = 0;
  93.     driver[playerid] = 0;
  94.     return 1;
  95. }
  96.  
  97. public OnPlayerDisconnect(playerid, reason)
  98. {
  99.     vehicle[GetPlayerVehicleID(playerid)] = 0;
  100.     return 1;
  101. }
  102.  
  103. public OnPlayerDeath(playerid, killerid, reason)
  104. {
  105.     if(driver[playerid] == 1)
  106.     {
  107.         for(new i; i<MAX_PLAYERS; i++)
  108.         {
  109.             if(IsPlayerConnected(i) && IsACop(i) == 1 && GetPlayerVehicleID(i) == 497 && gunner[i] == 1)
  110.             {
  111.                 SetPlayerHealth(i,0);
  112.                 DisablePlayerCheckpoint(i);
  113.             }
  114.         }
  115.     }
  116.     return 1;
  117. }
  118.  
  119. public OnPlayerStateChange(playerid, newstate, oldstate)
  120. {
  121.     if(newstate== PLAYER_STATE_DRIVER && IsACop(playerid) && GetVehicleModel(GetPlayerVehicleID(playerid)) == 497)
  122.     {
  123.         driver[playerid] = 1;
  124.     }
  125.     if(newstate == 3 && IsACop(playerid) && GetVehicleModel(GetPlayerVehicleID(playerid)) == 497 && oldstate != newstate)
  126.     {
  127.         if(vehicle[GetPlayerVehicleID(playerid)] == 0)
  128.         {
  129.             vehicle[GetPlayerVehicleID(playerid)] = 1;
  130.             gunner[playerid] = 1;
  131.             heightz[playerid] = 0;
  132.             aimplusx[playerid] = 0;
  133.             aimplusy[playerid] = 0;
  134.             SetTimerEx("gunnertimer",1000,0,"i",playerid);
  135.             keychecktimer[playerid] = SetTimerEx("funckeys",1000,0,"i",playerid);
  136.         }
  137.     }
  138.     return 1;
  139. }
  140.  
  141.  
  142. public OnPlayerExitVehicle(playerid, vehicleid)
  143. {
  144.     KillTimer(keychecktimer[playerid]);
  145.     RemovePlayerMapIcon(playerid,18);
  146.     driver[playerid] = 0;
  147.     if(IsACop(playerid) && gunner[playerid] == 1)
  148.     {
  149.         gunner[playerid] = 0;
  150.         SetCameraBehindPlayer(playerid);
  151.     }
  152.     DisablePlayerCheckpoint(playerid);
  153.    
  154.     vehicle[vehicleid] = 0;
  155.     return 1;
  156. }
  157.  
  158. public IsACop(killerid)
  159. {
  160.     if(GetPlayerSkin(killerid) == 280 || GetPlayerSkin(killerid) == 281 || GetPlayerSkin(killerid) == 282 || GetPlayerSkin(killerid) == 283 || GetPlayerSkin(killerid) == 284 || GetPlayerSkin(killerid) == 285 || GetPlayerSkin(killerid) == 286 || GetPlayerSkin(killerid) == 287 || GetPlayerSkin(killerid) == 288)
  161.     {
  162.         return 1;
  163.     }
  164.     else
  165.     {
  166.         return 0;
  167.     }
  168. }
  169.  
  170. public gunnertimer(playerid)
  171. {
  172.     if(gunner[playerid] == 1)
  173.     {
  174.         GetPlayerPos(playerid,vx,vy,vz);
  175.         SetPlayerCameraPos(playerid, vx, vy, vz-1.5);
  176.         SetPlayerCameraLookAt(playerid, vx + aimplusx[playerid], vy + aimplusy[playerid], vz - 40);
  177.  
  178.         DisablePlayerCheckpoint(playerid);
  179.         SetPlayerCheckpoint(playerid,vx + aimplusx[playerid],vy + aimplusy[playerid],heightz[playerid],15);
  180.        
  181.         SetTimerEx("gunnertimer",camtime,0,"i",playerid);
  182.     }
  183.     else
  184.     {
  185.         DisablePlayerCheckpoint(playerid);
  186.         SetCameraBehindPlayer(playerid);
  187.     }
  188. }
  189.  
  190. public funckeys(playerid)
  191. {
  192.     new keys, updown, leftright;
  193.     GetPlayerKeys(playerid,keys,updown,leftright);
  194.     if((keys == KEY_ANALOG_UP) && gunner[playerid] == 1)
  195.     {
  196.         heightz[playerid] = heightz[playerid] + 1;
  197.         format(string, sizeof(string), "Height set on %i", heightz[playerid] );
  198.         GameTextForPlayer(playerid,string,1000,3);
  199.     }
  200.     if((keys == KEY_ANALOG_DOWN) && gunner[playerid] == 1)
  201.     {
  202.         heightz[playerid] = heightz[playerid] - 1;
  203.         format(string, sizeof(string), "Height set on %i", heightz[playerid] );
  204.         GameTextForPlayer(playerid,string,1000,3);
  205.     }
  206.     if((keys == KEY_FIRE) && gunner[playerid] == 1)
  207.     {
  208.         if(rakready == 1)
  209.         {
  210.             rakready = 0;
  211.             GameTextForPlayer(playerid,"Rocket launched",2000,3);
  212.             new Float:gunx,Float:guny,Float:gunz;
  213.             GetPlayerPos(playerid,gunx,guny,gunz);
  214.             SetPlayerMapIcon(playerid,18,gunx,guny,gunz,56,COLOR_RED);
  215.             SetObjectPos(Missile,gunx,guny,gunz);
  216.             MoveObject(Missile,vx + aimplusx[playerid],vy + aimplusy[playerid],heightz[playerid],rocketspeed);
  217.             rakshootatx[playerid] = vx + aimplusx[playerid];
  218.             rakshootaty[playerid] = vy + aimplusy[playerid];
  219.             rakshootatz[playerid] = heightz[playerid];
  220.             checkrakettimer[playerid] = SetTimerEx("checkraket",rockettime,0,"i",playerid);
  221.             return 0;
  222.         }
  223.         else
  224.         {
  225.             GameTextForPlayer(playerid,"Launcher not ready",1000,3);
  226.         }
  227.     }
  228.     if((leftright == KEY_LEFT) && gunner[playerid] == 1)
  229.     {
  230.         aimplusx[playerid] = aimplusx[playerid] - 5;
  231.     }
  232.     if((leftright == KEY_RIGHT) && gunner[playerid] == 1)
  233.     {
  234.         aimplusx[playerid] = aimplusx[playerid] + 5;
  235.     }
  236.     if((updown == KEY_UP) && gunner[playerid] == 1)
  237.     {
  238.         aimplusy[playerid] = aimplusy[playerid] + 5;
  239.     }
  240.     if((updown == KEY_DOWN) && gunner[playerid] == 1)
  241.     {
  242.         aimplusy[playerid] = aimplusy[playerid] - 5;
  243.     }
  244.     keychecktimer[playerid] = SetTimerEx("funckeys",keytime,0,"i",playerid);
  245.     return 1;
  246. }
  247.  
  248.  
  249. public checkraket(playerid)
  250. {
  251.     new Float:rakstatusx[MAX_PLAYERS],Float:rakstatusy[MAX_PLAYERS],Float:rakstatusz[MAX_PLAYERS];
  252.     GetObjectPos(Missile,rakstatusx[playerid],rakstatusy[playerid],rakstatusz[playerid]);
  253.     RemovePlayerMapIcon(playerid,18);
  254.     SetPlayerMapIcon(playerid,18,rakstatusx[playerid],rakstatusy[playerid],rakstatusz[playerid],56,COLOR_RED);
  255.  
  256.     if((rakstatusx[playerid] == rakshootatx[playerid]) && (rakstatusy[playerid] == rakshootaty[playerid]) && (rakstatusz[playerid] == rakshootatz[playerid]))
  257.     {
  258.         rakready = 1;
  259.         CreateExplosion(rakstatusx[playerid],rakstatusy[playerid],rakstatusz[playerid],explosiontype,explosionradius);
  260.         SetObjectPos(Missile,0,0,-1000);
  261.         RemovePlayerMapIcon(playerid,18);
  262.         keychecktimer[playerid] = SetTimerEx("funckeys",keytime,0,"i",playerid);
  263.         return 0;
  264.     }
  265.     else
  266.     {
  267.         checkrakettimer[playerid] = SetTimerEx("checkraket",rockettime,0,"i",playerid);
  268.     }
  269.     return 1;
  270. }
  271.  
  272. public OnPlayerCommandText(playerid, cmdtext[])
  273. {
  274.     if(strcmp("/testing", cmdtext, true, 8) == 0 && testing == 1)
  275.     {
  276.         SetPlayerSkin(playerid,281);
  277.         SetPlayerPos(playerid,2068.6187,2648.2661,13.6719);
  278.         return 1;
  279.     }
  280.     if(strcmp("/reload", cmdtext, true, 7) == 0)
  281.     {
  282.         rakready = 1;
  283.         return 1;
  284.     }
  285.     return 0;
  286. }
  287.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement