• 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.
hmm just tried some random storages and it still says -1 charge, and then if I use it again it says 0 charges, if i use it again it says 1 charge, if i use it again then 2, and then 3, and if i use it again it disappears
 
my bad
i hada put send msg after setting the storages sry
tested
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = {
	noRemove = {SKULL_WHITE, SKULL_YELLOW},
	playerSkull = getCreatureSkullType(cid),
	storage = 30050
}
	if isInArray(v.noRemove, v.playerSkull) then
		doPlayerSendCancel(cid, "You may not remove this kind of skull.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	end
	if getPlayerStorageValue(cid, v.storage) < 3 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(getThingPos(cid), CONST_ME_MAGIC_RED)
		doSendAnimatedText(getThingPos(cid), "POFF!", 180)
		doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
		setPlayerStorageValue(cid, v.storage, getPlayerStorageValue(cid, v.storage)+1)
		doPlayerSendTextMessage(cid, 20, "You have " .. -(getPlayerStorageValue(cid, v.storage)) .. " charges left.")
	elseif getPlayerStorageValue(cid, v.storage) == 3 then
		doRemoveItem(item.uid)
	end
	return true
end
 
Ok so far but is it like this, when I use it, it says 0 charges left, when I use it again it says 1 charge left? ;p

why not like this: if I use it once, then it says "3 charges left" if again "2 charge left" and if again, the skull removes and also the item.
 
yes
replace
Code:
doPlayerSendTextMessage(cid, 20, "You have " .. getPlayerStorageValue(cid, v.storage) - 1 .. " charges left.")
 
change the storage ;S
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = {
	noRemove = {SKULL_WHITE, SKULL_YELLOW},
	playerSkull = getCreatureSkullType(cid),
	storage = 30061
}
	if isInArray(v.noRemove, v.playerSkull) then
		return doPlayerSendCancel(cid, "You may not remove this kind of skull.") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	end
	if getPlayerStorageValue(cid, v.storage) < 3 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(getThingPos(cid), CONST_ME_MAGIC_RED)
		doSendAnimatedText(getThingPos(cid), "POFF!", 180)
		doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
		setPlayerStorageValue(cid, v.storage, getPlayerStorageValue(cid, v.storage)+1)
		doPlayerSendTextMessage(cid, 20, "You have " .. -(getPlayerStorageValue(cid, v.storage)) + 1 .. " charges left.")
	end
	if getPlayerStorageValue(cid, v.storage) == 3 then
		doRemoveItem(item.uid)
		doPlayerSendTextMessage(cid, 20, "You ran out of charges.")
	end
	return true
end
 
Last edited:
03:30 You have -1 charges left.
03:30 You have 0 charges left.
03:30 You have 1 charges left.
03:30 You have 2 charges left.
03:31 You ran out of charges.
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local noRemove = {SKULL_WHITE, SKULL_YELLOW}
local playerSkull = getPlayerSkullType(cid)
local storage = 4003
local t = 3022
local firstUse = 34343
	if getPlayerStorageValue(cid, firstUse) == -1 then
		setPlayerStorageValue(cid, firstUse, 1)
		setPlayerStorageValue(cid, storage, 4)
	end
	if not isInArray(noRemove, playerSkull) and getPlayerStorageValue(cid, firstUse) == 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(getThingPos(cid), CONST_ME_MAGIC_RED)
		doSendAnimatedText(getThingPos(cid), "POFF!", 180)
		doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
		setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage)-1)
		setPlayerStorageValue(cid, t, getPlayerStorageValue(cid, t)+1)
		doPlayerSendTextMessage(cid, 20, "You have " .. getPlayerStorageValue(cid, storage) .. " charges left.")
	else
		doPlayerSendCancel(cid, "You may not remove this kind of skull.")
	end
	if getPlayerStorageValue(cid, t) == 3 then
		doRemoveItem(item.uid)
		doPlayerSendTextMessage(cid, 20, "You ran out of charges.")
	end
	return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local noRemove = {SKULL_WHITE, SKULL_YELLOW}
local action = 5000
local charges = 3

	if not getItemAttribute(item.uid, "aid") then
		doItemSetAttribute(item.uid, "aid", action)
	end
	
	if not isInArray(noRemove, getPlayerSkullType(cid)) 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(getThingPos(cid), CONST_ME_MAGIC_RED)
		doSendAnimatedText(getThingPos(cid), "POFF!", 180)
		doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
		doItemSetAttribute(item.uid, "aid", getItemAttribute(item.uid, "aid")-1)
		doPlayerSendTextMessage(cid, 20, "You have " .. getItemAttribute(item.uid, "aid")-action+charges .. " charges left.")
	else
		doPlayerSendCancel(cid, "You may not remove this kind of skull.")
	end
	
	if getItemAttribute(item.uid, "aid") == action-charges then
		doRemoveItem(item.uid, 1)
		doPlayerSendTextMessage(cid, 20, "You ran out of charges.")
	end
	return true
end
 
Can't see why it won't work, you can give this a try but I don't think it will make any difference.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local noRemove = {SKULL_WHITE, SKULL_YELLOW}
local action = 5000
local charges = 3

	if not getItemAttribute(item.uid, "aid") then
		doItemSetAttribute(item.uid, "aid", action)
	end
	
	if not isInArray(noRemove, getCreatureSkullType(cid)) 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(getThingPos(cid), CONST_ME_MAGIC_RED)
		doSendAnimatedText(getThingPos(cid), "POFF!", 180)
		doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
		doItemSetAttribute(item.uid, "aid", getItemAttribute(item.uid, "aid")-1)
		doPlayerSendTextMessage(cid, 20, "You have " .. getItemAttribute(item.uid, "aid")-action+charges .. " charges left.")
	else
		doPlayerSendCancel(cid, "You may not remove this kind of skull.")
	end
	
	if getItemAttribute(item.uid, "aid") == action-charges then
		doRemoveItem(item.uid, 1)
		doPlayerSendTextMessage(cid, 20, "You ran out of charges.")
	end
	return true
end
 
Last edited:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local noRemove = {SKULL_RED, SKULL_BLACK}
local playerSkull = getPlayerSkullType(cid)
local storage = 4003
local t = 3022
local firstUse = 34343
	if getPlayerStorageValue(cid, firstUse) == -1 then
		setPlayerStorageValue(cid, firstUse, 1)
		setPlayerStorageValue(cid, storage, 4)
	end
	if isInArray(noRemove, playerSkull) and getPlayerStorageValue(cid, firstUse) == 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(getThingPos(cid), CONST_ME_MAGIC_RED)
		doSendAnimatedText(getThingPos(cid), "POFF!", 180)
		doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
		setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage)-1)
		setPlayerStorageValue(cid, t, getPlayerStorageValue(cid, t)+1)
		doPlayerSendTextMessage(cid, 20, "You have " .. getPlayerStorageValue(cid, storage) .. " charges left.")
	else
		doPlayerSendCancel(cid, "You may not remove this kind of skull.")
	end
	if getPlayerStorageValue(cid, t) == 3 then
		doRemoveItem(item.uid)
		doPlayerSendTextMessage(cid, 20, "You ran out of charges.")
	end
	return true
end
 
@up

thanks, but, when I don't have a skull and click on it, it says "You may not remove this kind of skull" and "You ran out of charges" and then the item disappears :eek:
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local action = 5000
local charges = 3

	if not getItemAttribute(item.uid, "aid") then
		doItemSetAttribute(item.uid, "aid", action)
	end
	
	if getCreatureSkullType(cid) < 4 and getCreatureSkullType(cid) > 0 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(getThingPos(cid), CONST_ME_MAGIC_RED)
		doSendAnimatedText(getThingPos(cid), "POFF!", 180)
		doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
		doItemSetAttribute(item.uid, "aid", getItemAttribute(item.uid, "aid")-1)
		doPlayerSendTextMessage(cid, 20, "You have " .. getItemAttribute(item.uid, "aid")-action+charges .. " charges left.")
	else
		doPlayerSendCancel(cid, "You may not remove this kind of skull.")
	end
	
	if getItemAttribute(item.uid, "aid") == action-charges then
		doRemoveItem(item.uid, 1)
		doPlayerSendTextMessage(cid, 20, "You ran out of charges.")
	end
	return true
end
 
Last edited:
Hmm, still the same problem, even if I don't have a skull I can still click the item ;s

everything else is fine, the "countdown", and the item disappears after I've clicked 3 times :p
 
Status
Not open for further replies.
Back
Top