• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved item that you can only use once? :) pls help

Cris2387

Member
Joined
Dec 30, 2013
Messages
177
Reaction score
9
hi, so i made an item that gives you life and mana and heals you, you dont have to do it yourself :) but before i put it in my server i want to make sure that the item is only usable once so if the person uses the item, the person cant use the item again ( if he gets another one hehe ) this is the script that according to me was going to work but didnt :(
Code:
function onUse(cid, item)
if getPlayerStorageValue(cid,13503) < 1 then
  local health = 50000
   local mana = 50000
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + health)
setCreatureMaxMana(cid, getCreatureMaxMana(cid) + mana)
doCreatureAddHealth(cid,999999999)
doCreatureAddMana(cid,999999999)
  doCreatureSay(cid, "You gained 50k of life & mana, now your health is ".. getCreatureMaxHealth(cid) ..", and your mana is ".. getCreatureMaxMana(cid) .."!" ,19)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_RED)
doRemoveItem(item.uid)
setPlayerStorageValue(cid,13503)
elseif getPlayerStorageValue(cid,13503) > 1 then
doPlayerSendTextMessage(cid,22,"You already got your life & mana.")

   end  
return TRUE
end
the only problem with this script is that the player can keep using the item meaning that if he gets another one he can use the item again :l and i dont want that to happen because then the players will have like 4kk of life lol so how can i make it so that it is only usable once per player? also feel free to use this script in your server hehe all you have to do is edit the health and mana part
 
There some more wrong.. let me change it give me a few min.
Code:
setPlayerStorageValue(cid,13503) -- old
setPlayerStorageValue(cid,13503,1) -- new

Untested, but should work.. assuming the setcreaturemaxhealth is executing properly.
Code:
function onUse(cid, item)
   if getPlayerStorageValue(cid,13503) < 1 then
     local health = 50000
     local mana = 50000
     setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + health)
     setCreatureMaxMana(cid, getCreatureMaxMana(cid) + mana)
     doCreatureAddHealth(cid,999999999)
     doCreatureAddMana(cid,999999999)
     doCreatureSay(cid, "You gained 50k of life & mana, now your health is ".. getCreatureMaxHealth(cid) ..", and your mana is ".. getCreatureMaxMana(cid) .."!" ,19)
     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_RED)
     doRemoveItem(item.uid)
     setPlayerStorageValue(cid,13503,1)
   elseif getPlayerStorageValue(cid,13503) == 1 then
     doPlayerSendTextMessage(cid,22,"You already got your life & mana.")
     return false
   end  
return true
end
 
Last edited by a moderator:
Untested, but should work.. assuming the setcreaturemaxhealth is executing properly.
Code:
function onUse(cid, item)
   if getPlayerStorageValue(cid,13503) < 1 then
     local health = 50000
     local mana = 50000
     setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + health)
     setCreatureMaxMana(cid, getCreatureMaxMana(cid) + mana)
     doCreatureAddHealth(cid,999999999)
     doCreatureAddMana(cid,999999999)
     doCreatureSay(cid, "You gained 50k of life & mana, now your health is ".. getCreatureMaxHealth(cid) ..", and your mana is ".. getCreatureMaxMana(cid) .."!" ,19)
     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_RED)
     doRemoveItem(item.uid)
     setPlayerStorageValue(cid,13503,1)
   elseif getPlayerStorageValue(cid,13503) == 1 then
     doPlayerSendTextMessage(cid,22,"You already got your life & mana.")
     return false
   end 
return true
end
you're awesome dude thank you xD
 
Anytime.
If the script works, just edit your title changing from 'windows' to 'solved' so others don't need to read through the post to know it was solved. ;)
 
Back
Top