• 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 Need Explain & Help

EvilSkillz

Back
Joined
Jul 12, 2012
Messages
1,811
Solutions
2
Reaction score
390
Location
Egypt - Cairo
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isSorcerer(cid) then -- is sorcerer [it will allow master sorcerers too, to allow sorcs only use [[if getPlayerVocation(cid) == 1 then ]].]
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your vocation has been changed to druid.")
		doPlayerSetVocation(cid, 2) -- change voc to druid
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "only sorcerers may use this chest.")
	end
	return true
end

i have this script up
as u see it's to change vocation from sorcerer to druid
but can i ask for something
i need box change from any vocation to druid
Example . ' . 1 Box if u are Sorcerer - Knight - Paladin you can be druid when click on box

and also something
u need to have xxx storage to click in box and when u change ur voc u will lose some of ur storage

like if storage 500 it's will be 200

Regards Evil Skillz
 
Last edited by a moderator:
Then use or.
LUA:
if isSorcerer(cid) or isKnight(cid) or isPaladin(cid) then
Alternatively, you could also use isInArray and search through a list of vocation IDs.

Use storage check outside the vocation check.
So, it'd be something like this then:
LUA:
if getCreatureStorage(cid, XXX) dowhichevercheckyouwant then
	if isSorcerer(cid) or isKnight(cid) or isPaladin(cid) then
Then if successful, inside that, use:
LUA:
doSetCreatureStorage(cid, XXX, anyvalueyouneed)
 
Then use or.
LUA:
if isSorcerer(cid) or isKnight(cid) or isPaladin(cid) then
Alternatively, you could also use isInArray and search through a list of vocation IDs.

Use storage check outside the vocation check.
So, it'd be something like this then:
LUA:
if getCreatureStorage(cid, XXX) dowhichevercheckyouwant then
	if isSorcerer(cid) or isKnight(cid) or isPaladin(cid) then
Then if successful, inside that, use:
LUA:
doSetCreatureStorage(cid, XXX, anyvalueyouneed)

I'm not very well informed when it comes to TFS yet, but to shorten the code and make it more attractive, use:

LUA:
if not isDruid(cid) then

Full code should be sometihng like:

LUA:
storage = 400
if not isDruid(cid) then
	if getCreatureStorage(cid, storage) then
		doSetCreatureStorage(cid, storage-200)
	end
end

Not sure though, I haven't checked the function params yet
 
Last edited:
but u don't understand what i mean
listen i have this storage 12345 it's 400 and u are any vocation
if u click in box ur vocation will change to any vocation and storage of 12345 will be 200
also the box will have another storage but i don't need it cuz i need players change vocations alot of time if they want
xD
 
but u don't understand what i mean
listen i have this storage 12345 it's 400 and u are any vocation
if u click in box ur vocation will change to any vocation and storage of 12345 will be 200
also the box will have another storage but i don't need it cuz i need players change vocations alot of time if they want
xD

Yeah, you're right, I don't understand, can you explain step by step?


Also, can you fetch the function list for me? I can't find it.
 
Look guys i have passed it but i got only one error it's changed my vocation success
but the problem in rebirth count
this is my script
LUA:
local str = 85987
local rebirth = 10


function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureStorage(cid, str) >= rebirth then
	if not isKnight(cid) then
		doPlayerSetVocation(cid, 4)
		doSetCreatureStorage(cid, rebirth, 5)
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "only Vocations with 10 Rebirth may use this chest.")
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your vocation has been changed to sorcerer.")
		doRemoveCreature(cid)
	end
	end
	return true
end

and this is the error
11/06/2013 17:18:02] [Error - Action Interface]
[11/06/2013 17:18:02] data/actions/scripts/other/chest.lua:onUse
[11/06/2013 17:18:02] Description:
[11/06/2013 17:18:02] data/actions/scripts/other/chest.lua:9: attempt to call global 'doSetCreatureStorage' (a nil value)
[11/06/2013 17:18:02] stack traceback:
[11/06/2013 17:18:02] data/actions/scripts/other/chest.lua:9: in function <data/actions/scripts/other/chest.lua:5>
[11/06/2013 17:18:02] Wizava has logged out.
[11/06/2013 17:18:04] Wizava has logged in.

- - - Updated - - -

updated
it's allow me to press on it again even if i'm knight looooool
wtf it this error?

19eibh


- - - Updated - - -

ATTACH]
 

Attachments

Last edited:
Back
Top