• 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!

Action Vocation Chest!

Evil Hero

Legacy Member
TFS Developer
Joined
Dec 12, 2007
Messages
1,255
Solutions
28
Reaction score
723
Location
Germany
Hello everybody :D

I'm going to share my Vocation Chest now with you all :)

PHP:
-->>>>>>>>>>>>>>>>>++<<<<<<<<<<<<<<<<<<<--
 -->>>>>>>>>> Vocation Chest <<<<<<<<<<--
 -->>>>>>>>>>>>> made by <<<<<<<<<<<<<<--
 -->>>>>>>>>>>> Evil Hero <<<<<<<<<<<<<--
-->>>>>>>>>>>>>>>>>++<<<<<<<<<<<<<<<<<<<--

function onUse(cid, item, frompos, item2, topos)
 
-->>>>>>>>>> CONFIG <<<<<<<<<<--
local action = xxxx--The id of the Chest
local sorcreward = xxxx--Itemid of the item which will the Sorcerer gain
local druidreward = xxxx--Itemid of the item which will the Druid gain
local paladinreward = xxxx--Itemid of the item which will the Paladin gain
local knightreward = xxxx--Itemid of the item which will the Knight gain
-->>>>>>>>>> /CONFIG <<<<<<<<<<--
-->>>>>>>>>> DO NOT EDIT! <<<<<<<<<<--
local vocation = getCreatureVocation(cid)
local sorcerer = 1
local druid = 2
local paladin = 3
local knight = 4
local mastersorcerer = 5
local elderdruid = 6
local royalpaladin = 7
local eliteknight = 8
-->>>>>>>>>> /DO NOT EDIT! <<<<<<<<<<--
	if item.actionid == action then
        	if getPlayerStorageValue(cid,action) == -1 then
            		if vocation == sorcerer or vocation == mastersorcerer then
                		doPlayerAddItem(cid,sorcreward)
                		doPlayerSendTextMessage(cid,25, "You have found a ".. getItemName(sorcreward) ..".")
                		setPlayerStorageValue(cid,action,1)
            		end
        	else
                	doPlayerSendCancel(cid,"You already got your reward!")
        	end
 
	elseif item.actionid == action then
        	if getPlayerStorageValue(cid,action) == -1 then
            		if vocation == druid or vocation == elderdruid then
                		doPlayerAddItem(cid,druidreward)
                		doPlayerSendTextMessage(cid,25, "You have found a ".. getItemName(druidreward) ..".")
                		setPlayerStorageValue(cid,action,1)
            		end
        	else
                	doPlayerSendCancel(cid,"You already got your reward!")
            	end
 
	elseif item.actionid == action then
        	if getPlayerStorageValue(cid,action) == -1 then
            		if vocation == paladin or vocation == royalpaladin then
                		doPlayerAddItem(cid,paladinreward)
                		doPlayerSendTextMessage(cid,25, "You have found a ".. getItemName(paladinreward) ..".")
                		setPlayerStorageValue(cid,action,1)
            		end
        	else
                	doPlayerSendCancel(cid,"You already got your reward!")
        	end
 
	elseif item.actionid == action then
        	if getPlayerStorageValue(cid,action) == -1 then
            		if vocation == knight or vocation == eliteknight then
                		doPlayerAddItem(cid,knightreward)
                		doPlayerSendTextMessage(cid,25, "You have found a ".. getItemName(knightreward) ..".")
                		setPlayerStorageValue(cid,action,1)
            		end
        	else
                	doPlayerSendCancel(cid,"You already got your reward!")
        	end
    	end
end

and put this into actions.xml

PHP:
<action actionid="THEACTIONIDHERE" script="scriptname.lua" />

I hope it works for all, if not leave a msg with the error code :p

yours Evil Hero,
 
Last edited:
vocation is nil, actionid is nil. Texts are bugged

Where is function onUse?
 
Last edited:
Yea you where right forgot the vocation thing added it now onUse is above the locals and explain me why actionid is nil?

Edit: oww yea i where dumb changed the action but forgot to change the actionid into action to :p sorry for that was a noob failure ^^
 
What about this one?
PHP:
--##>> CONFIG <<##-- 
local storageValue = 5464 --## Storage value to be set on the player! ##--

local rewards = { --## Rewards you'll get when you finish the quest! ##--
	sorcerer = {itemid, count},
	druid = {itemid, count},
	paladin = {itemid, count},
	knight = {itemid, count}
}

local vocations = { --## Vocation information! ##--
	sorcerer = {1, 5},
	druid = {2, 6},
	paladin = {3, 7},
	knight = {4, 8}
}
--##>> CONFIG <<##--

function onUse(cid, item, frompos, item2, topos)
	if getPlayerStorageValue(cid, storageValue) == -1 then
		for vocName, vocIds in pairs(vocations) do
			if isVocation(cid, vocIds) then
				doPlayerAddItem(cid, rewards[vocName][1], rewards[vocName][2])
				doPlayerSendTextMessage(cid,25, "You have found a ".. getItemName(rewards[vocName]) ..".")
				setPlayerStorageValue(cid, storageValue, 1)
				return TRUE
			end
		end
	else
		doPlayerSendCancel(cid, "You already got your reward!")
	end
	return TRUE
end

function isVocation(cid, vocs)
	return isInArray(vocs, getPlayerVocation(cid)) == 1
end
 
Last edited:
You know I'm not that advanced in scripting like you :p ofcourse your version is a lot better ^^

btw get online on msn pls i have to talk with you about something :)

yours Evil Hero,
 
upps noticed i already made a post here... ill keep the one i have in the bottom...
 
Last edited:
What about this one?
PHP:
--##>> CONFIG <<##-- 
local storageValue = 5464 --## Storage value to be set on the player! ##--

local rewards = { --## Rewards you'll get when you finish the quest! ##--
	sorcerer = {itemid, count},
	druid = {itemid, count},
	paladin = {itemid, count},
	knight = {itemid, count}
}

local vocations = { --## Vocation information! ##--
	sorcerer = {1, 5},
	druid = {2, 6},
	paladin = {3, 7},
	knight = {4, 8}
}
--##>> CONFIG <<##--

function onUse(cid, item, frompos, item2, topos)
	if getPlayerStorageValue(cid, storageValue) == -1 then
		for vocName, vocIds in pairs(vocations) do
			if isVocation(cid, vocIds) then
				doPlayerAddItem(cid, rewards[vocName][1], rewards[vocName][2])
				doPlayerSendTextMessage(cid,25, "You have found a ".. getItemName(rewards[vocName]) ..".")
				setPlayerStorageValue(cid, storageValue, 1)
				return TRUE
			end
		end
	else
		doPlayerSendCancel(cid, "You already got your reward!")
	end
	return TRUE
end

function isVocation(cid, vocs)
	return isInArray(vocs, getPlayerVocation(cid)) == 1
end


This one works for me, thanks and good job!
 
What about this one?
PHP:
--##>> CONFIG <<##-- 
local storageValue = 5464 --## Storage value to be set on the player! ##--

local rewards = { --## Rewards you'll get when you finish the quest! ##--
	sorcerer = {itemid, count},
	druid = {itemid, count},
	paladin = {itemid, count},
	knight = {itemid, count}
}

local vocations = { --## Vocation information! ##--
	sorcerer = {1, 5},
	druid = {2, 6},
	paladin = {3, 7},
	knight = {4, 8}
}
--##>> CONFIG <<##--

function onUse(cid, item, frompos, item2, topos)
	if getPlayerStorageValue(cid, storageValue) == -1 then
		for vocName, vocIds in pairs(vocations) do
			if isVocation(cid, vocIds) then
				doPlayerAddItem(cid, rewards[vocName][1], rewards[vocName][2])
				doPlayerSendTextMessage(cid,25, "You have found a ".. getItemName(rewards[vocName]) ..".")
				setPlayerStorageValue(cid, storageValue, 1)
				return TRUE
			end
		end
	else
		doPlayerSendCancel(cid, "You already got your reward!")
	end
	return TRUE
end

function isVocation(cid, vocs)
	return isInArray(vocs, getPlayerVocation(cid)) == 1
end


Really nice script :) thank you!

What if i want a knight to obtain 3 weapons? I'm scared to play around with this script :p do i just need to add knight = {"itemid, count"itemid, count"itemid, count"} ?

//Massen
 
Back
Top