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

Solved Chest Problem

EvilSkillz

Back
Joined
Jul 12, 2012
Messages
1,810
Solutions
2
Reaction score
388
Location
Egypt - Cairo
listen
i need a chest change my vocation but depends on rebirth too and lower reb
i made this script
it's works when i click on chest
it's down my rebirth successfully
but the problem it's never change vocation
also it's never give me warning if i'm lower rebirth to use it
it's keep let me make rebirth
i don't need it buy storage cuz i need players use it a lot of time even when they get the rebirth

this is all

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if not isDruid(cid) then
	if getPlayerStorageValue(cid, 31337, 10) then
		doPlayerSetVocation(cid, 2)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your vocation has been changed to druid.")
	else
		doCreatureSetStorage(cid, 31337, 5)
		doRemoveCreature(cid)
		end	
	if getPlayerStorageValue(cid, 31337) < 10 then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "only Vocations with 10 rebirth may use this chest.")
		end
	return true
	end
end
it's works good with lower the rebirth counts the problem it's never change vocation
and never give me the refuse msg
"only Vocations with 10 rebirth may use this chest"

why?
also got this error
Code:
[12/06/2013 18:38:21] GOD Otswe has logged in.

[12/06/2013 18:38:23] [Error - Action Interface] 
[12/06/2013 18:38:24] data/actions/scripts/quests/druidchest.lua:onUse
[12/06/2013 18:38:24] Description: 
[12/06/2013 18:38:24] (luaGetCreatureStorage) Creature not found
[12/06/2013 18:38:24] GOD Otswe has logged out.

[12/06/2013 18:38:24] [Error - Action Interface] 
[12/06/2013 18:38:24] data/actions/scripts/quests/druidchest.lua:onUse
[12/06/2013 18:38:24] Description: 
[12/06/2013 18:38:24] (luaGetCreatureStorage) Creature not found

[12/06/2013 18:38:24] [Error - Action Interface] 
[12/06/2013 18:38:24] data/actions/scripts/quests/druidchest.lua:onUse
[12/06/2013 18:38:24] Description: 
[12/06/2013 18:38:24] data/actions/scripts/quests/druidchest.lua:10: attempt to compare boolean with number
[12/06/2013 18:38:24] stack traceback:
[12/06/2013 18:38:24] 	data/actions/scripts/quests/druidchest.lua:10: in function <data/actions/scripts/quests/druidchest.lua:1>
[12/06/2013 18:38:25] GOD Otswe has logged in.

Code:
[12/06/2013 18:40:39] [Error - Action Interface] 
[12/06/2013 18:40:39] data/actions/scripts/quests/druidchest.lua:onUse
[12/06/2013 18:40:39] Description: 
[12/06/2013 18:40:39] (luaGetCreatureStorage) Creature not found
[12/06/2013 18:40:39] GOD Otswe has logged out.

[12/06/2013 18:40:39] [Error - Action Interface] 
[12/06/2013 18:40:39] data/actions/scripts/quests/druidchest.lua:onUse
[12/06/2013 18:40:39] Description: 
[12/06/2013 18:40:39] (luaGetCreatureStorage) Creature not found

[12/06/2013 18:40:39] [Error - Action Interface] 
[12/06/2013 18:40:39] data/actions/scripts/quests/druidchest.lua:onUse
[12/06/2013 18:40:39] Description: 
[12/06/2013 18:40:39] data/actions/scripts/quests/druidchest.lua:10: attempt to compare boolean with number
[12/06/2013 18:40:39] stack traceback:
[12/06/2013 18:40:39] 	data/actions/scripts/quests/druidchest.lua:10: in function <data/actions/scripts/quests/druidchest.lua:1>
 
Last edited:
Try this:

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(not isPlayer(cid)) then
		return true
	end	
	if not isDruid(cid) then
		if getPlayerStorageValue(cid, 31337) >= 10 then
			doPlayerSetVocation(cid, 2)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your vocation has been changed to druid.")
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "only Vocations with 10 rebirth may use this chest.")
			doCreatureSetStorage(cid, 31337, 5)
			doRemoveCreature(cid)
		end	
	end
	return true
end

This is will work without erros in console and has the following behavior:

- When the player is not a Druid and has the storage value less than 10, he will receive the message, it will set the player storage to 5 and remove the player.
- When the player is not a Druid and has the storage value equal or greater than 10, he will get the vocation changed and receive the message.

Regards,
 
But as your logic you send, he will set the rebirth to 5.

You want it to add more 5 rebirth?

Because everytime that the player click on the chest, the rebirth goes to 5 and never will get 10, so for consequence never will change the vocation.

Try this (adding more 5 rebirth instead of setting):

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(not isPlayer(cid)) then
        return true
    end    
    if not isDruid(cid) then
        if getPlayerStorageValue(cid, 31337) >= 10 then
            doPlayerSetVocation(cid, 2)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your vocation has been changed to druid.")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "only Vocations with 10 rebirth may use this chest.")
			if getPlayerStorageValue(cid, 31337) > -1 then
				local rebirth = getPlayerStorageValue(cid, 31337)
				rebirth = rebirth + 5
				doCreatureSetStorage(cid, 31337, rebirth)
			else	
				doCreatureSetStorage(cid, 31337, 5)
			end	
			doRemoveCreature(cid)
        end    
    end
    return true
end
 
Solved

Solved

Thanks To You psychomen
Rep++
i Edited few things
xD

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(not isPlayer(cid)) then
        return false
    end    
    if not isDruid(cid) then
        if getCreatureStorage(cid, 31337) < 10 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "only Vocations with 10 rebirth may use this chest.")
        end    
        if getCreatureStorage(cid, 31337) >= 10 then
            doPlayerSetVocation(cid, 2)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your vocation has been changed to druid.")
            doCreatureSetStorage(cid, 31337, 5)
            doRemoveCreature(cid)
        end    
    end
    return true
end
Feel Free to use it

Regard Evil Skillz
Special Thanks For psychomen << he Edited my first Script >>
 
Back
Top