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

Can't attack guild members...

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
I tried to make a script that would be impossible to attack members of the same guild.
But it went wrong, I can not attack anyone...

Code:
function onAttack(cid, target)
 if isPlayer(target) == TRUE then
  if getPlayerGuildId(cid) == getPlayerGuildId(target) then
   return FALSE
  end
 end
end
And another... I can kill anyone using magic... I wish it was also impossible to reach members of the same guild with spells.

>>Yes, I am using a translator.
 
You need also to return TRUE at the bottom (before last end) because if you won't add it - it will always return FALSE by default, and won't let you attack anyone as you said.

For magic -> use onCombat(cid, target) event.

Btw I love replying in your threads :p
 
You need also to return TRUE at the bottom (before last end) because if you won't add it - it will always return FALSE by default, and won't let you attack anyone as you said.

For magic -> use onCombat(cid, target) event.

Btw I love replying in your threads :p

AHSUahsu THX man ;)
 
Ah, I edited the script... Now appears the MSG, but I CAN attack members of the same guild <_<
Code:
function onAttack(cid, target)
 if isPlayer(target) == TRUE then
  if getPlayerGuildId(cid) == getPlayerGuildId(target) then
   return doPlayerSendCancel(cid, "Voc\ê n\ão pode atacar membros da mesma guilda.")
    else
    return TRUE
   end
  end
 return TRUE
end
 
You can't use 'return doPlayerSendCancel' because doPlayerSendCancel returns TRUE if message was successful sent.

Should work:
Code:
function onAttack(cid, target)
	if isPlayer(target) == TRUE then
		if getPlayerGuildId(cid) == getPlayerGuildId(target) then
			doPlayerSendCancel(cid, "Voc\ê n\ão pode atacar membros da mesma guilda.")
			return FALSE
		end
	end

	return TRUE
end
 
You can't use 'return doPlayerSendCancel' because doPlayerSendCancel returns TRUE if message was successful sent.

Should work:
Code:
function onAttack(cid, target)
	if isPlayer(target) == TRUE then
		if getPlayerGuildId(cid) == getPlayerGuildId(target) then
			doPlayerSendCancel(cid, "Voc\ê n\ão pode atacar membros da mesma guilda.")
			return FALSE
		end
	end

	return TRUE
end

Now I can't attack all players...
If I edit to:
Code:
function onAttack(cid, target)
 if isPlayer(target) == TRUE then
  if getPlayerGuildId(cid) ~= getPlayerGuildId(target) then
   return TRUE
    else
     doPlayerSendCancel(cid, "Voc\ê n\ão pode atacar membros da mesma guilda.")
    return FALSE
   end
  end
 return TRUE
end
...Will be work?
 
Code:
function onAttack(cid, target)
    if (isMonster(target) or isMonster(cid)) then
        return true
    end

    if(getPlayerGuildId(cid) == getPlayerGuildId(target)) then
        doPlayerSendCancel(cid, "You cannot attack your own guild members.")
        return false
    end
    return true
end
 
Last edited:
oh......... now I understand why it wasn't working. We need to check if guild id != 0 (thats the reason why you couldn't attack all players)

Code:
function onAttack(cid, target)
	if isPlayer(target) == TRUE then
		local guild = getPlayerGuildId(cid)
		if guild ~= 0 and guild == getPlayerGuildId(target) then
			doPlayerSendCancel(cid, "Voc\ê n\ão pode atacar membros da mesma guilda.")
			return FALSE
		end
	end

	return TRUE
end

it must work now!
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_PLANTATTACK)
setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 5, 10)

local area = createCombatArea(AREA_CROSS6X6)
setCombatArea(combat, area)

function onCastSpell(cid, var)
 local target = getCreatureTarget(cid)
  if isPlayer(target) == TRUE then
   local guild = getPlayerGuildId(cid)
    if guild ~= 0 and guild == getPlayerGuildId(target) then
     doPlayerSendCancel(cid, "Voc\ê n\ão pode atacar membros da mesma guilda.")
      return FALSE
     else
    return doCombat(cid, combat, var)
   end
  end
 return TRUE
end

Will be work?
 
Back
Top