Advertisement
Guest User

Trani's GTA IV Grenade Mode Eng

a guest
Feb 25th, 2013
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.07 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #if defined FILTERSCRIPT
  4.  
  5. new grenade;
  6. new trangr[MAX_PLAYERS];
  7. new Float:ox, Float:oy, Float:oz;
  8. new timer1;
  9.  
  10. forward boom();
  11.  
  12. #endif
  13. public OnFilterScriptExit()
  14. {
  15. KillTimer(timer1);
  16. return 1;
  17. }
  18.  
  19. public OnPlayerConnect(playerid)
  20. {
  21. trangr[playerid] = 0;
  22. return 1;
  23. }
  24.  
  25. public OnPlayerDisconnect(playerid, reason)
  26. {
  27. trangr[playerid] = 0;
  28. return 1;
  29. }
  30.  
  31. public OnPlayerCommandText(playerid, cmdtext[])
  32. {
  33.     if (strcmp("/mg", cmdtext, true, 10) == 0)
  34.     {
  35.         if(trangr[playerid] == 0)
  36.         {
  37.             trangr[playerid] = 1;
  38.             SendClientMessage(playerid, 0x00FF00FF, "GTA IV Grenade Mode Activated");
  39.             ShowPlayerDialog(playerid, 2756, DIALOG_STYLE_MSGBOX, "How to use", "{ff0000}If you have a grenade, press Y (if any buttons do not pressed (only Y))", "Ok", "");
  40.             return 1;
  41.         }
  42.         else if(trangr[playerid] == 1)
  43.         {
  44.             trangr[playerid] = 0;
  45.             SendClientMessage(playerid, 0xFF0000FF, "GTA IV Grenade Mode Deactivated");
  46.             return 1;
  47.         }
  48.     }
  49.     return 0;
  50. }
  51. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  52. {
  53.     if(newkeys == KEY_YES)
  54.     {
  55.         if(IsPlayerInAnyVehicle(playerid))
  56.         {
  57.             if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  58.             {
  59.                 if(trangr[playerid] == 1)
  60.                 {
  61.                     new weapon,ammo;
  62.                     GetPlayerWeaponData(playerid, 8, weapon, ammo);
  63.                     if(weapon == 16)
  64.                     {
  65.                         if(ammo >= 1)
  66.                         {
  67.                             new Float:A, Float:x, Float:y, Float:z, veh;
  68.                             veh = GetPlayerVehicleID(playerid);
  69.                             GetVehicleZAngle(veh, A);
  70.                             if(A>=0 && A<45)
  71.                             {
  72.                                 GetPlayerPos(playerid, x, y, z);
  73.                                 grenade = CreateObject(342, x-1.4, y, z+0.8, 0, 90, 0, 0);
  74.                                 MoveObject(grenade, x-5.0, y, z-1.2, 7, 0, 0, 0);
  75.                                 SetPlayerAmmo(playerid, 16, ammo-1);
  76.                             }
  77.                             if(A>=45 && A<90)
  78.                             {
  79.                                 GetPlayerPos(playerid, x, y, z);
  80.                                 grenade = CreateObject(342, x-1.4, y-1.4, z+0.8, 0, 90, 0, 0);
  81.                                 MoveObject(grenade, x-5.0, y-5.0, z-1.2, 7, 0, 0, 0);
  82.                                 SetPlayerAmmo(playerid, 16, ammo-1);
  83.                             }
  84.                             if(A>=90 && A<135)
  85.                             {
  86.                                 GetPlayerPos(playerid, x, y, z);
  87.                                 grenade = CreateObject(342, x, y-1.4, z+0.8, 0, 90, 0, 0);
  88.                                 MoveObject(grenade, x, y-5.0, z-1.2, 7, 0, 0, 0);
  89.                                 SetPlayerAmmo(playerid, 16, ammo-1);
  90.                             }
  91.                             if(A>=135 && A<180)
  92.                             {
  93.                                 GetPlayerPos(playerid, x, y, z);
  94.                                 grenade = CreateObject(342, x+1.4, y-1.4, z+0.8, 0, 90, 0, 0);
  95.                                 MoveObject(grenade, x+5.0, y-5.0, z-1.2, 7, 0, 0, 0);
  96.                                 SetPlayerAmmo(playerid, 16, ammo-1);
  97.                             }
  98.                             if(A>=180 && A<225)
  99.                             {
  100.                                 GetPlayerPos(playerid, x, y, z);
  101.                                 grenade = CreateObject(342, x+1.4, y, z+0.8, 0, 90, 0, 0);
  102.                                 MoveObject(grenade, x+5.0, y, z-1.2, 7, 0, 0, 0);
  103.                                 SetPlayerAmmo(playerid, 16, ammo-1);
  104.                             }
  105.                             if(A>=225 && A<270)
  106.                             {
  107.                                 GetPlayerPos(playerid, x, y, z);
  108.                                 grenade = CreateObject(342, x+1.4, y+1.4, z+0.8, 0, 90, 0, 0);
  109.                                 MoveObject(grenade, x+5.0, y+5.0, z-2, 7, 0, 0, 0);
  110.                                 SetPlayerAmmo(playerid, 16, ammo-1);
  111.                             }
  112.                             if(A>=270 && A<315)
  113.                             {
  114.                                 GetPlayerPos(playerid, x, y, z);
  115.                                 grenade = CreateObject(342, x-1.4, y+1.4, z+0.8, 0, 90, 0, 0);
  116.                                 MoveObject(grenade, x-5.0, y+5.0, z-1.2, 7, 0, 0, 0);
  117.                                 SetPlayerAmmo(playerid, 16, ammo-1);
  118.                             }
  119.                             if(A>=315 && A<360)
  120.                             {
  121.                                 GetPlayerPos(playerid, x, y, z);
  122.                                 grenade = CreateObject(342, x-1.4, y+1.4, z+0.8, 0, 90, 0, 0);
  123.                                 MoveObject(grenade, x-5.0, y+5.0, z-1.2, 7, 0, 0, 0);
  124.                                 SetPlayerAmmo(playerid, 16, ammo-1);
  125.                             }
  126.                             timer1 = SetTimer("boom", 4000, false);
  127.                         }
  128.                         if(ammo == 0) SendClientMessage(playerid, 0xFF0000FF, "Where is grenade? Buy it now!");
  129.                     }
  130.                     else SendClientMessage(playerid, 0xFF0000FF, "Where is grenade? Buy it now!");
  131.                 }
  132.             }
  133.         }
  134.     }
  135.     return 1;
  136. }
  137. public boom()
  138. {
  139. GetObjectPos(grenade,ox,oy,oz);
  140. DestroyObject(grenade);
  141. CreateExplosion( ox,oy,oz, 2, 2.0);
  142. KillTimer(timer1);
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement