LucasFerraz
Systems Analyst
!steal PLAYERTARGET will steal 0~20k from player.
I should steal only nearby players (1x1 like exori). Can someone help?
I should steal only nearby players (1x1 like exori). Can someone help?
Code:
function onSay(cid, words, param, channel)
if not param or param == '' then
doPlayerSendCancel(cid, "Player target is offline or do not exist.")
return true
end
local StealLevel = getConfigValue('StealLevelProtection')
local target = getPlayerByName(param)
local randomvalue = math.random(0,20000)
local targetcash = getPlayerMoney(target)
if target == nil then
doPlayerSendCancel(cid, "Player target is offline or do not exist.")
return true
else
if (getTileInfo(getCreaturePosition(cid)).protection) or (getTileInfo(getCreaturePosition(target)).protection) then
doPlayerSendCancel(cid, "You can not steal inside of a Protection Zone.")
return true
elseif getPlayerLevel(cid) <= StealLevel then
doPlayerSendCancel(cid, "You must be level 80 or higher to steal.")
return true
elseif getPlayerLevel(target) < StealLevel then
doPlayerSendCancel(cid, "You can not steal a player level 80 or lower.")
return true
elseif getPlayerName(cid) == getPlayerName(target) then
doPlayerSendCancel(cid, "You can not steal yourself.")
return true
end
if targetcash < randomvalue then
doPlayerRemoveMoney(target, targetcash)
doPlayerAddMoney(cid,targetcash)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You stole '.. targetcash ..'gp from '.. getPlayerName(target)..'.')
doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, ''.. getPlayerName(cid) ..' stole '.. targetcash ..'gp of you.')
else
doPlayerRemoveMoney(target, randomvalue)
doPlayerAddMoney(cid,randomvalue)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You stole '.. randomvalue ..'gp from '.. getPlayerName(target) ..'.')
doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, ''.. getPlayerName(cid) ..' stole '.. randomvalue ..'gp of you.')
end
if getPlayerGuildId(cid) <= 0 then
if getPlayerGuildId(target) <= 0 then
doAddCriminalPoints(cid, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You received 1 criminal point for stealing. You have '.. getCriminalPoints(cid) ..' criminal points.')
elseif getPlayerGuildId(target) > 0 then
doAddCriminalPoints(cid, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You received 1 criminal point for stealing. You have '.. getCriminalPoints(cid) ..' criminal points.')
end
else
if getPlayerGuildId(cid) == getPlayerGuildId(target) then
doPlayerSendCancel(cid, "You can not steal a member of your guild.")
return true
elseif getPlayerGuildId(target) <= 0 then
doAddCriminalPoints(cid, 2)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You received 2 criminal points for stealing a player without a guild. You have '.. getCriminalPoints(cid) ..' criminal points.')
elseif getPlayerGuildId(target) > 0 then
doAddCriminalPoints(cid, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You received 1 criminal point for stealing. You have '.. getCriminalPoints(cid) ..' criminal points.')
end
end
doCreatureSetSkullType(cid, SKULL_WHITE)
doPlayerSetSkullEnd(cid, os.time() + 15 * 60 * 1000, SKULL_WHITE)
local PZBlock = createConditionObject(CONDITION_INFIGHT)
setConditionParam(PZBlock, CONDITION_PARAM_TICKS, 15 * 60 * 1000)
end
return true
end