• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua scroll on use

Lbtg

Advanced OT User
Joined
Nov 22, 2008
Messages
2,398
Reaction score
165
how i add cancel , if voc id 1,2 send cancel |your vocation cannot use the scroll|

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)


doRemoveItem(item.uid, 1)
doSendMagicEffect(fromPosition, 43)
doPlayerSetVocation(cid, 2)
doPlayerSave(cid)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations! You have been promoted to '.. getPlayerVocationName(cid)..'!!')

local pos = getThingPos(cid)
for i = 1, 55 do
doSendDistanceShoot({x = pos.x + math.random(-4, 4), y = pos.y + math.random(-4, 4), z = pos.z}, pos, 36)
end
return true
end
 
Code:
local cannotUse = {1, 2}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local voc = getPlayerVocation(cid)
    if voc > 4 or isInArray(cannotUse, voc) then
        return false
    end
    doRemoveItem(item.uid, 1)
    doSendMagicEffect(fromPosition, 43)
    doPlayerSetVocation(cid, voc + 4)
    doPlayerSave(cid)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations! You have been promoted to '.. getPlayerVocationName(cid)..'!!')
    local pos = getThingPos(cid)
    for i = 1, 55 do
        doSendDistanceShoot({x = pos.x + math.random(-4, 4), y = pos.y + math.random(-4, 4), z = pos.z}, pos, 36)
    end
    return true
end
 
it looks its working , but if wrong voc using can the player recieve a message saying "you already choosen your vocation "
 
Code:
local cannotUse = {1, 2}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local voc = getPlayerVocation(cid)
    if voc > 4 or isInArray(cannotUse, voc) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have already chosen your vocation.")
        return false
    end
    doRemoveItem(item.uid, 1)
    doSendMagicEffect(fromPosition, 43)
    doPlayerSetVocation(cid, voc + 4)
    doPlayerSave(cid)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations! You have been promoted to '.. getPlayerVocationName(cid)..'!!')
    local pos = getThingPos(cid)
    for i = 1, 55 do
        doSendDistanceShoot({x = pos.x + math.random(-4, 4), y = pos.y + math.random(-4, 4), z = pos.z}, pos, 36)
    end
    return true
end
 
wonderfull thank you realy much :) meybe you could help with npc aswell ? :) would be realy nice :)
 
Back
Top