Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- util.AddNetworkString("oocprint")
- local meta = FindMetaTable("Player")
- function strstarts(String,Start)
- return string.sub(String:lower(),1,string.len(Start:lower()))==Start:lower()
- end
- function GetPlayers(text,request_ply)
- for k,v in pairs(player.GetAll()) do
- if strstarts(v:Name(), text) then return v end
- end
- end
- local correctweapon = {
- "weapon_357",
- "weapon_ar2"
- }
- function meta:CheckActiveWeapon()
- for k,v in pairs(correctweapon) do
- if self:GetActiveWeapon():GetClass() == v then
- return true;
- end
- end
- return false;
- end
- hook.Add("PlayerSay", "PS", function(ply, text)
- local word = string.Explode(" ", text)
- /*
- Money commands
- */
- if word[1] == "/addmoney" then
- if not word[2] then return "" end
- table.remove(word,1)
- GetPlayers(table.concat(word, " ", 1, table.Count( word )-1)):AddMoney(table.remove(word,#word))
- return ""
- end
- if word[1] == "/getmoney" then
- if not word[2] then return "" end
- table.remove(word,1)
- ply:ChatPrint(GetPlayers(table.concat(word," ")):Name().." possède "..GetPlayers(table.concat(word," ")):GetMoney().."€.")
- return ""
- end
- if word[1] == "/setmoney" then
- if not word[2] then return "" end
- table.remove(word,1)
- GetPlayers(table.concat(word, " ", 1, table.Count( word )-1)):SetMoney(table.remove(word,#word))
- return ""
- end
- if word[1] == "/takemoney" then
- if not word[2] then return "" end
- table.remove(word,1)
- if GetPlayers(table.concat(word, " ", 1, table.Count( word )-1)):GetMoney() > 0 then
- GetPlayers(table.concat(word, " ", 1, table.Count( word )-1)):TakeMoney(table.remove(word,#word))
- end
- return ""
- end
- if word[1] == "/dropmoney" then
- if not word[2] then return "" end
- if tonumber(word[2]) == 0 then
- return ""
- end
- if tonumber(ply:GetMoney()) >= math.abs(tonumber(word[2])) then
- ply:TakeMoney(math.abs(tonumber(word[2])))
- local money = ents.Create("base_money")
- money:SetPos(ply:GetShootPos() + ply:GetAimVector() * 50)
- money:Spawn()
- money:Activate()
- money:SetValue(math.abs(tonumber(word[2])))
- end
- return ""
- end
- /*
- Chat commands
- */
- if word[1] == "/ooc" then
- net.Start("oocprint")
- net.WriteString(ply:Name())
- net.WriteString(string.sub(text, 6))
- net.Send(player.GetAll())
- print("[OOC] "..ply:Name()..": "..string.sub(text, 6))
- return ""
- elseif word[1] == "//" then
- net.Start("oocprint")
- net.WriteString(ply:Name())
- net.WriteString(string.sub(text, 4))
- net.Send(player.GetAll())
- print("[OOC] "..ply:Name()..": "..string.sub(text, 4))
- return ""
- end
- /*
- Job commands
- */
- if word[1] == "/getjob" then
- if not word[2] then return "" end
- table.remove(word,1)
- ply:ChatPrint(GetPlayers(table.concat(word," ")):Nick().." is "..GetPlayers(table.concat(word," ")):GetJobSN())
- return ""
- end
- if word[1] == "/setjob" then
- if not word[2] then return "" end
- table.remove(word,1)
- GetPlayers(table.concat(word, " ", 1, table.Count(word)-1)):SetJob(table.remove(word,#word))
- return ""
- end
- if text == "/drop" then
- if ply:CheckActiveWeapon() then
- ply:DropWeapon(ply:GetActiveWeapon())
- end
- return ""
- end
- if word[1] == "/sethunger" then
- if not word[2] then return "" end
- table.remove(word,1)
- GetPlayers(table.concat(word, " ", 1, table.Count(word)-1)):SetHunger(table.remove(word,#word))
- return ""
- end
- if word[1] == "/gethunger" then
- if not word[2] then return "" end
- table.remove(word,1)
- ply:ChatPrint(GetPlayers(table.concat(word, " ")):Nick().." has "..GetPlayers(table.concat(word, " ")):GetHunger().." of hunger")
- return ""
- end
- if word[1] == "/setthirst" then
- if not word[2] then return "" end
- table.remove(word,1)
- GetPlayers(table.concat(word, " ", 1, table.Count(word)-1)):SetThirst(table.remove(word,#word))
- return ""
- end
- if word[1] == "/getthirst" then
- if not word[2] then return "" end
- table.remove(word,1)
- ply:ChatPrint(GetPlayers(table.concat(word, " ")):Nick().." has "..GetPlayers(table.concat(word, " ")):GetThirst().." of thirst")
- return ""
- end
- if word[1] == "/gethealth" then
- if not word[2] then return "" end
- table.remove(word,1)
- ply:ChatPrint(GetPlayers(table.concat(word, " ")):Nick().." has "..GetPlayers(table.concat(word, " ")):Health().." of life")
- return ""
- end
- if word[1] == "/sethealth" then
- if not word[2] then return "" end
- table.remove(word,1)
- GetPlayers(table.concat(word, " ", 1, table.Count(word)-1)):SetHealth(table.remove(word,#word))
- return ""
- end
- return text
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement