1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Darkrpvar return nill serverside

Discussion in 'DarkRP Modding Questions & Help' started by ✪ DeviX, Nov 7, 2018.

  1. ✪ DeviX

    ✪ DeviX New Member

    Hello guys,

    i've little strange problem, i've a script on my server but it doesn't work since i've update darkrp. i think that i've fund the problem but it is really strange.
    I set DarkRPVar on serverside, the DarkRPVar is well recovered clientside but on serverside it return me nill.

    code that set DarkRPVar :
    Code (Text):
    function DarkRP.retrievePlayerLevelData(ply)
            if not IsValid(ply) then return end
            local info = data and data[1] or {}
            info.xp = (info.xp or 0)
            info.level = (info.level or 1)
            ply:setDarkRPVar('xp', info.xp)
            ply:setDarkRPVar('level', info.level)
            if not data then DarkRP.createPlayerLevelData(ply) end
    clientside code : (var is coorect)
    Code (Text):
    draw.DrawText('Level: '..(ply:getDarkRPVar('level') or 0), "DarkRPHUD2", pos.x, pos.y -58, Color(0,0,0,255), 1)
    serverside code : (return false beceause darkrpvar is nill)
    Code (Text):
    hook.Add('playerCanChangeTeam', 'manolis:MVLevels:playerTeamChange', function(ply, jobno)
        // This one requires a little extra work
        job = RPExtraTeams[jobno]
        if (job.level) then
            if not ((ply:getDarkRPVar('level') or 0) >= (job.level)) then
                DarkRP.notify(ply, 1, 2, 'You\'re not the right level to become this! your level : '..(ply:getDarkRPVar('level') or 0))
                return false, true
  2. (FPtje) Atheos

    (FPtje) Atheos Main Developer Staff Member

  3. ✪ DeviX

    ✪ DeviX New Member

    Yes i've declared it. I've also solved the issue. darkrpvar is set on player at player initial spawn, i just put function that declare it on simple Timer and it's work

Share This Page