Ghecco

PreventShoot

Oct 6th, 2020 (edited)
211
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Armi scariche
  2.  
  3. #include <a_samp>
  4. #include <streamer>
  5.  
  6. #define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) // Già definito
  7. #define KEY_AIM KEY_HANDBRAKE // Non definito di default
  8.  
  9.  
  10.  
  11. #define AMMO_INFINITE   (99999)
  12. #define MAX_WEAPON_FAIL (3)
  13.  
  14.  
  15.  
  16. main(){}
  17.  
  18. public OnPlayerSpawn(playerid)
  19. {
  20.      SetPlayerPos(playerid, 244.7393,-50.9366,1.5781);
  21.     SetPlayerSkin(playerid, 25);
  22.     GivePlayerWeapon(playerid, 10, 3);
  23.     GivePlayerWeapon(playerid, 24, 4);
  24.     return 1;
  25. }
  26. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  27. {
  28.     if(GetPlayerAmmo(playerid) == 1) GivePlayerWeapon(playerid, weaponid, AMMO_INFINITE), SendClientMessage(playerid, -1, "Arma scarica");
  29.     else if(GetEmptyWeapon(playerid))
  30.     {
  31.         PreventPlayerShoot(playerid, true);
  32.         return 0;
  33.     }
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerShootDynamicObject(playerid, weaponid, STREAMER_TAG_OBJECT:objectid, Float:x, Float:y, Float:z)
  38. {
  39.     if(GetEmptyWeapon(playerid)) return 0;
  40.     return 1;
  41. }
  42.  
  43. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  44. {
  45.     if(newkeys & KEY_AIM) if(GetEmptyWeapon(playerid)) PreventPlayerShoot(playerid);
  46.     return 1;
  47. }
  48.  
  49.  
  50. GetEmptyWeapon(playerid)
  51. {
  52.     if(GetPlayerAmmo(playerid) < 0) return 1;
  53.     else return 0;
  54. }
  55.  
  56. stock PreventPlayerShoot(playerid, bool:adding = false)
  57. {
  58.     new spariFail = GetPVarInt(playerid, "Player_WeaponFail");
  59.     if(spariFail >= MAX_WEAPON_FAIL) SendClientMessage(playerid, -1, "[PreventShoot] Non ti è permesso mirare, hai eseguito troppi FailShot."),  SetPlayerArmedWeapon(playerid, 0);
  60.     if(adding == true)
  61.     {
  62.         spariFail++;
  63.         SetPVarInt(playerid, "Player_WeaponFail", spariFail);
  64.         SendClientMessageFormatted(playerid, -1, "[PreventShoot]Stai sparando con un'arma scarica, rischi di farti bloccare la mira ! %d/%d", spariFail, MAX_WEAPON_FAIL);
  65.         SetPlayerArmedWeapon(playerid, 0);
  66.     }
  67.     return 1;
  68. }
  69.  
RAW Paste Data