Advertisement
Combreal

Ghost.lua

Jan 29th, 2014
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 KB | None | 0 0
  1. --Test of a server command that makes the admin invisible
  2. --Inspired from Wizard, Nuggets, Soap and Superzilla's works
  3.                 --With the great help of Kennan
  4.  
  5. ghost = {}
  6.  
  7. function GetRequiredVersion()
  8.     return 200
  9. end
  10.  
  11. function OnScriptLoad(processid, game, persistent)
  12.     main_timer  = registertimer(20, "IsPlayerGhost")
  13. end
  14.  
  15.  
  16. function OnServerCommand(player, command)
  17.  
  18.     local t = tokenizecmdstring(command)
  19.     local count = #t
  20.  
  21.     if t[1] == "sv_ghost" then
  22.         GhostPlayer(player)
  23.         return false
  24.     elseif t[1] == "sv_unghost" then
  25.         UnGhostPlayer(player)
  26.         return false
  27.     end
  28. end
  29.  
  30.  
  31. function OnGameEnd(stage)
  32.  
  33.     if stage == 1 then
  34.         if main_timer then
  35.             removetimer(main_timer)
  36.         end
  37.  
  38.         for player = 0, 15 do
  39.             if getplayer(player) then
  40.                 ghost[gethash(player)] = false
  41.             end
  42.         end
  43.     end
  44. end
  45.  
  46. function OnPlayerJoin(player)
  47.  
  48.     ghost[gethash(player)] = false
  49. end
  50.  
  51. function OnPlayerLeave(player)
  52.  
  53.     ghost[gethash(player)] = false
  54. end
  55.  
  56. function IsPlayerGhost(id, count)
  57.  
  58.     for player = 0, 15 do
  59.         if getplayer(player) then
  60.             if ghost[gethash(player)] == true then
  61.                 local z = readfloat(getplayer(player) + 0x100)
  62.                 writefloat(getplayer(player) + 0x100, z - 1000)
  63.             end
  64.         end
  65.     end
  66.     return true
  67. end
  68.  
  69.  
  70. function GhostPlayer(player)
  71.  
  72.     if ghost[gethash(player)] ~= nil then
  73.         if ghost[gethash(player)] == true then
  74.             sendconsoletext(player, "You are already in Ghost Mode!")
  75.         else
  76.             ghost[gethash(player)] = true
  77.             sendconsoletext(player, "Ghost Mode Enabled!")
  78.         end
  79.     end
  80. end
  81.  
  82. function UnGhostPlayer(player)
  83.  
  84.     if ghost[gethash(player)] ~= nil then
  85.         if ghost[gethash(player)] == false then
  86.             sendconsoletext(player, "You are not in Ghost Mode!")
  87.         else
  88.             ghost[gethash(player)] = false
  89.             sendconsoletext(player, "Ghost Mode Disabled!")
  90.         end
  91.     end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement