Advertisement
Guest User

[FS]Spikes

a guest
Jul 31st, 2016
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4.  
  5.  
  6. //============//
  7. new bool:CSpike1[MAX_PLAYERS];
  8. new bool:CSpike2[MAX_PLAYERS];
  9. new Spike1[MAX_PLAYERS];
  10. new Spike2[MAX_PLAYERS];
  11. //============//
  12.  
  13. #define COLOR_RED 0xFF0000AA
  14.  
  15.  
  16. new Float:spX, Float:spY, Float:spZ, Float:spA;
  17.  
  18. stock PopPlayerTires(playerid)
  19. {
  20. new vehicleid = GetPlayerVehicleID(playerid);
  21. new panels, doors, lights, tires;
  22. GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
  23. tires = encode_tires(1, 1, 1, 1);
  24. UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, 15);
  25. }
  26.  
  27. ///////////////////////////////////////////////////////
  28. CMD:cspike(playerid, params[])
  29. {
  30. new id;
  31. GetPlayerPos(playerid, spX, spY, spZ);
  32. GetPlayerFacingAngle(playerid, spA);
  33.  
  34. if(sscanf(params, "i", id))
  35. {
  36. SendClientMessage(playerid, 0xFF0000AA, "/cspike [1|2]");
  37. SendClientMessage(playerid, -1, "1 - Small");
  38. SendClientMessage(playerid, -1, "2 - Big");
  39. return 1;
  40. }
  41. if(id == 1)
  42. {
  43. if(CSpike1[playerid] == false && CSpike2[playerid] == false)
  44. {
  45. Spike1[playerid] = CreateObject(2899, spX+5, spY, spZ-0.83, 0.0, 0.0, spA+180);
  46. CSpike1[playerid] = true;
  47. SendClientMessage(playerid, -1, "You set a Small spike.");
  48. }
  49. else return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: You already have created Spike!.");
  50. }
  51. else if(id == 2)
  52. {
  53. if(CSpike2[playerid] == false && CSpike1[playerid] == false)
  54. {
  55. Spike2[playerid] = CreateObject(2892, spX+5, spY, spZ-0.95, 0.0, 0.0, spA+180);
  56. CSpike2[playerid] = true;
  57. SendClientMessage(playerid, -1, "You set a Big spike.");
  58. }
  59. else return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]: You already have created Spike.");
  60. }
  61. else return SendClientMessage(playerid, 0xFF0000AA, "Wrong spike id [1|2].");
  62. return 1;
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. CMD:destroyspike(playerid, params[])
  66. {
  67. new id;
  68. if(sscanf(params, "i", id)) return SendClientMessage(playerid,-1, "/dspike [1|2]");
  69. if(id == 1)
  70. {
  71. if(CSpike1[playerid] == true)
  72. {
  73. DestroyObject(Spike1[playerid]);
  74. SendClientMessage(playerid, -1, "Small spike destroyed.");
  75. CSpike1[playerid] = false;
  76. }
  77. else return SendClientMessage(playerid, -1, "Small spike is not created.");
  78. }
  79. else if(id == 2)
  80. {
  81. if(CSpike2[playerid] == true)
  82. {
  83. DestroyObject(Spike2[playerid]);
  84. SendClientMessage(playerid, -1, "Bug spike destroyed.");
  85. CSpike2[playerid] = false;
  86. }
  87. else return SendClientMessage(playerid, -1, "Big spike is not created.");
  88. }
  89. else return SendClientMessage(playerid, 0xFF0000AA, "Wrong spike id [1|2].");
  90. return 1;
  91. }
  92.  
  93. public OnPlayerUpdate(playerid)
  94. {
  95. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  96. {
  97. if(IsPlayerInRangeOfPoint(playerid, 3.0, spX+5, spY, spZ-0.83))
  98. {
  99. if(CSpike1[playerid] == 1)
  100. {
  101. PopPlayerTires(playerid);
  102. }
  103. }
  104.  
  105. }
  106. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  107. {
  108. if(IsPlayerInRangeOfPoint(playerid, 3.0, spX+5, spY, spZ-0.95))
  109. {
  110. if(CSpike2[playerid] == 1)
  111. {
  112. PopPlayerTires(playerid);
  113. }
  114. }
  115.  
  116. }
  117. return 1;
  118. }
  119. //============================================================================//
  120. encode_tires(tires1, tires2, tires3, tires4) {
  121.  
  122. return tires1 | (tires2 << 1) | (tires3 << 2) | (tires4 << 3);
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement