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

Checking storage in script

Sorbal

Member
Joined
Jul 23, 2010
Messages
406
Reaction score
11
Location
Poland
Hello Otlanders, i need support from You.. I have this script:
PHP:
function onUse(cid, item, frompos, item2, topos)
    if (getPlayerPromotionLevel(cid) == 0) then
        doPlayerSetPromotionLevel(cid, 1)
		doRemoveItem(item.uid, 1)
		doCreatureSay(cid, "Congratulations! You promoted!", TALKTYPE_ORANGE_1)
		doSendMagicEffect(getPlayerPosition(cid), 49)
    else
		doPlayerSendCancel(cid, "You are already promoted or you don't have vip account")
    end
	return true
end
and i want to this script checks
PHP:
getPlayerStorageValue(cid,11552)
before the script give us promotion. Thanks ^_^
 
PHP:
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid,11552) == 1 then
    if (getPlayerPromotionLevel(cid) == 0) then
        doPlayerSetPromotionLevel(cid, 1)
        doRemoveItem(item.uid, 1)
        doCreatureSay(cid, "Congratulations! You promoted!", TALKTYPE_ORANGE_1)
        doSendMagicEffect(getPlayerPosition(cid), 49)
    else
        doPlayerSendCancel(cid, "You are already promoted or you don't have vip account")
    end
	end
    return true
end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerPromotionLevel(cid) > 0) then
		doPlayerSendCancel(cid, "You are already promoted.")
	end
	
	if(getPlayerStorageValue(cid, 11552) < 1) then
		doPlayerSendCancel(cid, "You are not a VIP member.")
	end
	
	doRemoveItem(item.uid, 1)
	doPlayerSetPromotionLevel(cid, 1)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(cid, "Congratulations! You have been promoted.", TALKTYPE_MONSTER)
	return true
end
 
~J.Dre
Not working, i can use it while im already promoted and while i don't have StorageValue=11552. There is no errors in console.

Also im using TFS 0.3.6
 
Sorbal, how does a player obtain the value for their storage value at 11552? (As in, is it from a quest? An NPC? Etc.) And what value should they have?
 
J.Dre, one misstake. The storagevalue should check if the storage is under 0, not under 1..
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerPromotionLevel(cid) > 0) then
		doPlayerSendCancel(cid, "You are already promoted.")
	end
 
	if(getPlayerStorageValue(cid, 11552) [COLOR="#FF0000"]< 0[/COLOR]) then
		doPlayerSendCancel(cid, "You are not a VIP member.")
	end
 
	doRemoveItem(item.uid, 1)
	doPlayerSetPromotionLevel(cid, 1)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(cid, "Congratulations! You have been promoted.", TALKTYPE_MONSTER)
	return true
end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local s = 11552
	if(getPlayerPromotionLevel(cid) == 0) then
		if(getPlayerStorageValue(cid, s) < 0) then
			setPlayerStorageValue(cid, s, 1)
			doPlayerSetPromotionLevel(cid, 1)
			doRemoveItem(item.uid, 1)
			doCreatureSay(cid, "Congratulations! You promoted!", TALKTYPE_ORANGE_1)
			doSendMagicEffect(getPlayerPosition(cid), 49)
		else
			doPlayerSendCancel(cid, "You are not a VIP member.")
		end
	else
		doPlayerSendCancel(cid, "You are already promoted.")
	end
	return true
end

This works. If this aint work then you have to test it with another character. Your current character may be bugged.
 
You got your promotion? becouse thats the point. - "You are already promoted" when you have used it once. You want it to have unlimited uses?
 
No i want to player can use this item while he have vip account (StoragaValue=11552) and he isn't already promoted. If he use this item without vip account, text "You don't have vip account" will appear, else if he have vip account and he is already promoted, he will see "You are already promoted". Thats what i want :D
 
Last edited:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local s = 11552
	if(getPlayerPromotionLevel(cid) == 0) then
		if(getPlayerStorageValue(cid, s) >= 1) then
			doPlayerSetPromotionLevel(cid, 1)
			doRemoveItem(item.uid, 1)
			doCreatureSay(cid, "Congratulations! You promoted!", TALKTYPE_ORANGE_1)
			doSendMagicEffect(getPlayerPosition(cid), 49)
		else
			doPlayerSendCancel(cid, "You are not a VIP member.")
		end
	else
		doPlayerSendCancel(cid, "You are already promoted.")
	end
	return true
end
This should work.
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerPromotionLevel(cid) > 0) and getPlayerStorageValue(uid, 11552)+1 then
		doPlayerSendCancel(cid, "You are already promoted.")
	else
	doRemoveItem(item.uid, 1)
	doPlayerSetPromotionLevel(cid, 1)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
	doCreatureSay(cid, "Congratulations! You have been promoted.", TALKTYPE_ORANGE_1)
	return true
	end
end
 

Similar threads

Back
Top