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

Adding three charges to this

Status
Not open for further replies.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local noRemove = {SKULL_WHITE, SKULL_YELLOW}
	local playerSkull = getCreatureSkullType(cid)
	local storage = 123456
	local charges = 5
	
	if getPlayerStorageValue(cid, storage) < 0 then
		setPlayerStorageValue(cid, storage, 0)
	return true
	
		if getPlayerStorageValue(cid, storage) == 5 then
			doPlayerRemoveItem(cid, item.uid, 1)
			setPlayerStorageValue(cid, storage, 0)
		end
	
			if isInArray(noRemove, playerSkull) then
				doPlayerSendCancel(cid, "You can't remove this type of skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
	
			elseif playerSkull == SKULL_NONE then
				doPlayerSendCancel(cid, "You don't have skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
	
			elseif getPlayerStorageValue(cid, storage) <= charges and getPlayerStorageValue(cid, storage) >= 1 then
				db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
				doCreatureSetSkullType(cid,0)
				doPlayerSendTextMessage(cid, 27, "Your frags & your skull have been removed!")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				doSendAnimatedText(getPlayerPosition(cid), "POFF!", 180)
				doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
				setPlayerStorageValue(cid, getPlayerStorageValue(cid, storage)+1)
			end
		end
	end
return true
end
Dunno if it works xD I was kinda confused when I made it because friends screaming in skype :p

EDIT; Shouldn't SKULL_GREEN be there too?
 
doRemoveItem(item.uid) ??

just make sure that this item has 'charges'-like runes.

(i know that i can be done by storage value or AID)

EDIT: @Slaktaren - just few seconds xD
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local noRemove = {SKULL_WHITE, SKULL_YELLOW}
	local playerSkull = getCreatureSkullType(cid)
	local storage = 123456
	local charges = 5
	
	if getPlayerStorageValue(cid, storage) < 0 then
		setPlayerStorageValue(cid, storage, 0)
	return true
	
		if getPlayerStorageValue(cid, storage) == 5 then
			doPlayerRemoveItem(cid, item.uid, 1)
			setPlayerStorageValue(cid, storage, 0)
		end
	
			if isInArray(noRemove, playerSkull) then
				doPlayerSendCancel(cid, "You can't remove this type of skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
	
			elseif playerSkull == SKULL_NONE then
				doPlayerSendCancel(cid, "You don't have skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
	
			elseif getPlayerStorageValue(cid, storage) <= charges and getPlayerStorageValue(cid, storage) >= 1 then
				db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
				doCreatureSetSkullType(cid,0)
				doPlayerSendTextMessage(cid, 27, "Your frags & your skull have been removed!")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				doSendAnimatedText(getPlayerPosition(cid), "POFF!", 180)
				doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
				setPlayerStorageValue(cid, getPlayerStorageValue(cid, storage)+1)
			end
		end
	end
return true
end
Dunno if it works xD I was kinda confused when I made it because friends screaming in skype :p

EDIT; Shouldn't SKULL_GREEN be there too?

ill try it out, thanks

edit:

I haven't tested but, let's say I use the item ONCE, then it says "the item has 2 charges left." and if I use it again it says "the item has one charge left."

cud u fix that?


thanks
 
ye here(I think):
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local noRemove = {SKULL_WHITE, SKULL_YELLOW}
	local playerSkull = getCreatureSkullType(cid)
	local storage = 123456
	local charges = 3
	local message_type = MESSAGE_INFO_DESCR
	
	if getPlayerStorageValue(cid, storage) < 0 then
		setPlayerStorageValue(cid, storage, 0)
	return true
	
		if getPlayerStorageValue(cid, storage) == charges then
			doPlayerRemoveItem(cid, item.uid, 1)
			setPlayerStorageValue(cid, storage, 0)
		end
	
			if isInArray(noRemove, playerSkull) then
				doPlayerSendCancel(cid, "You can't remove this type of skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
	
			elseif playerSkull == SKULL_NONE then
				doPlayerSendCancel(cid, "You don't have skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
	
			elseif getPlayerStorageValue(cid, storage) <= charges and getPlayerStorageValue(cid, storage) >= 1 then
				db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
				doCreatureSetSkullType(cid,0)
				doPlayerSendTextMessage(cid, 27, "Your frags & your skull have been removed! You have " .. getPlayerStorageValue(cid, storage) .. " charges left.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				doSendAnimatedText(getPlayerPosition(cid), "POFF!", 180)
				doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
				setPlayerStorageValue(cid, getPlayerStorageValue(cid, storage)+1)
			end
		end
	end
return true
end
 
Last edited:
Any errors in console?

EDIT;
Test this
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local noRemove = {SKULL_WHITE, SKULL_YELLOW}
	local playerSkull = getCreatureSkullType(cid)
	local storage = 123456
	local charges = 3
	local message_type = MESSAGE_INFO_DESCR
	
	if getPlayerStorageValue(cid, storage) < 0 then
		setPlayerStorageValue(cid, storage, 0)
	return true
	
		elseif getPlayerStorageValue(cid, storage) == charges then
			doPlayerRemoveItem(cid, item.uid, 1)
			setPlayerStorageValue(cid, storage, 0)
		return true
	
			elseif isInArray(noRemove, playerSkull) then
				doPlayerSendCancel(cid, "You can't remove this type of skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
	
			elseif playerSkull == SKULL_NONE then
				doPlayerSendCancel(cid, "You don't have skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
	
			elseif getPlayerStorageValue(cid, storage) <= charges and getPlayerStorageValue(cid, storage) >= 1 then
				db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
				doCreatureSetSkullType(cid,0)
				doPlayerSendTextMessage(cid, 27, "Your frags & your skull have been removed! You have " .. getPlayerStorageValue(cid, storage) .. " charges left.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
				doSendAnimatedText(getPlayerPosition(cid), "POFF!", 180)
				doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
				setPlayerStorageValue(cid, getPlayerStorageValue(cid, storage)+1)
	end
return true
end
 
[1:34:30.929] [Error - LuaInterface::loadFile] data/actions/scripts/other/fremov
e.lua:12: 'end' expected (to close 'if' at line 8) near 'if'
[1:34:30.929] [Warning - Event::loadScript] Cannot load script (data/actions/scr
ipts/other/fremove.lua)
[1:34:30.929] data/actions/scripts/other/fremove.lua:12: 'end' expected (to clos
e 'if' at line 8) near 'if'

in my console
 
Test this xD
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local noRemove = {SKULL_WHITE, SKULL_YELLOW}
	local playerSkull = getCreatureSkullType(cid)
	local storage = 123456
	local charges = 3
	local message_type = MESSAGE_INFO_DESCR
	
	if getPlayerStorageValue(cid, storage) < 0 then
		setPlayerStorageValue(cid, storage, 0)
	return true
	
		if getPlayerStorageValue(cid, storage) == charges then
			doPlayerRemoveItem(cid, item.uid, 1)
			setPlayerStorageValue(cid, storage, 0)
		return true
	
			if isInArray(noRemove, playerSkull) then
				doPlayerSendCancel(cid, "You can't remove this type of skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			return true
	
				if playerSkull == SKULL_NONE then
					doPlayerSendCancel(cid, "You don't have skull.")
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				return true
	
					if getPlayerStorageValue(cid, storage) <= charges then
						db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
						doCreatureSetSkullType(cid,0)
						doPlayerSendTextMessage(cid, 27, "Your frags & your skull have been removed! You have " .. getPlayerStorageValue(cid, storage) .. " charges left.")
						doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
						doSendAnimatedText(getPlayerPosition(cid), "POFF!", 180)
						doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
						setPlayerStorageValue(cid, getPlayerStorageValue(cid, storage)+1)
					else
						doPlayerSendCancel(cid, "Something is wrong")
					end
				end
			end
		end
	end
return true
end
 
doesn't work

[1:43:21.428] [Error - LuaInterface::loadFile] data/actions/scripts/other/fremov
e.lua:12: 'end' expected (to close 'if' at line 8) near 'if'
[1:43:21.428] [Warning - Event::loadScript] Cannot load script (data/actions/scr
ipts/other/fremove.lua)
[1:43:21.428] data/actions/scripts/other/fremove.lua:12: 'end' expected (to clos
e 'if' at line 8) near 'if'

in console
 
It's not even an "end" on line 12..
Are you sure you copied the new and reloaded actions?

EDIT; else test this..
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local noRemove = {SKULL_WHITE, SKULL_YELLOW}
	local playerSkull = getCreatureSkullType(cid)
	local storage = 123456
	local charges = 3
	local message_type = MESSAGE_INFO_DESCR
	
	if getPlayerStorageValue(cid, storage) < 0 then
		setPlayerStorageValue(cid, storage, 0)
	end
	
		if getPlayerStorageValue(cid, storage) == charges then
			doPlayerRemoveItem(cid, item.uid, 1)
			setPlayerStorageValue(cid, storage, 0)
		end
	
			if isInArray(noRemove, playerSkull) then
				doPlayerSendCancel(cid, "You can't remove this type of skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			end
	
				if playerSkull == SKULL_NONE then
					doPlayerSendCancel(cid, "You don't have skull.")
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				end
	
					if getPlayerStorageValue(cid, storage) <= charges then
						db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
						doCreatureSetSkullType(cid,0)
						doPlayerSendTextMessage(cid, 27, "Your frags & your skull have been removed! You have " .. getPlayerStorageValue(cid, storage) .. " charges left.")
						doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
						doSendAnimatedText(getPlayerPosition(cid), "POFF!", 180)
						doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
						setPlayerStorageValue(cid, getPlayerStorageValue(cid, storage)+1)
					else
						doPlayerSendCancel(cid, "Something is wrong")
					end
return true
end
 
hmm.

It works, it removes my skull but the first time I use it this text appears:

01:52 Your frags & your skull have been removed! You have 0 charges left.

Shouldn't I have 2 charges? :p

and the item doesnt disappear
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local noRemove = {SKULL_WHITE, SKULL_YELLOW}
	local playerSkull = getCreatureSkullType(cid)
	local storage = 123456
	local charges = 3
	local charge_storage = 234567
	local message_type = MESSAGE_INFO_DESCR

if getPlayerStorageValue(cid, charge_storage) == -1 or getPlayerStorageValue(cid, charge_storage) == 0 then
	setPlayerStorageValue(cid, charge_storage, charges)
end
	if getPlayerStorageValue(cid, storage) == -1 then
		setPlayerStorageValue(cid, storage, 0)
	end
	
		if getPlayerStorageValue(cid, storage) == charges then
			doPlayerRemoveItem(cid, item.uid, 1)
			setPlayerStorageValue(cid, storage, 0)
		end
	
			if isInArray(noRemove, playerSkull) then
				doPlayerSendCancel(cid, "You can't remove this type of skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			end
	
				if playerSkull == SKULL_NONE then
					doPlayerSendCancel(cid, "You don't have skull.")
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				end
	
					if getPlayerStorageValue(cid, storage) <= charges then
						db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
						doCreatureSetSkullType(cid,0)
						doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
						doSendAnimatedText(getPlayerPosition(cid), "POFF!", 180)
						doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
						setPlayerStorageValue(cid, getPlayerStorageValue(cid, storage)+1)
						setPlayerStorageValue(cid, getPlayerStorageValue(cid, charge_storage)-1)
						doPlayerSendTextMessage(cid, 27, "Your frags & your skull have been removed! You have " .. getPlayerStorageValue(cid, charge_storage) .. " charges left.")
					else
						doPlayerSendCancel(cid, "Something is wrong")
					end
return true
end
test now...
 
Last edited:
Status
Not open for further replies.
Back
Top