• 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
5
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()
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,039
Solutions
103
Reaction score
1,096
Location
London
GitHub
MillhioreBT
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")
 
OP
OP
R

RigBy

Member
Joined
Jun 9, 2015
Messages
44
Solutions
1
Reaction score
5
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.
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
8,040
Solutions
215
Reaction score
3,882
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
 
OP
OP
R

RigBy

Member
Joined
Jun 9, 2015
Messages
44
Solutions
1
Reaction score
5
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?
 
Top