Guest User

Untitled

a guest
May 27th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. function CreateCK()
  2.     if not fileExists(":RPGU_CK/CK.txt") then
  3.         local newfile = fileCreate(":RPGU_CK/CK.txt")
  4.         fileClose(newfile)
  5.     end
  6. end
  7. addEventHandler("onResourceStart", getRootElement(), CreateCK)
  8.  
  9. function checkPlayer(playerElementOrName)
  10.     local userName = playerElementOrName
  11.     if isElement(playerElementOrName) and getElementType(playerElementOrName) == "player" then
  12.         userName = getPlayerName(playerElementOrName)
  13.     elseif type(playerElementOrString) ~= "string" then
  14.         return
  15.     end
  16.  
  17.     local fd = fileOpen(":RPGU_CK/CK.txt", true)
  18.     if fd then
  19.         local content = split(fileRead(fd, fileGetSize(fd)), "\r\n")
  20.         fileClose(fd)
  21.         userName = userName:lower()
  22.         for index, value in pairs(content) do
  23.             if value == userName then
  24.                 return true
  25.             end
  26.         end
  27.         return false
  28.     end
  29. end
  30.  
  31.  
  32. function CKcmd (source,cmd,cked)
  33.     if cked then
  34.         local blah = getPlayerFromName(cked)
  35.         outputChatBox("((" ..cked.. " just got Character killed by admin!))")
  36.         local ckfile = fileOpen(":RPGU_CK/CK.txt")
  37.         fileSetPos(ckfile, fileGetSize(ckfile))
  38.         fileWrite(ckfile, cked:lower().."\r\n")
  39.         fileClose(ckfile)
  40.         kickPlayer(blah,"You just got Character Killed, please use another one")
  41.         end
  42.     end
  43. addCommandHandler("ck", CKcmd)
  44.  
  45. function CKKick()
  46.     if checkPlayer(source) then
  47.         kickPlayer(source,"This character is dead. Use another one.")
  48.         end
  49.     end
  50. addEventHandler("onPlayerJoin", getRootElement(), CKKick)
Add Comment
Please, Sign In to add comment