• 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 Very simple action script not working

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,018
Solutions
1
Reaction score
1,040
Location
United States
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local itemID = 6500
local count = getPlayerItemCount(cid, itemID)
	if isPlayer(cid) and count >= 500 and getPlayerStorageValue(cid, 57388) == -1 then
		doSendMagicEffect(fromPosition, 13)
		setPlayerStorageValue(cid, 57388, 1)
		doPlayerRemoveItem(cid, itemID, 500)
		doCreatureSay(cid, "You have sacrificed 500 essences.", TALKTYPE_ORANGE_1)
		else
		doSendMagicEffect(fromPosition, 2)
	end
	return true
end

When I click something in-game, it is supposed to delete 500 demonic essences.
But, I think it's the counting that is wrong. No error in console or anything.
 
Maybe this???
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local itemID = 6500
	if isPlayer(cid) and doPlayerRemoveItem(cid, itemID, 500) and getPlayerStorageValue(cid, 57388) == -1 then
		doSendMagicEffect(fromPosition, 13)
		setPlayerStorageValue(cid, 57388, 1)
		doCreatureSay(cid, "You have sacrificed 500 essences.", TALKTYPE_ORANGE_1)
		else
		doSendMagicEffect(fromPosition, 2)
	end
	return true
end
 
This should work just fine.

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureStorage(cid, 57388) < 0 then
		if doPlayerRemoveItem(cid, 6500, 500) then
			doCreatureSetStorage(cid, 57388, 1)
			doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
			doCreatureSay(cid, "You have sacrificed 500 Demonic Essences!", TALKTYPE_MONSTER)
		else
			doPlayerSendCancel(cid, "You do not have enough Demonic Essences.")
		end
	else
		doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	return true
end
 
Last edited:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getCreatureStorage(cid, 57388) < 0 then
		if doPlayerRemoveItem(cid, 6500, 500) then
			doCreatureSetStorage(cid, 57388, 1)
			doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
			doCreatureSay(cid, "You have sacrificed 500 Demonic Essences!", TALKTYPE_MONSTER)
		else
			doPlayerSendCancel(cid, "You do not have enough Demonic Essences.")
		end
	else
		doPlayerSendCancel(cid, "You can only do it once.")
	end
	return true
end

This is the script J.Dre made but modified.. think it will work better.. cause otherwise it will take 500 demonic essences everytime you use it and it won't change anything..
 
This is the script J.Dre made but modified.. think it will work better.. cause otherwise it will take 500 demonic essences everytime you use it and it won't change anything..

Hm, yes I should have put the storage check first. I have edited my post.

J.Dre
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local itemID = 6500

	if isPlayer(cid) == TRUE then
		if getPlayerStorageValue(cid, 57388) < 0 then
			if (doPlayerRemoveItem(cid, 2159, 50) == TRUE) then
				doSendMagicEffect(fromPosition, 13)
				setPlayerStorageValue(cid, 57388, 1)
				doCreatureSay(cid, "You have sacrificed 500 essences.", TALKTYPE_ORANGE_1)
			else
				doPlayerSendCancel(cid, "You don't have the item.") 
				doSendMagicEffect(fromPosition, 2)
			end
		else
			doPlayerSendCancel(cid, "You already have that storage value.") 
			doSendMagicEffect(fromPosition, 2)
		end
	end
	return true
end
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local itemID = 6500

	if isPlayer(cid) == TRUE then
		if getPlayerStorageValue(cid, 57388) < 0 then
			if (doPlayerRemoveItem(cid, 2159, 50) == TRUE) then
				doSendMagicEffect(fromPosition, 13)
				setPlayerStorageValue(cid, 57388, 1)
				doCreatureSay(cid, "You have sacrificed 500 essences.", TALKTYPE_ORANGE_1)
			else
				doPlayerSendCancel(cid, "You don't have the item.") 
				doSendMagicEffect(fromPosition, 2)
			end
		else
			doPlayerSendCancel(cid, "You already have that storage value.") 
			doSendMagicEffect(fromPosition, 2)
		end
	end
	return true
end

God dammit man.. guy already said "Working thanks" >_> xD
 
Back
Top