Advertisement
Guest User

Anti Spawn Kill Protection - SAMP (AliScripter)

a guest
May 21st, 2016
692
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.85 KB | None | 0 0
  1. // Includes
  2. #include <a_samp>
  3.  
  4. // Variables
  5. new AntiSK[MAX_PLAYERS], AntiSKt[MAX_PLAYERS], AntiSKr[MAX_PLAYERS], AntiSKa[MAX_PLAYERS];
  6.  
  7. #define FLOAT_INFINITY (0x7F800000)
  8.  
  9. public OnFilterScriptInit()
  10. {
  11.     return 1;
  12. }
  13.  
  14. public OnFilterScriptExit()
  15. {
  16.     return 1;
  17. }
  18.  
  19. public OnPlayerSpawn(playerid)
  20. {
  21.     SpawnProtect(playerid);
  22.     return 1;
  23. }
  24.  
  25. forward SpawnProtect(playerid);
  26. public  SpawnProtect(playerid)
  27. {
  28.     SetPlayerHealth(playerid, FLOAT_INFINITY);
  29.     AntiSKr[playerid] = random(3);
  30.     switch(AntiSKr[playerid])
  31.     {
  32.         case 0:
  33.         {
  34.             AntiSKa[playerid] = 10*1000; // 10 multiplied by 1000 mili-secs = 10 seconds.
  35.             SendClientMessage(playerid, -1, "* You have spawn protection for 10 seconds.");
  36.         }
  37.         case 1:
  38.         {
  39.             AntiSKa[playerid] = 15*1000; // 15 multiplied by 1000 mili-secs = 15 seconds.
  40.             SendClientMessage(playerid, -1, "* You have spawn protection for 15 seconds.");
  41.         }
  42.         case 2:
  43.         {
  44.             AntiSKa[playerid] = 20*1000; // 20 multiplied by 1000 mili-secs = 20 seconds.
  45.             SendClientMessage(playerid, -1, "* You have spawn protection for 20 seconds.");
  46.         }
  47.     }
  48.     AntiSK[playerid] = 1;
  49.     AntiSKt[playerid] = SetTimerEx("AntiSKfunc", AntiSKa[playerid], false, "i", playerid);
  50.     SendClientMessage(playerid, -1, "* Press key 'N' to end spawn protection.");
  51.     return 1;
  52. }
  53.  
  54. forward AntiSKfunc(playerid);
  55. public  AntiSKfunc(playerid)
  56. {
  57.     AntiSK[playerid] = 0;
  58.     SetPlayerHealth(playerid, 99.0);
  59.     SetPlayerArmour(playerid, 99.0);
  60.     SendClientMessage(playerid, -1, "* Spawn protection ended.");
  61.     return 1;
  62. }
  63.  
  64. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  65. {
  66.     if(newkeys & KEY_NO && AntiSK[playerid] == 1)
  67.     {
  68.         KillTimer(AntiSKt[playerid]);
  69.         AntiSKfunc(playerid);
  70.         SendClientMessage(playerid, -1, "* You have ended your spawn protection.");
  71.     }
  72.     return 1;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement