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

Attack

tashur

New Member
Joined
May 30, 2012
Messages
14
Reaction score
0
Hello.
I need script to cant atack my vocation.
For example: Im druid so i cant atack others druid just sorcerer, knight and paladin.

Thanks REP+
 
>creaturescripts/scripts/attack.lua
Lua:
function onAttack(cid, target) 
	local c = {storage = 1234, message = true}
	if isPlayer(target) == false or isPlayer(cid) == false then
		return true
	end
	if getPlayerVocation(cid) == getPlayerVocation(target) then
		if c.message == true then
			if getPlayerStorageValue(cid, c.storage) < os.time() then
				setPlayerStorageValue(cid, c.storage, (os.time() + 2))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You can't attack a player with your same vocation.")
			end
		end
		return false
	end
	return true
end

>creaturescripts/scripts/antidmg.lua
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	if isPlayer(target) == false or isPlayer(cid) == false then
		return true
	end
	if getPlayerVocation(cid) == getPlayerVocation(target) then
		if combat ~= COMBAT_HEALING then
			return false
		end 
	end
	return true
end

>creaturescripts/creaturescripts.xml
XML:
	<event type="attack" name="AntiVocAttack" event="script" value="attack.lua"/>
	<event type="statschange" name="AntiVocDmg" event="script" value="antidmg.lua" />

>creaturescripts/scripts/login.lua
and at the bottom before:
Lua:
	return TRUE
end

copy
Lua:
	registerCreatureEvent(cid, "AntiVocAttack")
	registerCreatureEvent(cid, "AntiVocDmg)

like this:
Lua:
	registerCreatureEvent(cid, "AntiVocAttack")
	registerCreatureEvent(cid, "AntiVocDmg)
	return TRUE
end
 
Last edited:
if(config.useFragHandler) then
registerCreatureEvent(cid, "SkullCheck")
end
registerCreatureEvent(cid, "AntiVocAttack")
registerCreatureEvent(cid, "AntiVocDmg")


registerCreatureEvent(cid, "ReportBug")
registerCreatureEvent(cid, "AdvanceSave")
return true
end

i paste it and
paste all what you want but i got eror in engine.

[09/03/2013 14:30:58] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/attack.lua:8: 'then' expected near 'if'
[09/03/2013 14:30:58] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/attack.lua)
[09/03/2013 14:30:58] data/creaturescripts/scripts/attack.lua:8: 'then' expected near 'if'


line 8 is:

if getPlayerStorageValue(cid, c.storage) < os.time() then
Plese help :D
 
Back
Top