local max_promotion_level = 1
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
return true
end
local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough params.")
return true
end
local pid = getPlayerByNameWildcard(t[1])
if not pid or isPlayerGhost(pid) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
return true
end
if not tonumber(t[2]) ~= nil then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Promotion param not a number.")
return true
end
local promo_level = tonumber(t[2])
if promo_level < 0 or promo_level > max_promotion_level then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Promotion param is not acceptable. Number must be above -1 and below " .. max_promotion_level ..".")
return true
end
if getPlayerPromotionLevel(pid) ~= promo_level then
doPlayerSetPromotionLevel(pid, promo_level)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "" .. t[1] .. "'s promotional status has been altered. " .. t[1] .. "'s vocation is now set to | " .. getPlayerVocationName(pid) .. ".")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is already set to this promotional level.")
end
return true
end