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

[Request] Group of Vocations Can't Attack Another Group of Vocations.

tabz23

New Member
Joined
Sep 3, 2009
Messages
66
Reaction score
0
As the title says i was wondering if its possible to make it so that a certain group of Vocations cannot attack another group of vocations... I already know theres a way to make it so all sorcerers dont attack all sorcerers and knights atk knights etc...


But is there a way for example that Sorcerers and Paladins cant Attack Druids and Knights?

i was thinking a lua code for example

Code:
local sorcererdruid = 
[1]
[2]

local knightpaladin = 
[3]
[4]
function onLogin 
      if getPlayerVocation(cid) == sorcererdruid
      then knightpaladin_notAttackable


That code was a very badd code it was just an example of the concept... So you can get an idea =)

If you want you can do it however you please i just need a lua script that can make it so only some vocations can attack some vocations please... ill rep you!!! thanks alot!
 
LUA:
function onAttack(cid, target)

local mages, warriors = {1, 2}, {3, 4}

	if isMonster(target) or isMonster(cid) then
		return true
	end

	if(isInArray(mages, getPlayerVocation(cid) and isInArray(warriors, getPlayerVocation(target)) or (isInArray(warriors, getPlayerVocation(cid) and isInArray(mages, getPlayerVocation(target)) then
		doPlayerSendCancel(cid, "You can not attack this player.")
		return false
	end
	return true
end
 
LUA:
function onAttack(cid, target)

local mages, warriors = {1, 2}, {3, 4}

	if isMonster(target) or isMonster(cid) then
		return true
	end

	if(isInArray(mages, getPlayerVocation(cid) and isInArray(warriors, getPlayerVocation(target)) or (isInArray(warriors, getPlayerVocation(cid) and isInArray(mages, getPlayerVocation(target)) then
		doPlayerSendCancel(cid, "You can not attack this player.")
		return false
	end
	return true
end

Woooooot! thats exactly what i was trying to do im just new at lua scripting thank you so much!!

EDIT: hey i just tried it out and it gave me this error

Code:
[22/12/2009 19:49:03] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/RaceProtection.lua)
[22/12/2009 19:49:03] data/creaturescripts/scripts/RaceProtection.lua:9: ')' expected near 'then'
[22/12/2009 19:49:03] >> Loading chat channels
[22/12/2009 19:49:03] >> Loading outfits
[22/12/2009 19:49:03] >> Loading experience stages
[22/12/2009 19:49:03] >> Loading monsters
[22/12/2009 19:49:04] >> Loading mods...

do you think you can fix it? i know its something small i tried adding parenthesis all around there pleaseee ! =)
 
LUA:
function onAttack(cid, target)

local mages, warriors = {1, 2}, {3, 4}

        if isMonster(target) or isMonster(cid) then
                return true
        end

        if(isInArray(mages, getPlayerVocation(cid)) and isInArray(warriors, getPlayerVocation(target)) or (isInArray(warriors, getPlayerVocation(cid)) and isInArray(mages, getPlayerVocation(target)))) then
                doPlayerSendCancel(cid, "You can not attack this player.")
                return false
        end
        return true
end
 
@2Up:

PHP:
if(isInArray(mages, getPlayerVocation(cid)) and isInArray(warriors, getPlayerVocation(target))) or (isInArray(warriors, getPlayerVocation(cid)) and isInArray(mages, getPlayerVocation(target))) then

Should work now..

Edit: Oops well Sync got it faster :p
 
Thanks! well still some issue, i the error no longer comes up, but now when i go to attack the other vocation the script still doesnt work >.<

it may be a noob error on my side im wondering, does it go in creaturescripts? and maybe im putting the creaturescripts.xml wrong >.<

think you guys can help? sorry for the hassle, i really need this script though its almost finished! thanks =]
 
i changed it to player anyways

but i still need help with the script... i was putting everything in correctly.. login.lua, the script and creaturescript.xml... it still doesnt work =/ the server doesnt give me any errors it just doesnt take effect...

does anyone know how to fix it or make another script? :x
 
i did trust me, i changed it like 10 different times and tried over and over and still nothing =/ do you maybe have another way so selected vocations dont attack each other?
 
im 100% sure i got the creaturescripts.xml correct, and in the login.lua too... i triprlechecked... i have this other one that cybermaster gave to me but it doesnt work either... he did it with stats change though instead of onattack.
 
Back
Top