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

No attack mates

Raggaer

Godly Member
Joined
Jul 25, 2012
Messages
1,557
Solutions
8
Reaction score
957
Location
Spain
I need a script or a c++ modification that makes you cant attack players from same vocation!, thanks!
 
XML:
<event type="combat" name="vocPrevent" event="script" value="vocPrevent.lua"/>

LUA:
registerCreatureEvent(cid, "vocPrevent")

LUA:
function onCombat(cid, target)
	if(isPlayer(cid) and isPlayer(target)) then
		if(getPlayerVocation(cid) == getPlayerVocation(target)) then
			return false
		end
	end
	return true
end
 
Let say I have a field in my database in the table players called .. 'Grade', then I need if the player has grade 1 players with grade 1 cannot attack, if grade 2 etc..
 
first add this function in your lib folder (data/lib/050-constant.lua)
LUA:
function getPlayerGrade(cid)
    local Field = db.getResult("SELECT `Grade` FROM `players` WHERE `name` = " .. getPlayerName(cid) .. " LIMIT 1")
        if Field:getID() ~= LUA_ERROR then
        local value = Field:getDataInt("Grade")
        Field:free()
        return value
    end
     return LUA_ERROR
end

now you can use the script with your Grade
LUA:
function onCombat(cid, target)
	if(isPlayer(cid) and isPlayer(target)) then
		if(getPlayerGrade(cid) == getPlayerGrade(target)) then
			return false
		end
	end
	return true
end
 
Back
Top