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

Lua What is doPlayerSetLossPercent for 1.0?

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,738
Solutions
7
Reaction score
541
Location
Canada
As the title says, I am trying to figure out what I replace doPlayerSetLossPercent with in 1.0.

Example:
Code:
function onDeath(cid, corpse)
   if isPlayer(cid) then
     if (getPlayerLevel(cid) < 100 then
       doPlayerSetLossPercent(cid, PLAYERLOSS_ITEMS, 0)
  doPlayerSetLossPercent(cid, PLAYERLOSS_CONTAINERS, 0)
  else
  doPlayerSetLossPercent(cid, PLAYERLOSS_ITEMS, 100)
  doPlayerSetLossPercent(cid, PLAYERLOSS_CONTAINERS, 100)
     end
   end
   return true
end

Error:
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/protection.lua:onDeath
data/creaturescripts/scripts/others/protection.lua:4: attempt to call global 'do
PlayerSetLossPercent' (a nil value)
stack traceback:
  [C]: in function 'doPlayerSetLossPercent'
  data/creaturescripts/scripts/others/protection.lua:4: in function <data/
creaturescripts/scripts/others/protection.lua:1>

Sorry for the nub question, seems like this shouldn't have even been switched!
 
Can someone also help me convert this script to 1.0 please and thank you!

Code:
local t = {
   39001, {
   [35] = {2160, 1, "You have been awarded with 1 crystal coin for reaching level 35!", 1},   
   [50] = {2160, 2, "You have been awarded with 2 crystal coins for reaching level 50!", 2},
   [75] = {2160, 5, "You have been awarded with 5 crystal coins for reaching level 75!", 3},
   [100] = {2160, 10, "You have been awarded with 10 crystal coins for reaching level 100!", 4},
   [200] = {2160, 25, "You have been awarded with 100 crystal coins for reaching level 200!", 5}
   }
}
function onAdvance(cid, skill, oldlevel, newlevel)
   if skill == SKILL__LEVEL then
     for level, v in pairs(t[2]) do
       if oldlevel < level and getPlayerLevel(cid) >= level and getPlayerStorageValue(cid, t[1]) < v[4] then
         doPlayerAddItem(cid, v[1], v[2])
         doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, v[3])
         setPlayerStorageValue(cid, t[1], v[4])
       end
     end
   end
   doPlayerSave(cid, true)
   return true
end
 
Code:
local t = {
  39001, {
    [35] = {2160, 1, "You have been awarded with 1 crystal coin for reaching level 35!", 1},
    [50] = {2160, 2, "You have been awarded with 2 crystal coins for reaching level 50!", 2},
    [75] = {2160, 5, "You have been awarded with 5 crystal coins for reaching level 75!", 3},
    [100] = {2160, 10, "You have been awarded with 10 crystal coins for reaching level 100!", 4},
    [200] = {2160, 25, "You have been awarded with 100 crystal coins for reaching level 200!", 5}
    }
}

function onAdvance(cid, skill, oldlevel, newlevel)
    local player = Player(cid)
    for level, v in pairs(t[2]) do
        if skill == SKILL_LEVEL and oldlevel < level and player:getLevel() >= level and player:getStorageValue(t[1]) < v[4] then
            player:addItem(v[1], v[2])
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, v[3])
            player:setStorageValue(t[1], v[4])
            break
        end
    end
    player:save()
    return true
end
 
@Ninja
Thank you very much, but am I using the wrong event type? Because when I get level 20 it doesn't add.

<event type="advance" name="CashRewards" event="script" value="others/cashrewards.lua"/>

It's still onAdvance so isn't the event type "advance"? Thanks again!
 
In 1.0 go to playerdeath.lua and under this:
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")

add this:
Code:
    if  getPlayerLevel(cid) < 100 and getPlayerSkullType(cid) == SKULL_NONE then
        doSetCreatureDropLoot(cid, false)
    end
 
@Ninja
Thank you very much, but am I using the wrong event type? Because when I get level 20 it doesn't add.

<event type="advance" name="CashRewards" event="script" value="others/cashrewards.lua"/>

It's still onAdvance so isn't the event type "advance"? Thanks again!
You have registered it incorrectly in creaturescripts.xml
Code:
<event type="advance" name="CashRewards" script="others/cashrewards.lua"/>
 
Well i had my cash reward and item reward as shadowcores but i just made it for myself so i didnt need to make tables to make shit easier if you want you can use it also. Hers is firstitems:
In login.lua under player:sendOutfitWindow()
add this:
Code:
        --All
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have recived a backpack, with your first items inside the backpack.")
        local backpack = doPlayerAddItem(cid, 1988, 1) --Backpack
        doAddContainerItem(backpack, 2152, 10) --1k
        doAddContainerItem(backpack, 2120, 1) --Rope
        doAddContainerItem(backpack, 2554, 1) --Shovel
        doAddContainerItem(backpack, 2050, 1) --Torch
        doAddContainerItem(backpack, 2789, 20) --Brown Mushroom
        doAddContainerItem(backpack, 2490, 1) --Dark Helmet
        doAddContainerItem(backpack, 2465, 1) --Brass Armor
        doAddContainerItem(backpack, 2525, 1) --Dwarven Shield
        doAddContainerItem(backpack, 2478, 1) --Brass Legs
        doAddContainerItem(backpack, 2643, 1) --Leather Boots
        doAddContainerItem(backpack, 2152, 20) --20 Platium coins         
        if (isSorcerer(cid)) then 
            doAddContainerItem(backpack, 2190, 1) --Wand of Vortex
        elseif (isDruid(cid)) then
            doAddContainerItem(backpack, 2182, 1) --Snakebite Rod
        elseif (isPaladin(cid)) then
            doAddContainerItem(backpack, 2389, 5) --Spears
        elseif (isKnight(cid)) then
            doAddContainerItem(backpack, 2383, 1) --Spike Sword
            doAddContainerItem(backpack, 2429, 1) --Barbarian Axe
            doAddContainerItem(backpack, 2423, 1) --Clerical Mace
        end

Instead of Ninja script you can use this: it give cash and items on level up also in knight weapon it check highest skills and cash get sent to bank:
Just replace creaturescript/others/levelitems.lua
http://pastebin.com/6TB5aTpV

Enjoy.
 
Thank you so much for that levelitems script, that was going to be my next task to get working, and your just works great! Thank you for saving me time, now the server is truely "Player-Friendly" - Thank you again!
 
Back
Top