Jump to content

Script ERRORS..HElP


Recommended Posts

This script got a lot of ERRORS..Also i'm wanted to add a Sound when i Level up.. :)

    exports.scoreboard:scoreboardAddColumn("ExP") 
    exports.scoreboard:scoreboardAddColumn("Level") 
    local levels = {[1] = 1, [50] = 2, [75] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [100000] = 11} 
      
    function win(ammo, killer, weapon, bodypart) 
        if (killer and killer ~= source) then 
            local H = getElementData(killer, "ExP") 
            local S = getElementData(killer, "Level") 
            local killer1 = getPlayerName(killer) 
            local noob = getPlayerName(source) 
            setElementData(killer, "ExP", tonumber(H)+75) 
            if levels[tonumber(H)] then 
                setElementData(killer, "Level", "Lvl ".. tostring(levels[tonumber(H)]) .." !") 
                triggerClientEvent ( killer, "playSound", killer ) 
            end 
        end 
    end 
    addEventHandler( "onZombieWasted", getRootElement(), win) 
      
    function onLogin (_,account) 
        setElementData(source, "Level", getAccountData(account, "lvl") or "Level 0 ") 
        setElementData(source, "ExP", getAccountData(account, "exp") or "0") 
    end 
    addEventHandler ("onPlayerLogin", root, onLogin) 
      
    function saveData(thePlayer, theAccount) 
        if (theAccount and not isGuestAccount(theAccount)) then 
            setAccountData (theAccount, "lvl", getElementData(thePlayer, "Level")) 
            setAccountData (theAccount, "exp", getElementData(thePlayer, "ExP")) 
        end 
    end 
      
    addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
    addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 

This script's not working..i get a lot of problems when i start it..but the cmd tells me Works..and i see the Scoreboard..but i cant Level up or EXP up...Nothing to do..Please help :)...and i want to add a sound when i get Level up.. :)

Link to comment
This script got a lot of ERRORS..Also i'm wanted to add a Sound when i Level up.. :)
    exports.scoreboard:scoreboardAddColumn("ExP") 
    exports.scoreboard:scoreboardAddColumn("Level") 
    local levels = {[1] = 1, [50] = 2, [75] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [100000] = 11} 
      
    function win(ammo, killer, weapon, bodypart) 
        if (killer and killer ~= source) then 
            local H = getElementData(killer, "ExP") 
            local S = getElementData(killer, "Level") 
            local killer1 = getPlayerName(killer) 
            local noob = getPlayerName(source) 
            setElementData(killer, "ExP", tonumber(H)+75) 
            if levels[tonumber(H)] then 
                setElementData(killer, "Level", "Lvl ".. tostring(levels[tonumber(H)]) .." !") 
                triggerClientEvent ( killer, "playSound", killer ) 
            end 
        end 
    end 
    addEventHandler( "onZombieWasted", getRootElement(), win) 
      
    function onLogin (_,account) 
        setElementData(source, "Level", getAccountData(account, "lvl") or "Level 0 ") 
        setElementData(source, "ExP", getAccountData(account, "exp") or "0") 
    end 
    addEventHandler ("onPlayerLogin", root, onLogin) 
      
    function saveData(thePlayer, theAccount) 
        if (theAccount and not isGuestAccount(theAccount)) then 
            setAccountData (theAccount, "lvl", getElementData(thePlayer, "Level")) 
            setAccountData (theAccount, "exp", getElementData(thePlayer, "ExP")) 
        end 
    end 
      
    addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
    addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 

This script's not working..i get a lot of problems when i start it..but the cmd tells me Works..and i see the Scoreboard..but i cant Level up or EXP up...Nothing to do..Please help :)...and i want to add a sound when i get Level up.. :)

Before I start to look through your script could you tell me the errors the console is outputting to you?

Link to comment
This script got a lot of ERRORS..Also i'm wanted to add a Sound when i Level up.. :)
    exports.scoreboard:scoreboardAddColumn("ExP") 
    exports.scoreboard:scoreboardAddColumn("Level") 
    local levels = {[1] = 1, [50] = 2, [75] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [100000] = 11} 
      
    function win(ammo, killer, weapon, bodypart) 
        if (killer and killer ~= source) then 
            local H = getElementData(killer, "ExP") 
            local S = getElementData(killer, "Level") 
            local killer1 = getPlayerName(killer) 
            local noob = getPlayerName(source) 
            setElementData(killer, "ExP", tonumber(H)+75) 
            if levels[tonumber(H)] then 
                setElementData(killer, "Level", "Lvl ".. tostring(levels[tonumber(H)]) .." !") 
                triggerClientEvent ( killer, "playSound", killer ) 
            end 
        end 
    end 
    addEventHandler( "onZombieWasted", getRootElement(), win) 
      
    function onLogin (_,account) 
        setElementData(source, "Level", getAccountData(account, "lvl") or "Level 0 ") 
        setElementData(source, "ExP", getAccountData(account, "exp") or "0") 
    end 
    addEventHandler ("onPlayerLogin", root, onLogin) 
      
    function saveData(thePlayer, theAccount) 
        if (theAccount and not isGuestAccount(theAccount)) then 
            setAccountData (theAccount, "lvl", getElementData(thePlayer, "Level")) 
            setAccountData (theAccount, "exp", getElementData(thePlayer, "ExP")) 
        end 
    end 
      
    addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
    addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 

This script's not working..i get a lot of problems when i start it..but the cmd tells me Works..and i see the Scoreboard..but i cant Level up or EXP up...Nothing to do..Please help :)...and i want to add a sound when i get Level up.. :)

Before I start to look through your script could you tell me the errors the console is outputting to you?

Sure ..

Warning: exp_system\Exp.lua:8: bad argument @ 'getElementData' Expected element at argument 1, got number ' 30' ...... Exp.lua:9: bad argument @ 'getPlayerName' [Expected element at argument 1, got number '30'   .... Exp.lua:11: attempt to preform arithmtic on a nil value 

Link to comment

The problems are probably from the onZombieWasted event, i checked the resource, and even if this event is similar to onPlayerWasted, it's not the same. The arguments are wrong in your win function, the onZombieWasted event doesn't inform about the ammo:

function win(ammo, killer, weapon, bodypart) 
  
--------------- 
-- change to 
--------------- 
  
function win(killer, weapon, bodypart) 

Now it should work fine

Link to comment
The problems are probably from the onZombieWasted event, i checked the resource, and even if this event is similar to onPlayerWasted, it's not the same. The arguments are wrong in your win function, the onZombieWasted event doesn't inform about the ammo:
function win(ammo, killer, weapon, bodypart) 
  
--------------- 
-- change to 
--------------- 
  
function win(killer, weapon, bodypart) 

Now it should work fine

Gonna try :)..and thanks

Link to comment
The problems are probably from the onZombieWasted event, i checked the resource, and even if this event is similar to onPlayerWasted, it's not the same. The arguments are wrong in your win function, the onZombieWasted event doesn't inform about the ammo:
function win(ammo, killer, weapon, bodypart) 
  
--------------- 
-- change to 
--------------- 
  
function win(killer, weapon, bodypart) 

Now it should work fine

Gonna try :)..and thanks

Look...Working 100%..but when i added some levels and exps i got ERROR in cmd screen..

Called ERROR:

WARRNING: Loading Script Failed: exp_system\Exp.lua:3: '}' expected near '[' 

This problem happened when i added this

    local levels = {[1] = 1, [50] = 2, [75] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [40000] = 11 [60000] = 12 [75000] = 13 [95000] = 14 [110000] = 15 [120000] = 16 [130000] = 17 [145000] = 18 [165000] = 19 [200000] = 20} 

more levels :/ help please

Link to comment

in a table, you must put a coma after each argument, except for the last one, try this:

   local levels = {[1] = 1, [50] = 2, [75] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [40000] = 11, [60000] = 12, [75000] = 13, [95000] = 14, [110000] = 15, [120000] = 16, [130000] = 17, [145000] = 18, [165000] = 19, [200000] = 20}  

Link to comment
in a table, you must put a coma after each argument, except for the last one, try this:
   local levels = {[1] = 1, [50] = 2, [75] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [40000] = 11, [60000] = 12, [75000] = 13, [95000] = 14, [110000] = 15, [120000] = 16, [130000] = 17, [145000] = 18, [165000] = 19, [200000] = 20}  

THANKS A LOT understanded now :D Thanks for helping ^^

Link to comment
in a table, you must put a coma after each argument, except for the last one, try this:
   local levels = {[1] = 1, [50] = 2, [75] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [40000] = 11, [60000] = 12, [75000] = 13, [95000] = 14, [110000] = 15, [120000] = 16, [130000] = 17, [145000] = 18, [165000] = 19, [200000] = 20}  

THANKS A LOT understanded now :D Thanks for helping ^^

but how i can control the level and exp :/... like if i want to set level for some player or set exp for him :/ How...may you tell me that script? but add level and exp with /commands

Link to comment

try this

addCommandHandler ( "setexp", 
    function ( thePlayer, _, who, theExP ) 
        local theExP = tonumber ( theExP ) or 0 
        local playerWho = getPlayerFromName ( who ) 
        if ( playerWho ) then 
            exports.exp_system:setPlayerEXP ( playerWho, theExP ) 
        end 
    end 
) 

Link to comment
addCommandHandler ( "setlvl", 
    function ( thePlayer, _, who, theLevel ) 
        local theLevel = tonumber ( theLevel ) or 0 
        local playerWho = getPlayerFromName ( who ) 
        if ( playerWho ) then 
            exports.exp_system:setPlayerLevel ( playerWho, theLevel ) 
        end 
    end 
) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...