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

Jak sprawdzić czy na danej pozycji jest gracz

Lares

Member
Joined
Feb 8, 2010
Messages
315
Reaction score
8
Witam mam pewien problem ponieważ piszę pewien skrypt i jakoś nie wychodzi mi sprawdzenie czy na pozycji xyz znajduję się gracz a jeśli tak to żeby zabrało mu hp, może ktoś z tym pomóc?

PHP:
	if isPlayer(getTopCreature(poss.p1)) == true then
		dmg = math.random(250, 500)
		doCreatureAddHealth(getTopCreature(poss.p1), -dmg)
		doSendAnimatedText(poss.p1, dmg, TEXTCOLOR_YELLOW)	
	end
 
Code:
local position = {x=1, y=2, z=3}
local target = getTopCreature(position)
local dmg = math.random(250, 500)

if(isPlayer(target) == TRUE) then
    doCreatureAddHealth(target, -dmg)
    doSendAnimatedText(position, "-"..dmg.."HP!", TEXTCOLOR_YELLOW)    
end
 
Czym to się różni od mojego?

Moje:
if isPlayer(getTopCreature(poss.p1)) == true then
Twoje:
local position = {x=1, y=2, z=3}
local target = getTopCreature(position)

if(isPlayer(target) == TRUE) then
Czyli:
if(isPlayer(getTopCreature({x=1, y=2, z=3})) == TRUE) then

Wychodzi na to samo tak mi się wydaje.
 
Czym to się różni od mojego?

Moje:
if isPlayer(getTopCreature(poss.p1)) == true then
Twoje:
local position = {x=1, y=2, z=3}
local target = getTopCreature(position)

if(isPlayer(target) == TRUE) then
Czyli:
if(isPlayer(getTopCreature({x=1, y=2, z=3})) == TRUE) then

Wychodzi na to samo tak mi się wydaje.
Czytelnością ^2?
Poza tym, skąd mam wiedzieć co to jest poss.p1, i czy np. dobrze ją deklarujesz?
 
LUA:
local position = {x=1, y=2, z=3}
local target = getTopCreature(position)
local dmg = math.random(250, 500)

if(isPlayer(target) == TRUE) then
    doCreatureAddHealth(target, -dmg)
    doSendAnimatedText(position, "-"..dmg.."HP!", TEXTCOLOR_YELLOW)    
end

Czytelnością ^^
 
Czytelnością ^2?
Poza tym, skąd mam wiedzieć co to jest poss.p1, i czy np. dobrze ją deklarujesz?

--------------------------
local pos = getCreaturePosition(target)
local poss =
{
p1 = {x=pos.x-1,y=pos.y,z=pos.z}
}

poss.p1 jest to pozycja i deklaruje ją dobrze ponieważ na podanej pozycji tworzy się efekt:
LUA:
doSendMagicEffect(poss.p1, CONST_ME_POISONAREA)
 
Code:
local position = {x=1, y=2, z=3}
local target = getTopCreature(position).uid
local dmg = math.random(250, 500)

if(isPlayer(target) == TRUE) then
    doCreatureAddHealth(target, -dmg)
    doSendAnimatedText(position, "-"..dmg.."HP!", TEXTCOLOR_YELLOW)    
end
 
Back
Top