• 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 Help with getPlayerSlotItem

Drs1705

Member
Joined
Dec 26, 2011
Messages
69
Reaction score
14
Code:
if (getPlayerSlotItem([COLOR="#FF0000"][B]cid[/B][/COLOR], CONST_SLOT_ARMOR).itemid == 2505) then

How to put instead of checking if the player itself is using the armor, the player who is hit be checked? He is not a target, it will be checked in the field of magic.
 
Depense on what you want it to do after that, if it's not for a different combat you can do it like this.
LUA:
function onTargetCreature(cid, target)
	if target and isPlayer(target) then
		if(getPlayerSlotItem(target, CONST_SLOT_ARMOR).itemid == 2505) then
			doPlayerSendTextMessage(cid, 25, "The player has this armor")
		end
	end
	return true
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
 
I want to check if the target has this armor inside that function
Code:
local function UM(cid)
pos = getPosfromArea(cid,arr1)
n = 0
while n < #pos do
n = n+1
thing = {x=pos[n].x,y=pos[n].y,z=pos[n].z,stackpos=253}

if hasSqm(pos[n]) then
	if getTilePzInfo(pos[n]) == false then 
		if isPlayer(getThingfromPos(thing).uid) == TRUE or isMonster(getThingfromPos(thing).uid) == TRUE then
		doPushCreature(getThingfromPos(thing).uid,getPlayerLookDir(cid))
		end
	end
end
end
end
 
working, thanks , rep+

edit

not pushing the monsters = /

Code:
while n < #pos do
n = n+1
thing = {x=pos[n].x,y=pos[n].y,z=pos[n].z,stackpos=253}
if hasSqm(pos[n]) then
	if getTilePzInfo(pos[n]) == false then 
		if isPlayer(getThingfromPos(thing).uid) == TRUE then
            if not(getPlayerSlotItem(getThingfromPos(thing).uid, CONST_SLOT_ARMOR).itemid == 2505) then
				if isPlayer(getThingfromPos(thing).uid) == TRUE or isMonster(getThingfromPos(thing).uid) == TRUE then
				doPushCreature(getThingfromPos(thing).uid, getDirectionBetween(getThingPos(cid), thing), 1, 0)
				end
			end
		end
	end
end
end
end
 
Still only pushes player, monsters are not pushed

Code:
local function UM(cid)
pos = getPosfromArea(cid,arr1)
n = 0

while n < #pos do
n = n+1
thing = {x=pos[n].x,y=pos[n].y,z=pos[n].z,stackpos=253}
if hasSqm(pos[n]) then
	if getTilePzInfo(pos[n]) == false then 
		if isPlayer(getThingfromPos(thing).uid) == TRUE then
            if not(getPlayerSlotItem(getThingfromPos(thing).uid, CONST_SLOT_ARMOR).itemid == 2505) then
			doPushCreature(getThingfromPos(thing).uid, getDirectionBetween(getThingPos(cid), thing), 1, 0)
			elseif isMonster(getThingfromPos(thing).uid) == TRUE then
			doPushCreature(getThingfromPos(thing).uid, getDirectionBetween(getThingPos(cid), thing), 1, 0)
		end
		end	
	end
end
end
end
 
Add end under this
LUA:
if isPlayer(getThingfromPos(thing).uid) == TRUE then
	if not(getPlayerSlotItem(getThingfromPos(thing).uid, CONST_SLOT_ARMOR).itemid == 2505) then
		doPushCreature(getThingfromPos(thing).uid, getDirectionBetween(getThingPos(cid), thing), 1, 0)
So like this
LUA:
if isPlayer(getThingfromPos(thing).uid) == TRUE then
	if not(getPlayerSlotItem(getThingfromPos(thing).uid, CONST_SLOT_ARMOR).itemid == 2505) then
		doPushCreature(getThingfromPos(thing).uid, getDirectionBetween(getThingPos(cid), thing), 1, 0)
	end
Else the elseif is for the armor check, also remove the end under it to not have an extra end.
If you tab the code, you see that it will use elseif for the armor instead of for the player if you don't add end there.
LUA:
if isPlayer(getThingfromPos(thing).uid) == TRUE then
	if not(getPlayerSlotItem(getThingfromPos(thing).uid, CONST_SLOT_ARMOR).itemid == 2505) then
		doPushCreature(getThingfromPos(thing).uid, getDirectionBetween(getThingPos(cid), thing), 1, 0)
	elseif isMonster(getThingfromPos(thing).uid) == TRUE then
		doPushCreature(getThingfromPos(thing).uid, getDirectionBetween(getThingPos(cid), thing), 1, 0)
	end
end
 
Solved, Rep+
Code:
if isPlayer(getThingfromPos(thing).uid) == TRUE then
			if not(getPlayerSlotItem(getThingfromPos(thing).uid, CONST_SLOT_ARMOR).itemid == 2505) then
			doPushCreature(getThingfromPos(thing).uid,getPlayerLookDir(cid))
			end
		elseif isMonster(getThingfromPos(thing).uid) == TRUE then
		doPushCreature(getThingfromPos(thing).uid,getPlayerLookDir(cid))
		end
 
Back
Top