• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Items on level

denkan97

Well-Known Member
Joined
Dec 27, 2011
Messages
329
Solutions
2
Reaction score
51
Okay so got help with this earlier but got a new problem with this.

Im using this script to give a reward at a specifik lvl.

local items = {
{itemid = 7458, count = 1},
{itemid = xxxx, count = yyyy}
}

local bagId = 2000

function onAdvance(cid, skill, oldlevel, newlevel)
if newlevel >= 150 and getCreatureStorage(cid, 44923) == -1 then
local bag = doPlayerAddItem(cid, bagId)
for _, item in ipairs(items) do
doAddContainerItem(bag, item.itemid, item.count)
end
doCreatureSetStorage(cid, 44923, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You've just recieved mammoth set for reaching level 150!")
end
return true
end

But now if i want it to give a wand to a sorcerer and a axe to a knight do i need to make 2 new scripts to give that? Or is it possible to make this script give knight his items and mages there items at the same lvl?

And what change do i make to the script if i would like it to give items at more then one level?

If you are a nice guy you can tell me how and what you changed so i can learn this shit, trying to learn by trying around but not the easyest. :confused:

(sry for bad english :D)
 
Last edited:
Solution
No, i meant you not publishing a solution of the issue you lately asked people to make for you is a dick move.
It's not like it is some great, complex lua system, so i don't know what's the problem.

Ehh fuck it your right :rolleyes:
With this one tho you need one for each reward insted of the other one where you could add more then one.

LUA:
function onAdvance(cid, skill, oldlevel, newlevel)
    if(getPlayerStorageValue(cid, 99961) ~= 1 and skill == SKILL__LEVEL and newlevel >= 300) then
    if isSorcerer(cid) then
            doPlayerAddItem(cid, 2160, 10)
        elseif isDruid(cid) then
            doPlayerAddItem(cid, 2160, 10)
        elseif isPaladin(cid) then
            doPlayerAddItem(cid, 2160, 10)
        elseif...
LUA:
local levels = {
[20] = {storage = 30000, vocations = {
                    [1] = {items = { --Level 20 items
                            [1] = {itemid = 1111, count = 1},
                            [2] = {itemid = 1111, count = 1}
                    }},
                    [2] = {items = {
                            [1] = {itemid = 1111, count = 1},
                            [2] = {itemid = 1111, count = 1}
                    }},
                    [3] = {items = {
                            [1] = {itemid = 1111, count = 1},
                            [2] = {itemid = 1111, count = 1}
                        }},
                    [4] = {items = {
                            [1] = {itemid = 1111, count = 1},
                            [2] = {itemid = 1111, count = 1}
                    }}
                    --If you have more vocations then sorc, druid, pala, knight add here [5]
                    }},
[40] = {storage = 30001, vocations = {
                    [1] = {items = { --Level 40 items
                            [1] = {itemid = 1111, count = 1},
                            [2] = {itemid = 1111, count = 1}
                            }},
                    [2] = {items = {
                            [1] = {itemid = 1111, count = 1},
                            [2] = {itemid = 1111, count = 1}
                            }},
                    [3] = {items = {
                            [1] = {itemid = 1111, count = 1},
                            [2] = {itemid = 1111, count = 1}
                            }},
                    [4] = {items = {
                            [1] = {itemid = 1111, count = 1},
                            [2] = {itemid = 1111, count = 1}
                            }}
                    --If you have more vocations then sorc, druid, pala, knight add here [5]
                    }}
--Add new levels here for more items
}

local bag_id = 2000

function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= SKILL_LEVEL then return true end
   
    LEVEL = levels[skill]
   
    if not LEVEL then return true end
   
    if getPlayerStorageValue(cid, LEVEL.storage) ~= -1 then return true end
   
    VOC = LEVEL.vocations[getPlayerBaseVocation(cid)]
   
    if not VOC then return true end
   
    setPlayerStorageValue(cid, storage, 1)
   
    BAG = doPlayerAddItem(cid, bag_id, 1)
   
    for i = 1, #VOC.items do
        doAddContainerItem(BAG, VOC.items[i].itemid, VOC.items[i].count)
    end
   
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have reached level "..skill.." and have been rewarded with items!")
return true
end
 
Last edited:
Have added.

registerCreatureEvent(cid, "levelpot") (In login.lua)

and
<event type="advance" name="levelpot" event="script" value="levelpot.lua"/>

But cant get it to work did i forget something?
 
Have added.

registerCreatureEvent(cid, "levelpot") (In login.lua)

and
<event type="advance" name="levelpot" event="script" value="levelpot.lua"/>

But cant get it to work did i forget something?
are you receiving any errors in console?
check to see if it's working by adding
Code:
print(1)
on the Next Line after the function onAdvance.
This will print to the console.
 
are you receiving any errors in console?
check to see if it's working by adding
on the Next Line after the function onAdvance.
This will print to the console.

So have added print to see if i could see the problem but still nothing in consol

LUA:
local levels = {
[50] = {storage = 30011, vocations = {
                    [1] = {items = { --Level 50 items
                            [1] = {itemid = 7589, count = 1},
                            [2] = {itemid = 2160, count = 10}
                    }},
                    [2] = {items = {
                            [1] = {itemid = 7589, count = 1},
                            [2] = {itemid = 2160, count = 10}
                    }},
                    [3] = {items = {
                            [1] = {itemid = 7589, count = 1},
                            [1] = {itemid = 7588, count = 1},
                            [2] = {itemid = 2160, count = 10}
                        }},
                    [4] = {items = {
                            [1] = {itemid = 7588, count = 1},
                            [2] = {itemid = 2160, count = 10}
                    }}
                    --If you have more vocations then sorc, druid, pala, knight add here [5]
                    }},
[80] = {storage = 30012, vocations = {
                    [1] = {items = { --Level 80 items
                            [1] = {itemid = 7590, count = 1},
                            [2] = {itemid = 2160, count = 15}
                            }},
                    [2] = {items = {
                            [1] = {itemid = 7590, count = 1},
                            [2] = {itemid = 2160, count = 15}
                            }},
                    [3] = {items = {
                            [1] = {itemid = 8472, count = 1},
                            [2] = {itemid = 2160, count = 15}
                            }},
                    [4] = {items = {
                            [1] = {itemid = 7591, count = 1},
                            [2] = {itemid = 2160, count = 15}
                            }}
                    --If you have more vocations then sorc, druid, pala, knight add here [5]
                    }}
--Add new levels here for more items
}

local bag_id = 2000
local amount_base_vocations = 4 --Set this to how many vocations you have EX: sorc, druid, pala, knight = 4

function onAdvance(cid, skill, oldlevel, newlevel)
    print(1)
    if skill ~= SKILL_LEVEL then return true end
  
    LEVEL = levels[skill]
  
    if not LEVEL then return true end
  
    if getPlayerStorageValue(cid, LEVEL.storage) ~= -1 then return true end
  
    VOC = LEVEL.vocations[getPlayerVocation(cid)]
    local promote1 = getPlayerVocation(cid) - amount_base_vocations
    VOC2 = LEVEL.vocations[promote1]
    local promote2 = getPlayerVocation(cid) - amount_base_vocations - amount_base_vocations
    VOC3 = LEVEL.vocations[promote2]
    local promote3 = getPlayerVocation(cid) - amount_base_vocations - amount_base_vocations - amount_base_vocations
    VOC4 = LEVEL.vocations[promote3]
  
    if not VOC1 and not VOC2 and not VOC3 and not VOC4 then return true end
  
    if VOC then
    setPlayerStorageValue(cid, storage, 1)
  
    BAG = doPlayerAddItem(cid, bag_id, 1)
  
    for i = 1, #VOC.items do
        doAddContainerItem(BAG, VOC.items[i].itemid, VOC.items[i].count)
    end
  
    elseif VOC2 then
    setPlayerStorageValue(cid, storage, 1)
  
    BAG = doPlayerAddItem(cid, bag_id, 1)
  
    for i = 1, #VOC1.items do
        doAddContainerItem(BAG, VOC2.items[i].itemid, VOC2.items[i].count)
    end
  
    elseif VOC3 then
    setPlayerStorageValue(cid, storage, 1)
  
    BAG = doPlayerAddItem(cid, bag_id, 1)
  
    for i = 1, #VOC3.items do
        doAddContainerItem(BAG, VOC3.items[i].itemid, VOC3.items[i].count)
    end
  
    elseif VOC4 then
    setPlayerStorageValue(cid, storage, 1)
  
    BAG = doPlayerAddItem(cid, bag_id, 1)
  
    for i = 1, #VOC3.items do
        doAddContainerItem(BAG, VOC4.items[i].itemid, VOC4.items[i].count)
    end
    end
  
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have reached level "..skill.." and have been rewarded with items!")
return true
end

thats the script.

Had help from @Itutorial but i'm too stupid to make it right xd


LUA:
  registerCreatureEvent(cid, "levelpot")

This is added in login.lua

XML:
 <event type="advance" name="levelpot" event="script" value="levelpot.lua"/>

And that in creaturescripts.xml

But still cant get it to work (Keep in mind im totaly new to this so dont know what im doing half of the time :D)
 
Unfortunately, I am not familiar with the bugs of that distro. In your console you don't see a 1?

You could try changing:
Code:
if skill ~= SKILL_LEVEL then return true end

to

Code:
if skill ~= SKILL__LEVEL then return true end
 
If above doesn't work, you could try
Code:
if skill ~= 8 then return true end

Btw, are you sure the code is not erroring when you start-up the server?
Otherwise you should definitely see "1" being printed to console, anytime a skill or level is obtained by a player.
 
@Xikini @Itutorial

Got a friend to send me a working script in confidence that i didn't share it, so got it working for me but cant share it.
Thx for all the help tho!

And i did see the 1 get printed and didnt get an error
 
@Xikini @Itutorial

Got a friend to send me a working script in confidence that i didn't share it, so got it working for me but cant share it.
Thx for all the help tho!

And i did see the 1 get printed and didnt get an error
then don't be a leech and ask us to do things for you if you aren't interested in being a part of a community and keeping things to yourself.
 
then don't be a leech and ask us to do things for you if you aren't interested in being a part of a community and keeping things to yourself.

Was asking for help becouse i did not know what i was doing and still dont. And if i manage to get it from a friend and he told me not to share it im gonna respect that and not share it sry.

Rly like the help i got from @Xikini and @Itutorial but im not gonna try around to fix the script when i got another one working, feels like a waste of time when i cant even understading half of it. (Im a mapped dont know shit about scripts)
 
Was asking for help becouse i did not know what i was doing and still dont. And if i manage to get it from a friend and he told me not to share it im gonna respect that and not share it sry.

Rly like the help i got from @Xikini and @Itutorial but im not gonna try around to fix the script when i got another one working, feels like a waste of time when i cant even understading half of it. (Im a mapped dont know shit about scripts)
Yeah, but you're posting support threads since 2016. Don't you really think that's a time to at least try to start getting to know your shit around, if you wanna have a server? It's not that hard as it looks.

@Xikini @Itutorial

Got a friend to send me a working script in confidence that i didn't share it, so got it working for me but cant share it.
Thx for all the help tho!

And i did see the 1 get printed and didnt get an error
And this is really a dick move...
 
Yeah, but you're posting support threads since 2016. Don't you really think that's a time to at least try to start getting to know your shit around, if you wanna have a server? It's not that hard as it looks.

The reason to this is the lack of intrest from time to time and the person im working with (the scripter) got out of school and got a job so he dont got much time to use to help me out (and i have no clue where to learn this shit becouse for me its hard to understand)

And this is really a dick move...

I understand what you are pointing at on this but i dont feel like using the time to try to get it to work when i dont know much about it :confused:
 
The reason to this is the lack of intrest from time to time and the person im working with (the scripter) got out of school and got a job so he dont got much time to use to help me out (and i have no clue where to learn this shit becouse for me its hard to understand)
It's not that you don't understand, but you don't want to do this. You can search through forum, i guess there are plenty of tutorials on how to script.
Then, when you got to know the syntax better, you can try to start to tinker with already existing scripts.
Start with something small, chop a parts of code and get them together. Go try-and-error until you make it work.
Use print() a lot, its helpful.

I understand what you are pointing at on this but i dont feel like using the time to try to get it to work when i dont know much about it :confused:
No, i meant you not publishing a solution of the issue you lately asked people to make for you is a dick move.
It's not like it is some great, complex lua system, so i don't know what's the problem.
 
No, i meant you not publishing a solution of the issue you lately asked people to make for you is a dick move.
It's not like it is some great, complex lua system, so i don't know what's the problem.

Ehh fuck it your right :rolleyes:
With this one tho you need one for each reward insted of the other one where you could add more then one.

LUA:
function onAdvance(cid, skill, oldlevel, newlevel)
    if(getPlayerStorageValue(cid, 99961) ~= 1 and skill == SKILL__LEVEL and newlevel >= 300) then
    if isSorcerer(cid) then
            doPlayerAddItem(cid, 2160, 10)
        elseif isDruid(cid) then
            doPlayerAddItem(cid, 2160, 10)
        elseif isPaladin(cid) then
            doPlayerAddItem(cid, 2160, 10)
        elseif isKnight(cid) then
            doPlayerAddItem(cid, 2160, 10)


end
setPlayerStorageValue(cid, 99961, 1)
doPlayerSendTextMessage(cid, 22, "Congratulations you have recieved a reward for reaching level 300!")
end
return true
end

It's not that you don't understand, but you don't want to do this. You can search through forum, i guess there are plenty of tutorials on how to script.
Then, when you got to know the syntax better, you can try to start to tinker with already existing scripts.
Start with something small, chop a parts of code and get them together. Go try-and-error until you make it work.
Use print() a lot, its helpful.

Think im gonna give it another try to learn it ;)
 
Solution
Back
Top