• 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.
But does it get removed when you use it 3 times?

EDIT;
Maybe found what's wrong:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local cfg = {
		noRemove = {SKULL_WHITE, SKULL_YELLOW},
		playerSkull = getCreatureSkullType(cid),
		storage = 123456,
		charges = 3,
		charge_storage = 234567,
		message_type = MESSAGE_INFO_DESCR,
			}

if getPlayerStorageValue(cid, cfg.charge_storage) == -1 or getPlayerStorageValue(cid, cfg.charge_storage) == 0 then
	setPlayerStorageValue(cid, cfg.charge_storage, charges)
end
	if getPlayerStorageValue(cid, cfg.storage) == -1 then
		setPlayerStorageValue(cid, cfg.storage, 0)
	end
	
		if getPlayerStorageValue(cid, cfg.storage) == cfg.charges then
			doPlayerRemoveItem(cid, item.uid, 1)
			setPlayerStorageValue(cid, cfg.storage, 0)
		end
	
			if isInArray(cfg.noRemove, cfg.playerSkull) then
				doPlayerSendCancel(cid, "You can't remove this type of skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			end
	
				if cfg.playerSkull == SKULL_NONE then
					doPlayerSendCancel(cid, "You don't have skull.")
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				end
	
					if getPlayerStorageValue(cid, cfg.storage) <= cfg.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, cfg.storage, getPlayerStorageValue(cid, cfg.storage)+1)
						setPlayerStorageValue(cid, cfg.charge_storage, getPlayerStorageValue(cid, cfg.charge_storage)-1)
						doPlayerSendTextMessage(cid, 27, "Your frags & your skull have been removed! You have " .. getPlayerStorageValue(cid, cfg.charge_storage) .. " charges left.")
					else
						doPlayerSendCancel(cid, "Something is wrong")
					end
return true
end
 
Hmm
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local cfg = {
		noRemove = {SKULL_WHITE, SKULL_YELLOW},
		playerSkull = getCreatureSkullType(cid),
		storage = 123456,
		charges = 3,
		charge_storage = 234567,
		message_type = MESSAGE_INFO_DESCR,
			}

	if getPlayerStorageValue(cid, cfg.charge_storage) == -1 or getPlayerStorageValue(cid, cfg.charge_storage) == 0 then
		setPlayerStorageValue(cid, cfg.charge_storage, charges)
	end
		if getPlayerStorageValue(cid, cfg.storage) == -1 then
			setPlayerStorageValue(cid, cfg.storage, 0)
		end
	
			if isInArray(cfg.noRemove, cfg.playerSkull) then
				doPlayerSendCancel(cid, "You can't remove this type of skull.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			end
	
				if cfg.playerSkull == SKULL_NONE then
					doPlayerSendCancel(cid, "You don't have skull.")
					doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				end
	
					if getPlayerStorageValue(cid, cfg.storage) <= cfg.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, cfg.storage, getPlayerStorageValue(cid, cfg.storage)+1)
						setPlayerStorageValue(cid, cfg.charge_storage, getPlayerStorageValue(cid, cfg.charge_storage)-1)
						doPlayerSendTextMessage(cid, 27, "Your frags & your skull have been removed! You have " .. getPlayerStorageValue(cid, cfg.charge_storage) .. " charges left.")
					
					elseif getPlayerStorageValue(cid, cfg.storage) == cfg.charges then
						doPlayerRemoveItem(cid, item.uid, 1)
						setPlayerStorageValue(cid, cfg.storage, 0)
					end
return true
end
damn I'm just changing some random shit right now xD
 
Try:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
  local noRemove = {SKULL_WHITE, SKULL_YELLOW}
    local playerSkull = getCreatureSkullType(cid)
    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
    else
      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))
    end
    local aidd = {
          min = 10901,
          max = 10903
    }
     if item.actionid < aidd.min then
        doItemSetAttribute(item.uid, "aid", aidd.min)
     elseif item.actionid >= aidd.min and item.actionid <= aidd.max then
            doItemSetAttribute(item.uid, "aid", getItemAttribute(item.uid, "aid")+1)
     elseif item.actionid >= aidd.max then
            doRemoveItem(item.uid)
     return TRUE
     end
     return true
end
 
Lua:
  function onUse(cid, item, fromPosition, itemEx, toPosition)
  local noRemove = {SKULL_WHITE, SKULL_YELLOW}
    local playerSkull = getCreatureSkullType(cid)
    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
    else
      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 " .. aidd.max - aidd.min .. " charges left.")
      doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
      doSendAnimatedText(getPlayerPosition(cid), "POFF!", 180)
      doPlayerSetSkullEnd(cid, 0, getPlayerSkullType(cid))
    end
    local aidd = {
          min = 10901,
          max = 10903
    }
     if item.actionid < aidd.min then
        doItemSetAttribute(item.uid, "aid", aidd.min)
     elseif item.actionid >= aidd.min and item.actionid <= aidd.max then
            doItemSetAttribute(item.uid, "aid", getItemAttribute(item.uid, "aid")+1)
     elseif item.actionid >= aidd.max then
            doRemoveItem(item.uid)
     return TRUE
     end
     return true
end
I think
 
this should work
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = {
	noRemove = {SKULL_WHITE, SKULL_YELLOW},
	playerSkull = getCreatureSkullType(cid),
	storage = 30000
}
	if getPlayerStorageValue(cid, v.storage) < 3 or isInArray(v.noRemove, v.playerSkull) then
		doPlayerSendCancel(cid, "You may not remove " .. v.playerSkull .. " skull.")
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	elseif 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!")
		doPlayerSendTextMessage(cid, 20, "You have - " .. getPlayerStorageValue(cid, v.storage) .. " charges left.")
		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)
	end
	if getPlayerStorageValue(cid, v.storage) == 3 then
		doRemoveItem(item.uid)
	end
	return true
end
 
Last edited:
about:

Code:
doPlayerSendCancel(cid, "You may not use this one more time.")

we maybe misunderstood each other but after the three charges is done, then the skull should disappear, but if they get the skull (the item - black skull) again they can use it


or maybe that's not possible to make? :eek: (now that I wrote it like that..)
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = {
	noRemove = {SKULL_WHITE, SKULL_YELLOW},
	playerSkull = getCreatureSkullType(cid),
	storage = 30001
}
	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!")
		doPlayerSendTextMessage(cid, 20, "You have " .. getPlayerStorageValue(cid, v.storage) .. " charges left.")
		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)
	elseif getPlayerStorageValue(cid, v.storage) == 3 then
		doRemoveItem(item.uid)
	end
	return true
end
 
Status
Not open for further replies.
Back
Top