Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.37 KB | None | 0 0
  1. util.AddNetworkString("oocprint")
  2. local meta = FindMetaTable("Player")
  3.  
  4. function strstarts(String,Start)
  5.     return string.sub(String:lower(),1,string.len(Start:lower()))==Start:lower()
  6.  end
  7.  
  8.  function GetPlayers(text,request_ply)
  9.      for k,v in pairs(player.GetAll()) do
  10.          if strstarts(v:Name(), text) then return v end
  11.      end
  12.  end
  13.  
  14.  local correctweapon = {
  15.  "weapon_357",
  16.  "weapon_ar2"
  17.  }
  18.  
  19.  function meta:CheckActiveWeapon()
  20.      for k,v in pairs(correctweapon) do
  21.          if self:GetActiveWeapon():GetClass() == v then
  22.              return true;
  23.          end
  24.      end
  25.      return false;
  26.  end
  27.  
  28.  hook.Add("PlayerSay", "PS", function(ply, text)
  29.      local word = string.Explode(" ", text)
  30.          
  31.      /*
  32.              Money commands
  33.      */
  34.  
  35.      if word[1] == "/addmoney" then
  36.          if not word[2] then return "" end
  37.          table.remove(word,1)
  38.          GetPlayers(table.concat(word, " ", 1, table.Count( word )-1)):AddMoney(table.remove(word,#word))
  39.          return ""
  40.      end
  41.  
  42.      if word[1] == "/getmoney" then
  43.          if not word[2] then return "" end
  44.          table.remove(word,1)
  45.          ply:ChatPrint(GetPlayers(table.concat(word," ")):Name().." possède "..GetPlayers(table.concat(word," ")):GetMoney().."€.")
  46.          return ""
  47.      end
  48.  
  49.      if word[1] == "/setmoney" then
  50.          if not word[2] then return "" end
  51.          table.remove(word,1)
  52.          GetPlayers(table.concat(word, " ", 1, table.Count( word )-1)):SetMoney(table.remove(word,#word))
  53.          return ""
  54.      end
  55.  
  56.      if word[1] == "/takemoney" then
  57.          if not word[2] then return "" end
  58.          table.remove(word,1)
  59.          if GetPlayers(table.concat(word, " ", 1, table.Count( word )-1)):GetMoney() > 0 then
  60.              GetPlayers(table.concat(word, " ", 1, table.Count( word )-1)):TakeMoney(table.remove(word,#word))
  61.          end
  62.          return ""
  63.      end
  64.  
  65.      if word[1] == "/dropmoney" then
  66.          if not word[2] then return "" end
  67.          if tonumber(word[2]) == 0 then
  68.              return ""
  69.          end
  70.  
  71.          if tonumber(ply:GetMoney()) >= math.abs(tonumber(word[2])) then
  72.              ply:TakeMoney(math.abs(tonumber(word[2])))
  73.              local money = ents.Create("base_money")
  74.              money:SetPos(ply:GetShootPos() + ply:GetAimVector() * 50)
  75.              money:Spawn()
  76.              money:Activate()
  77.              money:SetValue(math.abs(tonumber(word[2])))
  78.          end
  79.          return ""
  80.      end
  81.  
  82.      /*
  83.              Chat commands
  84.      */
  85.  
  86.      if word[1] == "/ooc" then
  87.          net.Start("oocprint")
  88.          net.WriteString(ply:Name())
  89.          net.WriteString(string.sub(text, 6))
  90.          net.Send(player.GetAll())
  91.          print("[OOC] "..ply:Name()..": "..string.sub(text, 6))
  92.          return ""
  93.      elseif word[1] == "//" then
  94.          net.Start("oocprint")
  95.          net.WriteString(ply:Name())
  96.          net.WriteString(string.sub(text, 4))
  97.          net.Send(player.GetAll())
  98.          print("[OOC] "..ply:Name()..": "..string.sub(text, 4))
  99.          return ""
  100.      end
  101.  
  102.      /*
  103.              Job commands
  104.      */
  105.  
  106.      if word[1] == "/getjob" then
  107.          if not word[2] then return "" end
  108.          table.remove(word,1)
  109.          ply:ChatPrint(GetPlayers(table.concat(word," ")):Nick().." is "..GetPlayers(table.concat(word," ")):GetJobSN())
  110.          return ""
  111.      end
  112.  
  113.      if word[1] == "/setjob" then
  114.          if not word[2] then return "" end
  115.          table.remove(word,1)
  116.          GetPlayers(table.concat(word, " ", 1, table.Count(word)-1)):SetJob(table.remove(word,#word))
  117.          return ""
  118.      end
  119.  
  120.      if text == "/drop" then
  121.          if ply:CheckActiveWeapon() then
  122.              ply:DropWeapon(ply:GetActiveWeapon())
  123.          end
  124.          return ""
  125.      end
  126.  
  127.      if word[1] == "/sethunger" then
  128.          if not word[2] then return "" end
  129.          table.remove(word,1)
  130.          GetPlayers(table.concat(word, " ", 1, table.Count(word)-1)):SetHunger(table.remove(word,#word))
  131.          return ""
  132.      end
  133.  
  134.      if word[1] == "/gethunger" then
  135.          if not word[2] then return "" end
  136.          table.remove(word,1)
  137.             ply:ChatPrint(GetPlayers(table.concat(word, " ")):Nick().." has "..GetPlayers(table.concat(word, " ")):GetHunger().." of hunger")
  138.          return ""
  139.      end
  140.  
  141.      if word[1] == "/setthirst" then
  142.          if not word[2] then return "" end
  143.          table.remove(word,1)
  144.          GetPlayers(table.concat(word, " ", 1, table.Count(word)-1)):SetThirst(table.remove(word,#word))
  145.          return ""
  146.      end
  147.  
  148.      if word[1] == "/getthirst" then
  149.          if not word[2] then return "" end
  150.          table.remove(word,1)
  151.             ply:ChatPrint(GetPlayers(table.concat(word, " ")):Nick().." has "..GetPlayers(table.concat(word, " ")):GetThirst().." of thirst")
  152.          return ""
  153.      end
  154.  
  155.      if word[1] == "/gethealth" then
  156.          if not word[2] then return "" end
  157.          table.remove(word,1)
  158.             ply:ChatPrint(GetPlayers(table.concat(word, " ")):Nick().." has "..GetPlayers(table.concat(word, " ")):Health().." of life")
  159.          return ""
  160.      end
  161.      if word[1] == "/sethealth" then
  162.          if not word[2] then return "" end
  163.          table.remove(word,1)
  164.          GetPlayers(table.concat(word, " ", 1, table.Count(word)-1)):SetHealth(table.remove(word,#word))
  165.          return ""
  166.      end
  167.  
  168.      return text
  169.  end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement