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

Is there "non vocation"? tfs 1.5

Mateus Robeerto

Excellent OT User
Joined
Jun 5, 2016
Messages
1,340
Solutions
71
Reaction score
701
Location
ლ(ಠ益ಠლ)
I'm looking for a script, for example "Vip Sorcerer cannot attack 'Master Sorcerer' vocation". Does anyone have this script? Can you share it around here? Thank you in advance.
 
Solution
Lua:
function onCombat(cid, target)
if not(isPlayer(target)) then
return true
end
if getPlayerGroupId(cid) > 2 then
return true
end
if getPlayerStorageValue(cid, 14136) ~= -1 or getPlayerStorageValue(target, 14136) ~= -1 then
return true
end
local valan1 = getPlayerVocation(cid) > 8
local valan2 = getPlayerVocation(target) > 8
if valan2 ~= valan1 then
doPlayerSendCancel(cid, "You can't attack other vocations.")
end
if valan2 ~= valan1 then
return false
end
return true
end
or
Lua:
function onCombat(cid, target)
     if isInArray({1, 2, 3}, getPlayerVocation(cid)) and isInArray({4, 5, 6}, getPlayerVocation(target)) then
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't attack other vocations.")...
Can you be more specific? Do you already have a combat script taking care of that? Its for a info window or something?
 
For example, I will explain that there are two very important vocations: Demi-God and God. Deus cannot attack Demigod until PROMOTION. Furthermore, only a God can attack another God if he has the same vocation. Did you understand?

example I want the same here

[Error - CreatureEvent::configureEvent] Invalid type for creature event: playerattack
[Warning - BaseEvents::loadFromXml] Failed to configure event

Could it be that I did this xml wrong?

XML:
<event type="combat" name="playerattack" script="valan/playerattack.lua"/>
    <event type="login" name="playerattacktype" script="valan/playerattacktype.lua"/>

I already registered at login.lua
 
It must be done inside onTargetCombat event as callback, there is no onCombat

Lua:
local ec = EventCallback
function ec.onTargetCombat(creature, target)
    return RETURNVALUE_NOERROR
end
ec:register()
 
It must be done inside onTargetCombat event as callback, there is no onCombat

Lua:
local ec = EventCallback
function ec.onTargetCombat(creature, target)
    return RETURNVALUE_NOERROR
end
ec:register()
Here, I have tried several times without success. Can you make a simple script for me?" please!
 
Show the script u done befor
Lua:
function onCombat(cid, target)
if not(isPlayer(target)) then
return true
end
if getPlayerGroupId(cid) > 2 then
return true
end
if getPlayerStorageValue(cid, 14136) ~= -1 or getPlayerStorageValue(target, 14136) ~= -1 then
return true
end
local valan1 = getPlayerVocation(cid) > 8
local valan2 = getPlayerVocation(target) > 8
if valan2 ~= valan1 then
doPlayerSendCancel(cid, "You can't attack other vocations.")
end
if valan2 ~= valan1 then
return false
end
return true
end
or
Lua:
function onCombat(cid, target)
     if isInArray({1, 2, 3}, getPlayerVocation(cid)) and isInArray({4, 5, 6}, getPlayerVocation(target)) then
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't attack other vocations.")
         return false
     end
     return true
end
 
Lua:
function onCombat(cid, target)
if not(isPlayer(target)) then
return true
end
if getPlayerGroupId(cid) > 2 then
return true
end
if getPlayerStorageValue(cid, 14136) ~= -1 or getPlayerStorageValue(target, 14136) ~= -1 then
return true
end
local valan1 = getPlayerVocation(cid) > 8
local valan2 = getPlayerVocation(target) > 8
if valan2 ~= valan1 then
doPlayerSendCancel(cid, "You can't attack other vocations.")
end
if valan2 ~= valan1 then
return false
end
return true
end
or
Lua:
function onCombat(cid, target)
     if isInArray({1, 2, 3}, getPlayerVocation(cid)) and isInArray({4, 5, 6}, getPlayerVocation(target)) then
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't attack other vocations.")
         return false
     end
     return true
end


Lua:
local ec = EventCallback

ec.onTargetCombat = function(self, target)
    if not self or not self:isPlayer() then
        return true
    end
    if not target or not target:isPlayer() then
        return true
    end
    if self:getVocation():getName() == "Druid" then
        if target:getVocation():getName() == "Sorcerer" then
            return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE
        end
    end
    return RETURNVALUE_NOERROR
end

ec:register()

1689203946113.png

This script blocks druid to attack sorcerer but sorcerer can attack druids and thats what you wanted?
 
Solution
Lua:
local ec = EventCallback

ec.onTargetCombat = function(self, target)
    if not self or not self:isPlayer() then
        return true
    end
    if not target or not target:isPlayer() then
        return true
    end
    if self:getVocation():getName() == "Druid" then
        if target:getVocation():getName() == "Sorcerer" then
            return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE
        end
    end
    return RETURNVALUE_NOERROR
end

ec:register()

View attachment 76706

This script blocks druid to attack sorcerer but sorcerer can attack druids and thats what you wanted?
Excuse me, which part did you add? Was it in the script or in the creaturescript/script? And what XML are you using?
 
Is it the script u needed?
If u want it different then let me know it.
Mark the script as "solution"
this is what i needed. My server is totally different from the other OTs, as well as the baiak, RL, global map, etc. My map is based on The Lord of the Rings, in the old version 7.92. I already marked you as a solution. Thank's for your time.
 
Back
Top