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

Revscript script works

RigBy

Member
Joined
Jun 9, 2015
Messages
44
Solutions
1
Reaction score
6
I haven't mastered Rev Script yet, someone teach me how to make it work :(

Lua:
local creatureevent = CreatureEvent("teste")

function creatureevent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    print("oi")
    return true
end


creatureevent:register()
 
data/scripts/file.lua
Lua:
local creatureEvent = CreatureEvent("creatureEventName")

function creatureEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    
    -- if creature is a player then
    if creature:isPlayer() then
        -- if primaryDamage or secondaryDamage is less than 0 then is a damage
        if primaryDamage < 0 or secondaryDamage < 0 then
            -- Reduce damages on 50%
            primaryDamage = primaryDamage / 2
            secondaryDamage = secondaryDamage / 2
        end
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

creatureEvent:register()

Remember that you must register this event to the creature so that it can use this method as a health filter
It is very common to register this type of events in the onLogin event for the players and in this way the players will make use of this method of damage reduction,

In this example I am checking if the creature is a player, but if you are sure that you are only going to register players to this event, then that check is unnecessary.

examples of how to register:
Lua:
creature:registerEvent("creatureEventName")
 
data/scripts/file.lua
Lua:
local creatureEvent = CreatureEvent("creatureEventName")

function creatureEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
   
    -- if creature is a player then
    if creature:isPlayer() then
        -- if primaryDamage or secondaryDamage is less than 0 then is a damage
        if primaryDamage < 0 or secondaryDamage < 0 then
            -- Reduce damages on 50%
            primaryDamage = primaryDamage / 2
            secondaryDamage = secondaryDamage / 2
        end
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

creatureEvent:register()

Remember that you must register this event to the creature so that it can use this method as a health filter
It is very common to register this type of events in the onLogin event for the players and in this way the players will make use of this method of damage reduction,

In this example I am checking if the creature is a player, but if you are sure that you are only going to register players to this event, then that check is unnecessary.

examples of how to register:
Lua:
creature:registerEvent("creatureEventName")
sorry my english, i use the translator.
is developing a resistance/absorb system for players using this function, could this be harmful to the server?
I hope you can understand.
 
sorry my english, i use the translator.
is developing a resistance/absorb system for players using this function, could this be harmful to the server?
I hope you can understand.
it has already been done :D
 
1629053325554.png

I'll take a look, can you tell me if the onStatus it already calculates armor, defense, damage reduction and the damage sampled there is already the damage passed by all this?

1629053564619.png

do you have a tutorial that talks better about onStatus?
 
Back
Top