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

RevScripts Help me understand this

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,085
Solutions
15
Reaction score
379
Location
Sweden
YouTube
Joriku
Hey,
I am new onto the Revscript side and got pretty confused about the fact that the datapack I am using atm has no creaturescripts folder including the "old" way of putting in an creaturescript inside the .xml file.
If I want to add in this script, how would it be done?
Last post by:

Demnish


Information that could be useful:
Using: (OTServBR) TFS 1.3

I am currently reading this to understand how to use it:


Me trying, explanation:
Lua:
-- Reward and amount
local config = {
    itemDrop = ITEM_PLATINUM_COIN,
    itemAmount = 1
}

function testAction.onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    -- Let's make sure non-viable players can't generate a reward
    if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return false
    end

    local master = killer:getMaster() -- Header??
    -- If the killer is a player the killer should get rewarded (duh?)
    if killer:isPlayer() then
        killer:addItem(config.itemDrop, config.itemAmount)
        return true
    -- When a player's summon kills another player the summoner should get rewarded (master = summoner, we defined it above)
    elseif killer:isMonster() and master:isPlayer() then
        master:addItem(config.itemDrop, config.itemAmount)
        return true
    end
    -- If none of these are met, there will be no reward
    return false
end

masterAction:id(2152) -- the item is a platinum coin
masterAction:register() -- End to activate it thru revscript??
 
Last edited:
Solution
E
Lua:
-- Reward and amount
local config = {
    itemDrop = ITEM_PLATINUM_COIN,
    itemAmount = 1
}

local creatureevent = CreatureEvent("PVP Reward")-- header

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- Let's make sure non-viable players can't generate a reward
    local player = creature:getPlayer()
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return false
    end

    local master = killer:getMaster()
    -- If the killer is a player the killer should get rewarded (duh?)
    if killer:isPlayer() then
        killer:addItem(config.itemDrop, config.itemAmount)
        return true
    -- When...
Lua:
-- Reward and amount
local config = {
    itemDrop = ITEM_PLATINUM_COIN,
    itemAmount = 1
}

local creatureevent = CreatureEvent("PVP Reward")-- header

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- Let's make sure non-viable players can't generate a reward
    local player = creature:getPlayer()
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return false
    end

    local master = killer:getMaster()
    -- If the killer is a player the killer should get rewarded (duh?)
    if killer:isPlayer() then
        killer:addItem(config.itemDrop, config.itemAmount)
        return true
    -- When a player's summon kills another player the summoner should get rewarded (master = summoner, we defined it above)
    elseif killer:isMonster() and master:isPlayer() then
        master:addItem(config.itemDrop, config.itemAmount)
        return true
    end
    -- If none of these are met, there will be no reward
    return false
end

creatureevent:register() -- footer/end

local creatureevent2 = CreatureEvent("register login") -- header 2

function creatureevent2.onLogin(player)
    player:registerEvent("PVP Reward")
    return true
end

creatureevent2:register() -- footer/end
 
Last edited by a moderator:
Solution
Lua:
-- Reward and amount
local config = {
    itemDrop = ITEM_PLATINUM_COIN,
    itemAmount = 1
}

local creatureevent = CreatureEvent("PVP Reward")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- Let's make sure non-viable players can't generate a reward
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return false
    end

    local master = killer:getMaster()
    -- If the killer is a player the killer should get rewarded (duh?)
    if killer:isPlayer() then
        killer:addItem(config.itemDrop, config.itemAmount)
        return true
    -- When a player's summon kills another player the summoner should get rewarded (master = summoner, we defined it above)
    elseif killer:isMonster() and master:isPlayer() then
        master:addItem(config.itemDrop, config.itemAmount)
        return true
    end
    -- If none of these are met, there will be no reward
    return false
end

creatureevent:register()

local creatureevent2 = CreatureEvent("register login")

function creatureevent2.onLogin(player)
    player:registerEvent("PVP Reward")
    return true
end

creatureevent2:register()
Sadly, didn't work..
7e60ffddf7ca2b4bb09f94d04344b164.png

Added it into data/scripts/creaturescripts/customs/fragreward.lua
ddc6b35fed2df46ad0824b9fcb16717a.jpg
 
Last edited:
yeah I missed a line, edited, should work now
Thank you,
Sort of miss understood it but at the same time I think I get a hand of it.



Lua:
dofile("war_config.lua")

local creatureevent = CreatureEvent("onLogin")-- header

function onLogin(player)

    local vocation = player:getVocation():getId()
    local promotion = player:getVocation():getPromotion()

    local function getVocationName(player)
        if vocation == 0 then
            return "Newbie"
        end
        if vocation == 1 then
            return "Sorcerer"
        end
        if vocation == 2 then
            return "Druid"
        end
        if vocation == 3 then
            return "Paladin"
        end
        if vocation == 4 then
            return "Knight"
        end
        if vocation == 5 then
            return "Master Sorcerer"
        end
        if vocation == 6 then
            return "Elder Druid"
        end
        if vocation == 7 then
            return "Royal Paladin"
        end
        if vocation == 8 then
            return "Elite Knight"
        end
        return "Unknown"
    end

    local function getExpForLevel(level)
           level = level - 1
            return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
    end

    local function getMinimumLevel(skill)

        if skill == "LEVEL" then
            if player:getStorageValue(minimumLevelUp1Stor) == 1 then
            return minimumLevelUp1
            else
            return minimumLevel
            end
        end    
    
        if vocation == 1 or vocation == 5 then
            if skill == SKILL_CLUB or skill == SKILL_SWORD or skill == SKILL_AXE or skill == SKILL_DISTANCE then
            return 10
            end
            if skill == SKILL_SHIELD then
                if player:getStorageValue(sorcererShieldUp1Stor) == 1 then
                return sorcererShieldUp1
                else
                return sorcererShield
                end
            end
            if skill == "MAGIC" then
                if player:getStorageValue(sorcererMagicUp1Stor) == 1 then
                return sorcererMagicUp1
                else
                return sorcererMagic
                end
            end
        end
        if vocation == 2 or vocation == 6 then
            if skill == SKILL_CLUB or skill == SKILL_SWORD or skill == SKILL_AXE or skill == SKILL_DISTANCE then
            return 10
            end
            if skill == SKILL_SHIELD then
                if player:getStorageValue(druidShieldUp1Stor) == 1 then
                return druidShieldUp1
                else
                return druidShield
                end
            end
            if skill == "MAGIC" then
                if player:getStorageValue(druidMagicUp1Stor) == 1 then
                return druidMagicUp1
                else
                return druidMagic
                end
            end
        end
        if vocation == 3 or vocation == 7 then
            if skill == SKILL_CLUB or skill == SKILL_SWORD or skill == SKILL_AXE then
            return 10
            end
            if skill == SKILL_DISTANCE then
                if player:getStorageValue(paladinDistanceUp1Stor) == 1 then
                return paladinDistanceUp1
                else
                return paladinDistance
                end
            end
            if skill == SKILL_SHIELD then
                if player:getStorageValue(paladinShieldUp1Stor) == 1 then
                return paladinShieldUp1
                else
                return paladinShield
                end
            end
            if skill == "MAGIC" then
                if player:getStorageValue(paladinMagicUp1Stor) == 1 then
                return paladinMagicUp1
                else
                return paladinMagic
                end
            end
        end
        if vocation == 4 or vocation == 8 then
            if skill == SKILL_DISTANCE then
            return 10
            end
            if skill == SKILL_CLUB or skill == SKILL_SWORD or skill == SKILL_AXE then
                if player:getStorageValue(knightMeleeUp1Stor) == 1 then
                return knightMeleeUp1
                else
                return knightMelee
                end
            end
            if skill == SKILL_SHIELD then
                if player:getStorageValue(knightShieldUp1Stor) == 1 then
                return knightShieldUp1
                else
                return knightShield
                end
            end
            if skill == "MAGIC" then
                if player:getStorageValue(knightMagicUp1Stor) == 1 then
                return knightMagicUp1
                else
                return knightMagic
                end
            end
        end
    end

    local function getRemainingDoubleFragReward(player)
        if player:getStorageValue(doubleFragRewardStor) >= 1 then
        return player:getStorageValue(doubleFragRewardStor)
        else
        return 0
        end
    end

    local function getRemainingExtraExp(player)
        if player:getStorageValue(extraExpStor) >= 1 then
        return player:getStorageValue(extraExpStor)
        else
        return 0
        end
    end

    local temple = getGlobalStorageValue(currentMap) 
    player:teleportTo(mapPositions[temple])
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, everyLoginMessage)

    if player:getLastLoginSaved() <= 0 then
        if player:getGroup():getId() < 2 then
            player:setStorageValue(fragStor, 0)
            player:setStorageValue(deathStor, 0)
            player:setStorageValue(doubleFragRewardStor, bonusFragReward)
            player:setStorageValue(extraExpStor, bonusExpReward)
            player:addExperience(getExpForLevel(startLevel) - player:getExperience())
        end
        if string.lower(promoteOnLogin) ~= "no" then
            if player:getGroup():getId() < 2 then
                player:setVocation(promotion)
            end
        end
        if string.lower(giveFirstItems) ~= "no" then
            if player:getGroup():getId() < 2 then
                for _, v in ipairs(commonItems) do
                    player:addItem(v.itemid, v.count or 1)
                end

                local giveItems = firstItems[vocation]

                if giveItems ~= nil then
                    for _, v in ipairs(giveItems) do
                        player:addItem(v.itemid, v.count or 1)
                    end
                end
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have recieved your first items!")
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, newPlayerMessage)
            end
        end
    end

    if string.lower(enableMinimumLevel) ~= "no" then
        if player:getLevel() < getMinimumLevel("LEVEL") then
            if player:getGroup():getId() < 2 then
                player:addExperience(getExpForLevel(getMinimumLevel("LEVEL")) - player:getExperience())
            end
        end
    end

    if string.lower(fullBlessOnLogin) ~= "no" then
        if player:getGroup():getId() < 2 then
            player:addPremiumDays(1)
            player:addBlessing(1)
            player:addBlessing(2)
            player:addBlessing(3)
            player:addBlessing(4)
            player:addBlessing(5)
        end
    end

    if string.lower(displayStatsOnLogin) ~= "no" then
        if player:getGroup():getId() < 2 then
        player:popupFYI("" .. player:getName() .. " the " .. getVocationName(player) .. " " ..
                    "\nKills: " .. player:getStorageValue(fragStor) .. " | Deaths: " .. player:getStorageValue(deathStor) .. " " ..
                    "\n " ..
                    "\nCharacter Stat: Current Level | (Minimum Level) " ..
                    "\n " ..
                    "\nExperience Level: " .. player:getLevel()  .. " | (" .. getMinimumLevel("LEVEL") .. ") " ..
                    "\nMagic Level: " .. player:getMagicLevel() .. " | (" .. getMinimumLevel("MAGIC") .. ") " ..
                    "\nClub Fighting: " .. player:getSkillLevel(SKILL_CLUB) .. " | (" .. getMinimumLevel(SKILL_CLUB) .. ") " ..
                    "\nSword Fighting: " .. player:getSkillLevel(SKILL_SWORD) .. " | (" .. getMinimumLevel(SKILL_SWORD) .. ") " ..
                    "\nAxe Fighting: " .. player:getSkillLevel(SKILL_AXE) .. " | (" .. getMinimumLevel(SKILL_AXE) .. ") " ..
                    "\nDistance Fighting: " .. player:getSkillLevel(SKILL_DISTANCE) .. " | (" .. getMinimumLevel(SKILL_DISTANCE) .. ") " ..
                    "\nShielding: " .. player:getSkillLevel(SKILL_SHIELD) .. " | (" .. getMinimumLevel(SKILL_SHIELD) .. ") " ..
                    "\n " ..
                    "\nBONUS FRAGS REMAINING: " ..
                    "\nDouble GOLD: " .. getRemainingDoubleFragReward(player) .. " " ..
                    "\nExtra EXP: " .. getRemainingExtraExp(player) .. " " ..
                    "\n " ..
                    "\nPurchase upgrades on the website! " ..
                    "\n ")
        end
    end

    if string.lower(enableMinimumSkills) ~= "no" then
    if player:getGroup():getId() < 2 then
        if vocation == 1 or vocation == 5 then
            while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
                player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
            end
            while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
                   player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
            end
        end
        
        if vocation == 2 or vocation == 6 then
            while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
                player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
            end
            while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
                   player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
            end
        end
        
        if vocation == 3 or vocation == 7 then
            while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
                player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
            end
            while player:getSkillLevel(SKILL_DISTANCE) < getMinimumLevel(SKILL_DISTANCE) do
                player:addSkillTries(SKILL_DISTANCE, player:getVocation():getRequiredSkillTries(SKILL_DISTANCE, player:getSkillLevel(SKILL_DISTANCE) + 1) - player:getSkillTries(SKILL_DISTANCE))
            end
            while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
                   player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
            end
        end
    
        if vocation == 4 or vocation == 8 then
            while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
                player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
            end
            while player:getSkillLevel(SKILL_SWORD) < getMinimumLevel(SKILL_SWORD) do
                player:addSkillTries(SKILL_SWORD, player:getVocation():getRequiredSkillTries(SKILL_SWORD, player:getSkillLevel(SKILL_SWORD) + 1) - player:getSkillTries(SKILL_SWORD))
            end
            while player:getSkillLevel(SKILL_AXE) < getMinimumLevel(SKILL_AXE) do
                player:addSkillTries(SKILL_AXE, player:getVocation():getRequiredSkillTries(SKILL_AXE, player:getSkillLevel(SKILL_AXE) + 1) - player:getSkillTries(SKILL_AXE))
            end
            while player:getSkillLevel(SKILL_CLUB) < getMinimumLevel(SKILL_CLUB) do
                player:addSkillTries(SKILL_CLUB, player:getVocation():getRequiredSkillTries(SKILL_CLUB, player:getSkillLevel(SKILL_CLUB) + 1) - player:getSkillTries(SKILL_CLUB))
            end
            while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
                   player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
            end
        end
    end
    end

    if string.lower(enableStartSkills) ~= "no" then
    if player:getGroup():getId() < 2 then
        if vocation == "sorcerer" or vocation == "master sorcerer" then
            while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
                player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
            end
            while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
                   player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
            end
        end
        
        if vocation == "druid" or vocation == "elder druid" then
            while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
                player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
            end
            while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
                   player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
            end
        end
        
        if vocation == "paladin" or vocation == "royal paladin" then
            while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
                player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
            end
            while player:getSkillLevel(SKILL_DISTANCE) < getMinimumLevel(SKILL_DISTANCE) do
                player:addSkillTries(SKILL_DISTANCE, player:getVocation():getRequiredSkillTries(SKILL_DISTANCE, player:getSkillLevel(SKILL_DISTANCE) + 1) - player:getSkillTries(SKILL_DISTANCE))
            end
            while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
                   player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
            end
        end
    
        if vocation == "knight" or vocation == "elite knight" then
            while player:getSkillLevel(SKILL_SHIELD) < getMinimumLevel(SKILL_SHIELD) do
                player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, player:getSkillLevel(SKILL_SHIELD) + 1) - player:getSkillTries(SKILL_SHIELD))
            end
            while player:getSkillLevel(SKILL_SWORD) < getMinimumLevel(SKILL_SWORD) do
                player:addSkillTries(SKILL_SWORD, player:getVocation():getRequiredSkillTries(SKILL_SWORD, player:getSkillLevel(SKILL_SWORD) + 1) - player:getSkillTries(SKILL_SWORD))
            end
            while player:getSkillLevel(SKILL_AXE) < getMinimumLevel(SKILL_AXE) do
                player:addSkillTries(SKILL_AXE, player:getVocation():getRequiredSkillTries(SKILL_AXE, player:getSkillLevel(SKILL_AXE) + 1) - player:getSkillTries(SKILL_AXE))
            end
            while player:getSkillLevel(SKILL_CLUB) < getMinimumLevel(SKILL_CLUB) do
                player:addSkillTries(SKILL_CLUB, player:getVocation():getRequiredSkillTries(SKILL_CLUB, player:getSkillLevel(SKILL_CLUB) + 1) - player:getSkillTries(SKILL_CLUB))
            end
            while player:getBaseMagicLevel() < getMinimumLevel("MAGIC") do
                   player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
            end
        end
    end
    end
    
    creatureevent:register() -- footer/end

local creatureevent2 = CreatureEvent("register onLogin") -- header 2

function creatureevent2.onLogin(player)
    player:registerEvent("PrepareDeath")
    player:registerEvent("DeathStats")
    return true
end

creatureevent2:register() -- footer/end
 
line 5 change:

function onLogin(player)

to

function creatureevent.onLogin(player)
Alright, something ain't workin as It should. The FragReward Script works.
(TFWS_GLOBAL)
The original Is here: [10.77+ - TFS 1.2] The Forgotten [WAR] Server v1.1 (UPDATED 17/12/15) (https://otland.net/threads/10-77-tfs-1-2-the-forgotten-war-server-v1-1-updated-17-12-15.234453/)

I would manage to do this the normal way but that ain't possible?
My edited ones:
Creaturescripts:
Fragreward.lua
warlogin.lua
deathstats.lua

Globalevents:
War_startup.lua

Where config.lua lays (Main Folder)
War_config.lua
 

Attachments

Last edited:
Alright, something ain't workin as It should. The FragReward Script works.
(TFWS_GLOBAL)
The original Is here: [10.77+ - TFS 1.2] The Forgotten [WAR] Server v1.1 (UPDATED 17/12/15) (https://otland.net/threads/10-77-tfs-1-2-the-forgotten-war-server-v1-1-updated-17-12-15.234453/)

I would manage to do this the normal way but that ain't possible?
My edited ones:
Creaturescripts:
Fragreward.lua
warlogin.lua
deathstats.lua

Globalevents:
War_startup.lua

Where config.lua lays (Main Folder)
War_config.lua

revscript were implemented on 2019, I highly doubt this tfs support this
 
revscript were implemented on 2019, I highly doubt this tfs support this
Ah, right.. Is there anyway to rescript it into it or else create a script that keeps level to min 120/skills to a minimum for all players?
Then the deaths non loss of items and an option for exp/skills?
Would like to get a sample I can go from cus I want to learn it myself but I'll need a hand with this one

Managed to get the level capped to 120 with, had to change the function from (cid) to (cid, player) than add in the header/footer for Rev
Now, skills depending on vocations
Lua:
local creatureevent = CreatureEvent("onLogin")-- header

function creatureevent.onLogin(cid, player)
     local player = Player(cid)
     if player:getLevel() < 120 then
         player:addExperience(getExpForLevel(120) - player:getExperience(), true)
    end
    return true
end

creatureevent:register() -- footer/end
 
Last edited:
Lua:
-- Reward and amount
local config = {
    itemDrop = ITEM_PLATINUM_COIN,
    itemAmount = 1
}

local creatureevent = CreatureEvent("PVP Reward")-- header

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- Let's make sure non-viable players can't generate a reward
    local player = creature:getPlayer()
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return false
    end

    local master = killer:getMaster()
    -- If the killer is a player the killer should get rewarded (duh?)
    if killer:isPlayer() then
        killer:addItem(config.itemDrop, config.itemAmount)
        return true
    -- When a player's summon kills another player the summoner should get rewarded (master = summoner, we defined it above)
    elseif killer:isMonster() and master:isPlayer() then
        master:addItem(config.itemDrop, config.itemAmount)
        return true
    end
    -- If none of these are met, there will be no reward
    return false
end

creatureevent:register() -- footer/end

local creatureevent2 = CreatureEvent("register login") -- header 2

function creatureevent2.onLogin(player)
    player:registerEvent("PVP Reward")
    return true
end

creatureevent2:register() -- footer/end
the script does work, want to reward soul too, below
Lua:
master:addItem(config.itemDrop, config.itemAmount)
Added
master:addsoul(1) and player:addsoul(1) how should it be?
 
the script does work, want to reward soul too, below
Lua:
master:addItem(config.itemDrop, config.itemAmount)
Added
master:addsoul(1) and player:addsoul(1) how should it be?

Lua:
-- Reward and amount
local config = {
    itemDrop = ITEM_PLATINUM_COIN,
    itemAmount = 1
}

local creatureevent = CreatureEvent("PVP Reward")-- header

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- Let's make sure non-viable players can't generate a reward
    local player = creature:getPlayer()
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return false
    end

    local master = killer:getMaster()
    -- If the killer is a player the killer should get rewarded (duh?)
    if killer:isPlayer() then
        killer:addItem(config.itemDrop, config.itemAmount)
        killer:addSoul(1)
        return true
    -- When a player's summon kills another player the summoner should get rewarded (master = summoner, we defined it above)
    elseif killer:isMonster() and master:isPlayer() then
        master:addItem(config.itemDrop, config.itemAmount)
        master:addSoul(1)
        return true
    end
    -- If none of these are met, there will be no reward
    return false
end

creatureevent:register() -- footer/end

local creatureevent2 = CreatureEvent("register login") -- header 2

function creatureevent2.onLogin(player)
    player:registerEvent("PVP Reward")
    return true
end

creatureevent2:register() -- footer/end
 
Lua:
-- Reward and amount
local config = {
    itemDrop = ITEM_PLATINUM_COIN,
    itemAmount = 1
}

local creatureevent = CreatureEvent("PVP Reward")-- header

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- Let's make sure non-viable players can't generate a reward
    local player = creature:getPlayer()
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return false
    end

    local master = killer:getMaster()
    -- If the killer is a player the killer should get rewarded (duh?)
    if killer:isPlayer() then
        killer:addItem(config.itemDrop, config.itemAmount)
        killer:addSoul(1)
        return true
    -- When a player's summon kills another player the summoner should get rewarded (master = summoner, we defined it above)
    elseif killer:isMonster() and master:isPlayer() then
        master:addItem(config.itemDrop, config.itemAmount)
        master:addSoul(1)
        return true
    end
    -- If none of these are met, there will be no reward
    return false
end

creatureevent:register() -- footer/end

local creatureevent2 = CreatureEvent("register login") -- header 2

function creatureevent2.onLogin(player)
    player:registerEvent("PVP Reward")
    return true
end

creatureevent2:register() -- footer/end
Lua:
-- Reward and amount
local config = {
    itemDrop = ITEM_PLATINUM_COIN,
    itemAmount = 2
}

local creatureevent = CreatureEvent("PVP Reward")-- header

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- Let's make sure non-viable players can't generate a reward
    local player = creature:getPlayer()
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return false
    end

    local master = killer:getMaster()
    -- If the killer is a player the killer should get rewarded (duh?)
    if killer:isPlayer() then
        killer:addItem(config.itemDrop, config.itemAmount)
        killer:addSoul(2)
        return true
    -- When a player's summon kills another player the summoner should get rewarded (master = summoner, we defined it above)
    elseif killer:isMonster() and master:isPlayer() then
        master:addItem(config.itemDrop, config.itemAmount)
       killer:addSoul(2)
        return true
    end
    -- If none of these are met, there will be no reward
    return false
end

creatureevent:register() -- footer/end

local creatureevent2 = CreatureEvent("register login") -- header 2

function creatureevent2.onLogin(player)
    player:registerEvent("PVP Reward")
    return true
end
is giving gold but not soul im using tfs 1.5

i tried this too but not working, any hint? of what i'm doing wrong
Code:
local killevent = CreatureEvent("PVP Reward2")

function killevent.onKill(player, target)
if target:isPlayer() then
player:addSoul(1)
--position:sendMagicEffect(CONST_ME_MAGIC_BLUE, cid)
end
return true
end
killevent:register()

local login = CreatureEvent("PVP Reward2")

function login.onLogin(player)
    player:registerEvent("PVP Reward2")
    return true
end

which variable is for remove soul or set it to 0 player:addSoul(-1)?
thanks in advance
 
it is working, I just tested, your problem is that you are trying to give soul to a player that already have full soul points



Lua:
player:addSoul(-100)
no bro in fact i thougt that it might be the problem, have soul 93 and character does not gain soul
tested in my datapack and in nekiro's clean and is not working is just gaining gold but no soul
edit: yes you were right it's working i removed few tings without notice.

thank for telling me how to remove soul and for the script
 
Last edited:
Lua:
-- Reward and amount
local config = {
    itemDrop = ITEM_PLATINUM_COIN,
    itemAmount = 2
}

local creatureevent = CreatureEvent("PVP Reward")-- header

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- Let's make sure non-viable players can't generate a reward
    local player = creature:getPlayer()
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return false
    end

    local master = killer:getMaster()
    -- If the killer is a player the killer should get rewarded (duh?)
    if killer:isPlayer() then
        killer:addItem(config.itemDrop, config.itemAmount)
        killer:addSoul(2)
        return true
    -- When a player's summon kills another player the summoner should get rewarded (master = summoner, we defined it above)
    elseif killer:isMonster() and master:isPlayer() then
        master:addItem(config.itemDrop, config.itemAmount)
       killer:addSoul(2)
        return true
    end
    -- If none of these are met, there will be no reward
    return false
end

creatureevent:register() -- footer/end

local creatureevent2 = CreatureEvent("register login") -- header 2

function creatureevent2.onLogin(player)
    player:registerEvent("PVP Reward")
    return true
end
is giving gold but not soul im using tfs 1.5

i tried this too but not working, any hint? of what i'm doing wrong
Code:
local killevent = CreatureEvent("PVP Reward2")

function killevent.onKill(player, target)
if target:isPlayer() then
player:addSoul(1)
--position:sendMagicEffect(CONST_ME_MAGIC_BLUE, cid)
end
return true
end
killevent:register()

local login = CreatureEvent("PVP Reward2")

function login.onLogin(player)
    player:registerEvent("PVP Reward2")
    return true
end

which variable is for remove soul or set it to 0 player:addSoul(-1)?
thanks in advance
local killevent = CreatureEvent("PVP Reward2")
local login = CreatureEvent("PVP Reward2")

You named both your events the same thing. This is generally a bad idea.
They might over-write each other, or error as duplicate.
player:registerEvent("PVP Reward2")
Which then causes this to not trigger, or trigger incorrectly.
 
local killevent = CreatureEvent("PVP Reward2")
local login = CreatureEvent("PVP Reward2")

You named both your events the same thing. This is generally a bad idea.
They might over-write each other, or error as duplicate.
player:registerEvent("PVP Reward2")
Which then causes this to not trigger, or trigger incorrectly.
thank you a lot
 
Back
Top