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

Solved CreatureScript. Check player items.

Hekan

New Member
Joined
Jun 14, 2008
Messages
94
Reaction score
0
Hello! I would like to ask you to write a creaturescript that if player dont have item tele his out. Can someon help me ? :)
 
Last edited:
Code:
local whereto = {x= 1, y=1, z=7} --change to place to kick them to
local itemyouneed = 1232 --replace with item they have to have

-----------------------------------------------<--- need more info before I can do this bit
if getPlayerItemCount(cid, itemyouneed) < 1 then
     doTeleportThing(cid, whereto, TRUE)
end
return TRUE
end

when will this code be used? when they log in? I can't finish the script until I know when it will check for the item :p
 
ok so that's a global event:
in globalevents.lua add:
Code:
<globalevent name="checkitem" interval="60000" event="script" value="checkitem.lua"/>
(I may have gotten the interval wrong... it's in milliseconds I think so it should be 60*1000 which is 1 minute)

in the scripts folder make a new file called checkitem.lua
open it, and add:
Code:
local whereto = {x= 1, y=1, z=7} --change to place to kick them to
local itemyouneed = 1232 --replace with item they have to have

function onThink(interval, lastExecution)
if getPlayerItemCount(cid, itemyouneed) < 1 then
     doTeleportThing(cid, whereto, TRUE)
end
return TRUE
end

then in the game (if the server's running) say /reload globalevents

however: this will kick EVERY player in the entire server... you'll need to tell me more what this is for in order for me to kick only certain players

what it will need: a storage value setting when they go to this place, if the storage value = 1 then it checks for the item, else it ignores them
 
if it has a storage value set already that's a LOT easier
assuming storage value is 500:
Code:
local whereto = {x= 1, y=1, z=7} --change to place to kick them to
local itemyouneed = 1232 --replace with item they have to have

function onThink(interval, lastExecution)

for _, pl in pairs(getPlayersOnline()) do
if getPlayerStorageValue(pl,500) == 1
     if getPlayerItemCount(pl, itemyouneed) < 1 then
          doTeleportThing(pl, whereto, TRUE)
          setPlayerStorageValue(pl,500,0)
     end
end
return TRUE
end

this -should- work if their storage value 500 is set to 1 when they enter
also, you'll need to make a script so that when they leave/die they have the storage value set to 0 else it will still check for their item ;)

onDeath etc etc
setPlayerStorageValue(cid,500,0)
 
@up you are missing [then]
here is a working one
Lua:
local cfg = {
	position = {x= 1000, y=1000, z=7} , --change to place to kick them to
	item = 1232, --replace with item they have to have
	storage = 500
	}

function onThink(interval, lastExecution)
	for _, cid in ipairs(getPlayersOnline()) do
		if getPlayerStorageValue(cid, cfg.storage) == 1 then
			if getPlayerItemCount(cid, cfg.item) < 1 then
				doTeleportThing(cid, cfg.position)
				setPlayerStorageValue(cid, cfg.storage, 0)
			end
		end
          end
return true
end
 
Back
Top