• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.
outfit bonus table

outfit bonus table

abdala ragab

Veteran OT User
Joined
Aug 18, 2018
Messages
594
Solutions
17
Reaction score
440
Location
gamelaots.online
abdala ragab submitted a new resource:

outfit bonus table - outfit bonus table Two different Script:

Two different script: A script if you were to give all the outfits the same reward or some of them with the same reward, and a script with different rewards.
Here is the first script of the consolidated rewards
Lua:
local addonBonus = CreatureEvent("AddonBonus")

function addonBonus.onLogin(player)
    -- Define conditions
    local conditions = {
        mage = Condition(CONDITION_ATTRIBUTES),
        noble = Condition(CONDITION_ATTRIBUTES),
        Citizen =...

Read more about this resource...
 
Hello, the script looks very good and interesting, but I tried to use it in TFS 1.3 OTG base but it is necessary to relog for the attribute to appear, could you adjust it for us please?
 
Last edited:
All conditions and their parameters are not set using any player value (his level etc.).
They should be created and configured above function addonBonus.onLogin(player) ex.
Lua:
-- Define different conditions
local conditions = {
    mage = Condition(CONDITION_ATTRIBUTES),
    noble = Condition(CONDITION_ATTRIBUTES),
    Citizen = Condition(CONDITION_ATTRIBUTES),
    hunter = Condition(CONDITION_ATTRIBUTES),
    Knight = Condition(CONDITION_ATTRIBUTES),
    Summoner = Condition(CONDITION_ATTRIBUTES),
    Warrior = Condition(CONDITION_ATTRIBUTES),
    Barbarian = Condition(CONDITION_ATTRIBUTES),
    Druid = Condition(CONDITION_ATTRIBUTES),
    Wizard = Condition(CONDITION_ATTRIBUTES),
    Oriental = Condition(CONDITION_ATTRIBUTES),
    Custom = Condition(CONDITION_ATTRIBUTES)
}

-- Set parameters for each condition

conditions.noble:setParameter(CONDITION_PARAM_TICKS, -1)
conditions.noble:setParameter(CONDITION_PARAM_SKILL_SHIELD, 15)
conditions.noble:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 50)
conditions.noble:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 50)
conditions.noble:setParameter(CONDITION_PARAM_SKILL_MELEE, 50)
conditions.noble:setParameter(CONDITION_PARAM_SKILL_FIST, 50)

-- HERE rest of conditions

function addonBonus.onLogin(player)
-- HERE code related to player starts:
    -- Getting the player's outfit directly
    local outfit = player:getOutfit()
    local lookType = outfit.lookType
    local lookAddons = outfit.lookAddons

All code inside function addonBonus.onLogin(player) is executed every time player logins into game. So it creates 12 new conditions in C++, set their values and then only add some of them or none in ex. player:addCondition(conditions.Knight). At end of execution of addonBonus.onLogin it will remove them all from Lua (they are local inside that function). I'm not sure, if it will remove these Conditions from C++ at all!

Code above function addonBonus.onLogin(player) is executed only once at server start (also on /reload xx), so making it create variables saves a lot of CPU.
You can apply same condition to multiple players using player:addCondition(conditions.Knight). That's what all Spells do with Conditions and Combats.

EDIT:
To make it easier to understand. Your Lua script may look like this:
Lua:
local loginMessage = CreatureEvent("LoginMessage")

local loginCounter = 0

function loginMessage.onLogin(player)
    loginCounter = loginCounter + 1

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Players logins into game " .. loginCounter)

    return true
end

loginMessage:register()
whenever any player relogs, it will increase count +1. Variable is outside "callback" function, it's shared between function executions.

You don't have to understand C++. From Lua point of view (what C++ "does"): when new player logins, it executes in Lua (imagine it's pasted at end of your .lua file):
Lua:
local playerLoggingIn = Player(123)
loginMessage:onLogin(playerLoggingIn)
Second player with GUID 567 logins, it executes:
Code:
local playerLoggingIn = Player(567)
loginMessage:onLogin(playerLoggingIn)
Third player with GUID 789 logins, it executes:
Code:
local playerLoggingIn = Player(789)
loginMessage:onLogin(playerLoggingIn)
so everytime some player logins into game, it defines new local variables at end of file ex. local playerLoggingIn = Player(567) and pass it as parameter to your function ex. loginMessage.onLogin(playerLoggingIn).
 
Last edited:
Back
Top