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

Need additem if not found itemid

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,780
Solutions
31
Reaction score
2,299
Location
Sweden?
Closed! Removed!

Closed! Removed!
 
Last edited:
Code:
function doSomething(you, fill, this, out, yourself)

[COLOR="#FF0000"]	if(getPlayerItemCount(cid, itemId) < 1) then
		doPlayerAddItem(cid, itemId, count)
	else
		doPlayerSendCancel(cid, "Sorry, not possible.")
	end[/COLOR]
	
	return true
end
 
Last edited:
J.Dre

I want when the script see that the leg_sloot is empty and there is no item there it will automatic add item id 2395, but if it alrdy a item there it dont gone do smth!
 
Last edited:
here is it ... put it in creaturescripts

Code:
function onThink(cid, interval)
     
	if getPlayerSlotItem(cid, CONST_SLOT_LEGS).itemid == 0 and getPlayerItemCount(cid, 2395) == 0 then
		doPlayerAddItem(cid, 2395, 1)
	end
	
	return true
end

add this line to creaturescripts.xml
Code:
<event type="think" name="legs" event="script" value="legs.lua"/>

register it into login.lua too
 
here is it ... put it in creaturescripts

Code:
function onThink(cid, interval)
     
	if getPlayerSlotItem(cid, CONST_SLOT_LEGS).itemid == 0 and getPlayerItemCount(cid, 2395) == 0 then
		doPlayerAddItem(cid, 2395, 1)
	end
	
	return true
end

add this line to creaturescripts.xml
Code:
<event type="think" name="legs" event="script" value="legs.lua"/>

register it into login.lua too

That's not a creature script. It's a global event, and also a bad idea. ^_^
 
onThink(cid, interval) is a creaturescript function too.
Main difference:
[creaturescript] onThink(cid, interval): Is always executed every 500ms in every online player.
[globalevent] onThink(): Execute interval and array of creatures can be configured.
 
Last edited:
Didnt work, but i made that if they login, it check if the sloot is empty and add the item. but thanks anyway Rep!
 
Back
Top