• 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 First Skills

Way20

Well-Known Member
Joined
Sep 29, 2014
Messages
205
Solutions
3
Reaction score
79
I'm making a 7.72 war server, I fixed everything that I need but every first skills script that I tried to use on OTHire didn't worked. I'm using ZnoteAAC too, but unlike gesior it doesnt have sample characters that come with level, skills, etc right from DB.

I tried this one first.
Code:
function onLogin(cid)
local reqTries = getPlayerRequiredSkillTries
local skillStor = 56367
local gotSkills = getPlayerStorageValue(cid, 56364)


if isPlayer(cid) and getPlayerVocation(cid) >= 1 and gotSkills == -1 then
doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,60)))
setPlayerStorageValue(cid, skillStor, 1)

elseif isPlayer(cid) and getPlayerVocation(cid) >= 1 and gotSkills == -1 then
doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,60)))
setPlayerStorageValue(cid, skillStor, 1)

elseif isPlayer(cid) and getPlayerVocation(cid) >= 1 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_DISTANCE, reqTries(cid, SKILL_DISTANCE, 71))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 60))
doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,15)))
setPlayerStorageValue(cid, skillStor, 1)

elseif isPlayer(cid) and getPlayerVocation(cid) >= 1 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_AXE, reqTries(cid, SKILL_AXE, 71))
doPlayerAddSkillTry(cid, SKILL_SWORD, reqTries(cid, SKILL_SWORD, 71))
doPlayerAddSkillTry(cid, SKILL_CLUB, reqTries(cid, SKILL_CLUB, 71))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 60))
doPlayerAddMagLevel(cid, 9)
setPlayerStorageValue(cid, skillStor, 1)

end
return TRUE
end

but OTHire doesn't have the functions doPlayerAddMagLevel and getPlayerRequiredSkillTries, then I tried to do this:
Code:
function onLogin(cid)
local magLevel = getPlayerMagLevel(cid)
local axeSkill = getPlayerSkill(cid, 3)
local distSkill = getPlayerSkill(cid, 4)
local shieldSkill = getPlayerSkill(cid, 5)
if (playerVoc == 4) or (playerVoc == 8) then
           while axeSkill < 70 do
                doPlayerAddSkillTry(cid, 3, 100, 100)
            end
            while shieldSkill < 70 do
                doPlayerAddSkillTry(cid, 5, 100, 100)
            end          
            while magLevel < 6 do
                doPlayerAddManaSpent(cid, 100, 100)
            end
elseif (playerVoc == 3) or (playerVoc == 7)  then
            while distSkill < 70 do
                doPlayerAddSkillTry(cid, 3, 100, 100)
            end
            while shieldSkill < 70 do
                doPlayerAddSkillTry(cid, 5, 100, 100)
            end          
            while magLevel < 15 do
                doPlayerAddManaSpent(cid, 100, 100)
            end  
else
            while magLevel < 40 do
                  doPlayerAddManaSpent(cid, 100, 100)
            end                  
end
end
With this one, the char doesn't even login.

Anyone have any ideia on how I could do it?
 
Last edited:
Solution
Just tested my script, it works.

Code:
function onLogin(cid)
    local lastLogin = getPlayerLastLogin(cid)
    local playerVoc = getPlayerVocation(cid)

    if(lastLogin == 0) then
        local qResult = db.storeQuery("SELECT `town_id` FROM `players` WHERE `id`= 1;")
        local cTown = result.getDataInt(qResult, "town_id")
        doPlayerSetTown(cid, cTown)
        doTeleportThing(cid, getTownTemplePosition(cTown))
        if (playerVoc == 4) or (playerVoc == 8) then
            doPlayerAddItem(cid,2498,1)
            doPlayerAddItem(cid,2432,1)
            doPlayerAddItem(cid,2520,1)
            doPlayerAddItem(cid,2414,1)
            doPlayerAddItem(cid,2492,1)         
            while getPlayerSkill(cid, LEVEL_SKILL_AXE) < 70 do...
That won't work as you want since magLevel, for exemple, is not being updated in the while loop, you not getting playerVoc anywhere, nor returning anything. But no errors?

Code:
function onLogin(cid)

    local playerVoc = getPlayerVocation(cid)

    if (playerVoc == 4) or (playerVoc == 8) then
        while getPlayerSkill(cid, LEVEL_SKILL_AXE) < 70 do
            doPlayerAddSkillTry(cid, LEVEL_SKILL_AXE, 100)
        end
        while getPlayerSkill(cid, LEVEL_SKILL_SHIELDING) < 70 do
            doPlayerAddSkillTry(cid, LEVEL_SKILL_SHIELDING, 100)
        end
        while getPlayerMagLevel(cid) < 6 do
            doPlayerAddManaSpent(cid, 100, 100)
        end
    elseif (playerVoc == 3) or (playerVoc == 7)  then
        while getPlayerSkill(cid, LEVEL_SKILL_DISTANCE) < 70 do
            doPlayerAddSkillTry(cid, LEVEL_SKILL_DISTANCE, 100)
        end
        while getPlayerSkill(cid, LEVEL_SKILL_SHIELDING) < 70 do
            doPlayerAddSkillTry(cid, LEVEL_SKILL_SHIELDING, 100)
        end
        while getPlayerMagLevel(cid) < 15 do
            doPlayerAddManaSpent(cid, 100, 100)
        end
    elseif playerVoc > 0 then
        while getPlayerMagLevel(cid) < 40 do
            doPlayerAddManaSpent(cid, 100, 100)
        end
    end

    return true
end
 
That won't work as you want since magLevel, for exemple, is not being updated in the while loop, you not getting playerVoc anywhere, nor returning anything. But no errors?

My bad, I just cut the lines from the actual script, so it could be easy to read. I'm using the script as first login, giving items and skills to players.

Code:
function onLogin(cid)
    local lastLogin = getPlayerLastLogin(cid)
    local playerVoc = getPlayerVocation(cid)
    local magLevel = getPlayerMagLevel(cid)
    local axeSkill = getPlayerSkill(cid, 3)
    local distSkill = getPlayerSkill(cid, 4)
    local shieldSkill = getPlayerSkill(cid, 5)
  
    if(lastLogin == 0) then
            local qResult = db.storeQuery("SELECT `town_id` FROM `players` WHERE `id`= 1;")
            local cTown = result.getDataInt(qResult, "town_id")
            doPlayerSetTown(cid, cTown)
            doTeleportThing(cid, getTownTemplePosition(cTown))
        if (playerVoc == 4) or (playerVoc == 8) then
            doPlayerAddItem(cid,2498,1)
            doPlayerAddItem(cid,2432,1)
            doPlayerAddItem(cid,2520,1)
            doPlayerAddItem(cid,2414,1)
            doPlayerAddItem(cid,2492,1)          
            --[[while axeSkill < 70 do
                doPlayerAddSkillTry(cid, 3, 100, 100)
            end
            while shieldSkill < 70 do
                doPlayerAddSkillTry(cid, 5, 100, 100)
            end          
            while magLevel < 6 do
                doPlayerAddManaSpent(cid, 100, 100)
            end
            ]]
        elseif (playerVoc == 3) or (playerVoc == 7)  then
            doPlayerAddItem(cid,2498,1)
            doPlayerAddItem(cid,2455,1)
            doPlayerAddItem(cid,2543,1)
            doPlayerAddItem(cid,2466,1)
            --[[while distSkill < 70 do
                doPlayerAddSkillTry(cid, 3, 100, 100)
            end
            while shieldSkill < 70 do
                doPlayerAddSkillTry(cid, 5, 100, 100)
            end          
            while magLevel < 15 do
                doPlayerAddManaSpent(cid, 100, 100)
            end]]  
        else
            doPlayerAddItem(cid,2497,1)
            doPlayerAddItem(cid,2456,1)
            doPlayerAddItem(cid,2546,1)
            doPlayerAddItem(cid,2656,1)
            --[[if (playerVoc == 1) or (playerVoc == 6)  then
                while magLevel < 40 do
                    doPlayerAddManaSpent(cid, 100, 100)
                end                  
            else
                while magLevel < 45 do
                    doPlayerAddManaSpent(cid, 100, 100)
                end              
            end]]
        end
        -- Equips for All Vocs --
        doPlayerAddItem(cid,2643,1)
        doPlayerAddItem(cid,2488,1)          
        Container = doPlayerAddItem(cid, 2000, 1)
        Container = doPlayerAddItem(cid, 1995, 1)
                doAddContainerItem(Container, 2273, 2)
                doAddContainerItem(Container, 2273, 2)
                doAddContainerItem(Container, 2273, 2)
                doAddContainerItem(Container, 2273, 2)
                doAddContainerItem(Container, 2273, 2)
                doAddContainerItem(Container, 2273, 2)
                doAddContainerItem(Container, 2273, 2)
                doAddContainerItem(Container, 2273, 2)
        Container = doPlayerAddItem(cid, 1996, 1)
                doAddContainerItem(Container, 2268, 2)
                doAddContainerItem(Container, 2268, 2)
                doAddContainerItem(Container, 2268, 2)
                doAddContainerItem(Container, 2268, 2)
                doAddContainerItem(Container, 2268, 2)
                doAddContainerItem(Container, 2268, 2)
                doAddContainerItem(Container, 2268, 2)
                doAddContainerItem(Container, 2268, 2)
        Container = doPlayerAddItem(cid, 1993, 1)
                doAddContainerItem(Container, 2261, 2)
                doAddContainerItem(Container, 2305, 2)
                doAddContainerItem(Container, 2261, 2)
                doAddContainerItem(Container, 2305, 2)
                doAddContainerItem(Container, 2262, 2)
                doAddContainerItem(Container, 2310, 2)
                doAddContainerItem(Container, 2286, 2)
                doAddContainerItem(Container, 2291, 2)
        Container = doPlayerAddItem(cid, 1994, 1)
                doAddContainerItem(Container, 2313, 2)
                doAddContainerItem(Container, 2313, 2)
                doAddContainerItem(Container, 2313, 2)
                doAddContainerItem(Container, 2313, 2)
                doAddContainerItem(Container, 2313, 2)
                doAddContainerItem(Container, 2313, 2)
                doAddContainerItem(Container, 2313, 2)
                doAddContainerItem(Container, 2313, 2)
        Container = doPlayerAddItem(cid, 1997, 1)
                doAddContainerItem(Container, 2293, 2)
                doAddContainerItem(Container, 2293, 2)
                doAddContainerItem(Container, 2293, 2)
                doAddContainerItem(Container, 2293, 2)
                doAddContainerItem(Container, 2293, 2)
                doAddContainerItem(Container, 2293, 2)
                doAddContainerItem(Container, 2293, 2)
                doAddContainerItem(Container, 2293, 2)
        Container = doPlayerAddItem(cid, 1987, 1)
                doAddContainerItem(Container, 2006, 7)
                doAddContainerItem(Container, 2006, 7)
                doAddContainerItem(Container, 2006, 7)
                doAddContainerItem(Container, 2006, 7)
                doAddContainerItem(Container, 2006, 7)
                doAddContainerItem(Container, 2006, 7)
                doAddContainerItem(Container, 2006, 7)
                doAddContainerItem(Container, 2006, 7)
        Container = doPlayerAddItem(cid, 3939, 1)
                doAddContainerItem(Container, 2214, 1)
                doAddContainerItem(Container, 2562, 1)
                doAddContainerItem(Container, 2167, 1)
                doAddContainerItem(Container, 2169, 1)
                doAddContainerItem(Container, 2789, 1)
                doAddContainerItem(Container, 2420, 1)
        Container = doPlayerAddItem(cid, 1988, 1)
                doAddContainerItem(Container, 2293, 2)
                doAddContainerItem(Container, 2304, 3)
                doAddContainerItem(Container, 2261, 2)
                doAddContainerItem(Container, 2305, 2)
                doAddContainerItem(Container, 2262, 2)
                doAddContainerItem(Container, 2273, 3)
                doAddContainerItem(Container, 2006, 7)
                doAddContainerItem(Container, 2268, 2)
    end
    return true
end
 
Just tested my script, it works.

Code:
function onLogin(cid)
    local lastLogin = getPlayerLastLogin(cid)
    local playerVoc = getPlayerVocation(cid)

    if(lastLogin == 0) then
        local qResult = db.storeQuery("SELECT `town_id` FROM `players` WHERE `id`= 1;")
        local cTown = result.getDataInt(qResult, "town_id")
        doPlayerSetTown(cid, cTown)
        doTeleportThing(cid, getTownTemplePosition(cTown))
        if (playerVoc == 4) or (playerVoc == 8) then
            doPlayerAddItem(cid,2498,1)
            doPlayerAddItem(cid,2432,1)
            doPlayerAddItem(cid,2520,1)
            doPlayerAddItem(cid,2414,1)
            doPlayerAddItem(cid,2492,1)         
            while getPlayerSkill(cid, LEVEL_SKILL_AXE) < 70 do
                doPlayerAddSkillTry(cid, LEVEL_SKILL_AXE, 100)
            end
            while getPlayerSkill(cid, LEVEL_SKILL_SHIELDING) < 70 do
                doPlayerAddSkillTry(cid, LEVEL_SKILL_SHIELDING, 100)
            end
            while getPlayerMagLevel(cid) < 6 do
                doPlayerAddManaSpent(cid, 100, 100)
            end
        elseif (playerVoc == 3) or (playerVoc == 7)  then
            doPlayerAddItem(cid,2498,1)
            doPlayerAddItem(cid,2455,1)
            doPlayerAddItem(cid,2543,1)
            doPlayerAddItem(cid,2466,1)
            while getPlayerSkill(cid, LEVEL_SKILL_DISTANCE) < 70 do
                doPlayerAddSkillTry(cid, LEVEL_SKILL_DISTANCE, 100)
            end
            while getPlayerSkill(cid, LEVEL_SKILL_SHIELDING) < 70 do
                doPlayerAddSkillTry(cid, LEVEL_SKILL_SHIELDING, 100)
            end
            while getPlayerMagLevel(cid) < 15 do
                doPlayerAddManaSpent(cid, 100, 100)
            end
        else
            doPlayerAddItem(cid,2497,1)
            doPlayerAddItem(cid,2456,1)
            doPlayerAddItem(cid,2546,1)
            doPlayerAddItem(cid,2656,1)
            if (playerVoc == 1) or (playerVoc == 6)  then
                while getPlayerMagLevel(cid) < 40 do
                    doPlayerAddManaSpent(cid, 100, 100)
                end       
            else
                while getPlayerMagLevel(cid) < 45 do
                    doPlayerAddManaSpent(cid, 100, 100)
                end   
            end
        end
       
        -- Equips for All Vocs --
        doPlayerAddItem(cid,2643,1)
        doPlayerAddItem(cid,2488,1)         
        Container = doPlayerAddItem(cid, 2000, 1)
        Container = doPlayerAddItem(cid, 1995, 1)
            doAddContainerItem(Container, 2273, 2)
            doAddContainerItem(Container, 2273, 2)
            doAddContainerItem(Container, 2273, 2)
            doAddContainerItem(Container, 2273, 2)
            doAddContainerItem(Container, 2273, 2)
            doAddContainerItem(Container, 2273, 2)
            doAddContainerItem(Container, 2273, 2)
            doAddContainerItem(Container, 2273, 2)
        Container = doPlayerAddItem(cid, 1996, 1)
            doAddContainerItem(Container, 2268, 2)
            doAddContainerItem(Container, 2268, 2)
            doAddContainerItem(Container, 2268, 2)
            doAddContainerItem(Container, 2268, 2)
            doAddContainerItem(Container, 2268, 2)
            doAddContainerItem(Container, 2268, 2)
            doAddContainerItem(Container, 2268, 2)
            doAddContainerItem(Container, 2268, 2)
        Container = doPlayerAddItem(cid, 1993, 1)
            doAddContainerItem(Container, 2261, 2)
            doAddContainerItem(Container, 2305, 2)
            doAddContainerItem(Container, 2261, 2)
            doAddContainerItem(Container, 2305, 2)
            doAddContainerItem(Container, 2262, 2)
            doAddContainerItem(Container, 2310, 2)
            doAddContainerItem(Container, 2286, 2)
            doAddContainerItem(Container, 2291, 2)
        Container = doPlayerAddItem(cid, 1994, 1)
            doAddContainerItem(Container, 2313, 2)
            doAddContainerItem(Container, 2313, 2)
            doAddContainerItem(Container, 2313, 2)
            doAddContainerItem(Container, 2313, 2)
            doAddContainerItem(Container, 2313, 2)
            doAddContainerItem(Container, 2313, 2)
            doAddContainerItem(Container, 2313, 2)
            doAddContainerItem(Container, 2313, 2)
        Container = doPlayerAddItem(cid, 1997, 1)
            doAddContainerItem(Container, 2293, 2)
            doAddContainerItem(Container, 2293, 2)
            doAddContainerItem(Container, 2293, 2)
            doAddContainerItem(Container, 2293, 2)
            doAddContainerItem(Container, 2293, 2)
            doAddContainerItem(Container, 2293, 2)
            doAddContainerItem(Container, 2293, 2)
            doAddContainerItem(Container, 2293, 2)
        Container = doPlayerAddItem(cid, 1987, 1)
            doAddContainerItem(Container, 2006, 7)
            doAddContainerItem(Container, 2006, 7)
            doAddContainerItem(Container, 2006, 7)
            doAddContainerItem(Container, 2006, 7)
            doAddContainerItem(Container, 2006, 7)
            doAddContainerItem(Container, 2006, 7)
            doAddContainerItem(Container, 2006, 7)
            doAddContainerItem(Container, 2006, 7)
        Container = doPlayerAddItem(cid, 3939, 1)
            doAddContainerItem(Container, 2214, 1)
            doAddContainerItem(Container, 2562, 1)
            doAddContainerItem(Container, 2167, 1)
            doAddContainerItem(Container, 2169, 1)
            doAddContainerItem(Container, 2789, 1)
            doAddContainerItem(Container, 2420, 1)
        Container = doPlayerAddItem(cid, 1988, 1)
            doAddContainerItem(Container, 2293, 2)
            doAddContainerItem(Container, 2304, 3)
            doAddContainerItem(Container, 2261, 2)
            doAddContainerItem(Container, 2305, 2)
            doAddContainerItem(Container, 2262, 2)
            doAddContainerItem(Container, 2273, 3)
            doAddContainerItem(Container, 2006, 7)
            doAddContainerItem(Container, 2268, 2)
    end

    return true
end
 
Solution
LOL, it worked, I swear I used the while like you told me to do, but I only did it for the ML and commented the others whiles (I was only testing with mages), it worked perfectly.

erXBoOqqRI2s7N20F1-jVg.png


G8PViTO_QnevJ1Fjv7kAzA.png


jM1ASN6fR96VfRN9FFwekw.png


Thank you very much for the help.
 

Similar threads

Back
Top