Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. function onSay(cid, words, param, channel)
  2.     if(param == '') then
  3.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
  4.         return true
  5.     end
  6.  
  7.     local t = string.explode(param, ",", 1)
  8.     local pid = getPlayerByNameWildcard(t[1])
  9.     if(not pid) then
  10.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
  11.         return true
  12.     end
  13.  
  14.     if(getPlayerAccess(pid) >= getPlayerAccess(cid)) then
  15.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot perform action.")
  16.         return true
  17.     end
  18.  
  19.     local g, group = 1, getPlayerGroupId(pid)
  20.     if(words:sub(2, 2) == "d") then
  21.         g = -1
  22.     end
  23.  
  24.     local newGroup = group + g
  25.     if(t[2] ~= nil) then
  26.         for i, id in ipairs(getGroupList()) do
  27.             local tmp = getGroupInfo(id)
  28.             if(isInArray({tmp.id, tmp.name}, t[2])) then
  29.                 newGroup = id
  30.                 break
  31.             end
  32.         end
  33.     end
  34.  
  35.     if(newGroup <= 0 or newGroup == group or not setPlayerGroupId(pid, newGroup)) then
  36.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot perform action.")
  37.         return true
  38.     end
  39.  
  40.     local str = "been " .. (group < newGroup and "promoted" or "demoted") .. " to " .. getGroupInfo(newGroup).name .. "."
  41.     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param .. " has " .. str)
  42.     doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You have " .. str)
  43.     return true
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement