peinneon

Noobist LandMine System

Dec 14th, 2011
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.17 KB | None | 0 0
  1. // Noobist LandMine System (NLM)
  2. // Created by Noobist, Credits to ZeeX (ZCMD), Y_Less (foreach), Incognito (Streamer), sheen (Concept), Kye (SA-MP)
  3. // You need ZCMD include from ZeeX, Streamer from Incognito, and foreach from Y_Less.
  4.  
  5.  
  6. #define FILTERSCRIPT
  7. #include <a_samp>
  8. #include <zcmd>
  9. #include <streamer>
  10. #include <foreach>
  11.  
  12. new LMCP[MAX_PLAYERS];
  13.  
  14. forward Plant(playerid);
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     foreach(Player, p) OnPlayerConnect(p);
  19.     print("\n--------------------------------------");
  20.     print(" Noobist LandMine System Loaded");
  21.     print("--------------------------------------\n");
  22.     return 1;
  23. }
  24.  
  25. public OnFilterScriptExit()
  26. {
  27.     foreach(Player, p)
  28.     {
  29.         DeletePVar(p, "HasLM");
  30.         DeletePVar(p, "LMX");
  31.         DeletePVar(p, "LMY");
  32.         DeletePVar(p, "LMZ");
  33.         DeletePVar(p, "LMID");
  34.     }
  35.     for(new cp = 0; cp < MAX_PLAYERS; cp++) DestroyDynamicCP(LMCP[cp]);
  36.     print("\n--------------------------------------");
  37.     print(" Noobist LandMine System Unloaded");
  38.     print("--------------------------------------\n");
  39.     return 1;
  40. }
  41.  
  42. public OnPlayerConnect(playerid)
  43. {
  44.     SendClientMessage(playerid, 0x00FF00, "This server landmine system is powered by Noobist LandMine System. Use /minehelp for more information.");
  45.     return 1;
  46. }
  47.  
  48. public OnPlayerDisconnect(playerid, reason)
  49. {
  50.     if(GetPVarInt(playerid, "HasLM") == 2) DestroyDynamicCP(LMCP[playerid]);
  51.     return 1;
  52. }
  53.  
  54. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  55. {
  56.     foreach(Player, p)
  57.     {
  58.         if(GetPVarInt(p, "HasLM") == 2 && GetPVarInt(p, "LMID") == checkpointid)
  59.         {
  60.             if(p == playerid) return 1;
  61.             CreateExplosion(GetPVarFloat(p, "LMX"), GetPVarFloat(p, "LMY"), GetPVarFloat(p, "LMZ"), 0, 10.0);
  62.             SetPVarInt(p, "HasLM", 0);
  63.             DeletePVar(p, "LMID");
  64.             SendClientMessage(playerid, 0xFF0000, "You stepped on a landmine!");
  65.             SendClientMessage(p, 0x00FF00, "Your landmine has exploded.");
  66.             DestroyDynamicCP(checkpointid);
  67.             DeletePVar(p, "LMX");
  68.             DeletePVar(p, "LMY");
  69.             DeletePVar(p, "LMZ");
  70.             return 1;
  71.         }
  72.     }
  73.     return 1;
  74. }
  75.  
  76. CMD:plant(playerid)
  77. {
  78.     if(GetPVarInt(playerid, "HasLM") == 0) return SendClientMessage(playerid, 0xFF0000, "You don't have any landmine. Buy it in Emmet's Place");
  79.     if(GetPVarInt(playerid, "HasLM") == 2) return SendClientMessage(playerid, 0xFF0000, "You already planted your landmine.");
  80.     if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) return SendClientMessage(playerid, 0xFF0000, "You must be crouching to plant a landmine.");
  81.     SetTimerEx("Plant", 5000, false, "i", playerid);
  82.     SendClientMessage(playerid, 0x00FF00, "Hold your position in 5 seconds to plant the landmine.");
  83.     new Float:x, Float:y, Float:z;
  84.     GetPlayerPos(playerid, x, y, z);
  85.     SetPVarFloat(playerid, "LMX", x);
  86.     SetPVarFloat(playerid, "LMY", y);
  87.     SetPVarFloat(playerid, "LMZ", z);
  88.     return 1;
  89. }
  90.  
  91.  
  92.  
  93. public Plant(playerid)
  94. {
  95.     new Float:x, Float:y, Float:z;
  96.     GetPlayerPos(playerid, x, y, z);
  97.     if(x != GetPVarFloat(playerid, "LMX") || y != GetPVarFloat(playerid, "LMY")) return SendClientMessage(playerid, 0xFF0000, "You must hold your position in 5 seconds to plant the landmine.");
  98.     if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) return SendClientMessage(playerid, 0xFF0000, "You must be crouching to plant a landmine.");
  99.     LMCP[playerid] = CreateDynamicCP(x, y, z, 3.5, -1, -1, -1, 4.0);
  100.     SetPVarInt(playerid, "HasLM", 2);
  101.     SetPVarInt(playerid, "LMID", LMCP[playerid]);
  102.     SendClientMessage(playerid, 0x00FF00, "Landmine planted.");
  103.     return 1;
  104. }
  105.  
  106. CMD:defusemine(playerid)
  107. {
  108.     if(GetPVarInt(playerid, "HasLM") == 0) return SendClientMessage(playerid, 0xFF0000, "You don't have any landmine. Buy it in Emmet's Place.");
  109.     if(GetPVarInt(playerid, "HasLM") == 1) return SendClientMessage(playerid, 0xFF0000, "You don't have any planted landmine.");
  110.     SetPVarInt(playerid, "HasLM", 0);
  111.     DeletePVar(playerid, "LMID");
  112.     DeletePVar(playerid, "LMX");
  113.     DeletePVar(playerid, "LMY");
  114.     DeletePVar(playerid, "LMZ");
  115.     DestroyDynamicCP(LMCP[playerid]);
  116.     SendClientMessage(playerid, 0x00FF00, "Landmine defused.");
  117.     return 1;
  118. }
  119.  
  120. CMD:buymine(playerid)
  121. {
  122.     if(!IsPlayerInRangeOfPoint(playerid, 20, 2447.1755, -1972.8712, 13.5469)) return SendClientMessage(playerid, 0xFF0000, "You must in Emmet's Place to buy a landmine.");
  123.     if(GetPVarInt(playerid, "HasLM") >= 1) return SendClientMessage(playerid, 0xFF0000, "You already have a landmine.");
  124.     if(GetPlayerMoney(playerid) < 25000) return SendClientMessage(playerid, 0xFF0000, "You need $25000 to buy a landmine.");
  125.     SetPVarInt(playerid, "HasLM", 1);
  126.     GivePlayerMoney(playerid, -25000);
  127.     SendClientMessage(playerid, 0x00FF00, "You have purchased landmine, use /plant to plant the landmine.");
  128.     return 1;
  129. }
  130.  
  131. CMD:minehelp(playerid)
  132. {
  133.     SendClientMessage(playerid, 0x00FF00, "Noobist LandMine System, Credits: ZeeX (ZCMD), Y_Less (foreach), Incognito (Streamer), sheen (Concept), Kye (SA-MP)");
  134.     SendClientMessage(playerid, 0x00FF00, "Available Commands");
  135.     SendClientMessage(playerid, 0x00FF00, "/buymine -> purchase a landmine in Emmet's Place");
  136.     SendClientMessage(playerid, 0x00FF00, "/plant -> plant a landmine");
  137.     SendClientMessage(playerid, 0x00FF00, "/defusemine -> deactivate your landmine");
  138.     return 1;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment