Advertisement
Guest User

Untitled

a guest
Oct 9th, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. -- ServerControl-Script v0.1a
  2.  
  3. dofile("sys/lua/wrapper.lua")
  4.  
  5. function table.newDynArray()
  6.     array = {}
  7.     array.content = {}
  8.     function array:push(el)
  9.         array.content[#self.content + 1] = el
  10.     end
  11.    
  12.     return array
  13. end
  14.  
  15. function parse(str)
  16.     flag_brackets = false
  17.     current_token = ""
  18.     tokens = table.newDynArray()
  19.    
  20.     for c in str:gmatch(".") do
  21.         if (c == '"') then
  22.             flag_brackets = not flag_brackets
  23.             if (current_token ~= "") then
  24.                 tokens:push(current_token)
  25.             end
  26.         elseif (c == " ") then
  27.             if (flag_brackets) then
  28.                 current_token = current_token .. " "
  29.             else
  30.                 if (current_token ~= "") then
  31.                     tokens:push(current_token)
  32.                     current_token = ""
  33.                 end
  34.             end
  35.         else
  36.             current_token = current_token .. c
  37.         end
  38.     end
  39.    
  40.     tokens:push(current_token)
  41.    
  42.     return tokens.content
  43. end
  44.  
  45. ------------------------------------------
  46.  
  47. function flare(id, tokens)
  48.     print("yo")
  49.     print(player(id, "x"))
  50.     print(player(id, "y"))
  51.     e = "explosion " ..math.floor(player(id, "x")).. " " ..math.floor(player(id, "y")).." 5 5 0"
  52.     print("\""..e.."\"")
  53.     parse(e)
  54.     explosion(2544, 694, 5, 5, 0)
  55.     print("eh")
  56. end
  57.  
  58. ------------------------------------------
  59.  
  60. admin_list = {}
  61.  
  62. functions = {}
  63. functions["#flare"] = flare
  64.  
  65. function isAdmin(id)
  66.     if (id == 1) then
  67.         return true
  68.     end
  69. end
  70.  
  71. addhook("say", "on_say")
  72. function on_say(id,message)
  73.     if (isAdmin(id)) then
  74.         tokens = parse(message)
  75.         if (string.byte(tokens[1], 1) == 35) then
  76.             functions[tokens[1]](id, tokens)
  77.         end
  78.     end
  79.     return 0
  80. end
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement