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

Deny use if in PZ.

Nightimarez

New Member
Joined
Jul 24, 2008
Messages
287
Reaction score
2
So I got this script that summons a creature, but I don't want it to work when in PZ.

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local pos = getPlayerPosition(cid)
	local summom = getCreatureSummons(cid)
	if(fromPosition.x ~= CONTAINER_POSITION) and item.itemid == 6579 then
		spawnEffect = math.random(6, 7)
		doRemoveItem(item.uid, 1)
		doSummonCreature("Boy", toPosition)
		doCreatureSay(cid, "Run little one!", TALKTYPE_ORANGE_1)
	elseif(fromPosition.x ~= CONTAINER_POSITION) == false and item.itemid == 6579 then
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Place him on the ground first!")
	end

	return true
end

I get this error if used in PZ.

PHP:
[04/05/2012 03:20:50] Lua Script Error: [Action Interface] 
[04/05/2012 03:20:50] data/actions/scripts/new/boy.lua:onUse
[04/05/2012 03:20:50] luaDoSummonCreature(). Can not summon monster: Boy
[04/05/2012 03:20:50] stack traceback:
[04/05/2012 03:20:50] 	[C]: in function 'doSummonCreature'
[04/05/2012 03:20:50] 	data/actions/scripts/new/boy.lua:7: in function <data/actions/scripts/new/boy.lua:1>
 
i have anther one work good and i add exhausted and another

LUA:
local cfg = {
	exhausted = 40, -- Time you are exhausted.
	storage = 80000 -- Storage used for "exhaust."
}

  function onUse(cid, item, frompos, item2, topos)

pos = getPlayerPosition(cid) 
po = getCreaturePosition(cid)
bad_items = {"fire field", "poison field", "energy field", "smoke", "searing fire", "poison gas"}
item_floor = getThingFromPos({x = po.x, y = po.y, z = po.z, stackpos = 2})

if(getPlayerStorageValue(cid, cfg.storage) > os.time()) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, cfg.storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, cfg.storage) - os.time()) == 1 and "" or "s") .. ".")
elseif getTilePzInfo(pos) == true then
  return doPlayerSendCancel(cid, "You cant use in protection zone.")
		

elseif(item_floor.itemid ~= 0) and (isInArray(bad_items, getItemNameById(item_floor.itemid)) == true) then
 return returnMessage(cid, "You may not call your pet here.")
								
 elseif item.itemid == 8982 then
 doConvinceCreature(cid, doCreateMonster("Boy", pos)) 
doSendMagicEffect(topos,12)
doCreatureSay(cid, "Run little one!", TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid, cfg.storage, os.time() + cfg.exhausted)	
end
return true
end

reb if this work good hope this help u
 
Thanks but I just need someone to put in this part for me.

PHP:
if getTilePzInfo(pos) == true then
  return doPlayerSendCancel(cid, "You cant use in protection zone.")
 
Tested & Working (0.3.7)

oqwttt.png


LUA:
local monster = "dog" -- the monster name
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getTileInfo(getCreaturePosition(cid)).protection) then
		return doPlayerSendCancel(cid, "You cannot use this while in PZ.")
	elseif(fromPosition.x == 0xFFFF) then
		return doPlayerSendCancel(cid, "You must place him on the ground!")
	else
		doRemoveItem(item.uid, 1)
		doCreateMonster(monster, fromPosition, false, true)
		doSendMagicEffect(fromPosition, CONST_ME_ENERGYAREA)
		doCreatureSay(cid, "I'm FREEEEEEE!", TALKTYPE_MONSTER, nil, nil, fromPosition)
	end
	
	return true
end
 
Thank you sir. This is how I wanted it though.

PHP:
local monster = "boy" -- the monster name
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getTileInfo(getCreaturePosition(cid)).protection) then
		return doPlayerSendCancel(cid, "You cannot use this while in PZ.")
	elseif(fromPosition.x == 0xFFFF) then
		return doPlayerSendCancel(cid, "You must place him on the ground!")
	else
		doRemoveItem(item.uid, 1)
		doSummonCreature("Boy", toPosition)
		doSendMagicEffect(fromPosition, CONST_ME_ENERGYAREA)
		doCreatureSay(cid, "Run little one!", TALKTYPE_ORANGE_1)
	end
 
	return true
end
 
Back
Top