Jump to content

Experience Required


ZeyadGTX

Recommended Posts

See

levelUpTable = { 
  
  
[0] = "100", 
[1] = "200", 
[2] = "800", 
[3] = "1600" 
} 
  
function levelRequired() 
local XP = getElementData(localPlayer, "EXP") 
local LV = getElementData(localPlayer, "LV") 
dxDrawText("LV: "..LV.." XP: "..XP.."/"..levelUpTable[LV], sWidth*(900/1280), sHeight*(689/720), sWidth*(621/1280), sHeight*(715/720), tocolor(255, 255, 255, 255), (0.8/1280)*sWidth,(0.8/720)*sHeight,"bankgothic", "left", "top", false, false, true, true, false) 
end 
addEventHandler("onClientRender",root,levelRequired) 

Link to comment

You mean like this :

dxDrawText("LV: "..LV.." XP: "..XP.."/"..levelUpTable[LV], sWidth*(400/1280), sHeight*(500/720), sWidth*(621/1280), sHeight*(715/720), tocolor(0, 0, 0, 255), (0.8/1280)*sWidth,(0.8/720)*sHeight,"bankgothic", "left", "top", false, false, true, true, false) 

Link to comment

Please look down at wiki the function dxDrawText or simply click on that red text on this forum and read it's arguments.

here is your explained mistake

if you read the wiki, you can see that after color argument scale is next which is a number and after scale is font argument which is a string

now here is part where you are wrong

tocolor(255, 255, 255, 255), (0.8/1280)*sWidth,       ->            (0.8/720)*sHeight, 
-- you have that thing on right side instead of "bankgothic", so just delete it and it should draw the text 

Link to comment

omg no

    dxDrawText("LV: "..LV.." XP: "..XP.."/"..levelUpTable[LV], sWidth*(400/1280), sHeight*(500/720), sWidth*(621/1280), sHeight*(715/720), tocolor(255, 0, 0, 255), (0.8/720)*sHeight, "bankgothic", "left", "top", false, false, true, true, false) 

Link to comment

ahh same problem not working :( anyway fuck this idea i started to get bored

levelUpTable = {   -- required experience to level up,e.g if someone is level 1 he would need 500 xp to level up 
[0] = "100", 
[1] = "500", 
[2] = "1000", 
[3] = "2000" 
} 
  
function levelRequired() 
local XP = getElementData(localPlayer,"EXP") 
local LV = getElementData(localPlayer,"LV") 
   dxDrawText("LV: "..LV.." XP: "..XP.."/"..levelUpTable[LV], sWidth*(400/1280), sHeight*(500/720), sWidth*(621/1280), sHeight*(715/720), tocolor(255, 0, 0, 255), (0.8/720)*sHeight, "bankgothic", "left", "top", false, false, true, true, false) 
end 
addEventHandler("onClientRender",root,levelRequired) 

Link to comment
ahh same problem not working :( anyway :o this idea i started to get bored
levelUpTable = {   -- required experience to level up,e.g if someone is level 1 he would need 500 xp to level up 
[0] = "100", 
[1] = "500", 
[2] = "1000", 
[3] = "2000" 
} 
  
function levelRequired() 
local XP = getElementData(localPlayer,"EXP") 
local LV = getElementData(localPlayer,"LV") 
   dxDrawText("LV: "..LV.." XP: "..XP.."/"..levelUpTable[LV], sWidth*(400/1280), sHeight*(500/720), sWidth*(621/1280), sHeight*(715/720), tocolor(255, 0, 0, 255), (0.8/720)*sHeight, "bankgothic", "left", "top", false, false, true, true, false) 
end 
addEventHandler("onClientRender",root,levelRequired) 

it works fine

are you sure the player LV data doesn't return false ?

Link to comment
YES

if you mean yes the player LV data doesn't return false

the problem isn't from the code because its work fine for me

setElementData(root,'EXP',50) 
  
setElementData(root,'LV',3) 
  
levelUpTable = {   -- required experience to level up,e.g if someone is level 1 he would need 500 xp to level up 
[0] = "100", 
[1] = "500", 
[2] = "1000", 
[3] = "2000" 
} 
  
function levelRequired() 
local XP = getElementData(localPlayer,"EXP") 
local LV = getElementData(localPlayer,"LV") 
   dxDrawText("LV: "..LV.." XP: "..XP.."/"..levelUpTable[LV], 0, 0, sWidth, sHeight, tocolor(255, 0, 0, 255), (0.8/720)*sHeight, "bankgothic", "center", "center", false, false, true, true, false) 
end 
addEventHandler("onClientRender",root,levelRequired) 

try it to be sure that the problem not from ur code ( i just add 2 lines to test it )

Link to comment

Server side

function win(ammo, killer, weapon, bodypart) 
    if (killer and getElementType(killer) == "player" and killer ~= source) then 
        local H = getElementData(killer, "EXP") or 0 
        local S = getElementData(killer, "LV") or 0 
        local killer1 = getPlayerName(killer) 
        local noob = getPlayerName(source) 
        local experience = math.random(25, 100) 
        setElementData(killer, "EXP", tonumber(H)+experience) 
        local H = tonumber(H) + experience 
        triggerClientEvent(killer, "onTestExp", killer, experience) 
        if (tonumber(H) >= 100 and tonumber(H) <=400) then 
            setElementData(killer, "LV", 1) 
            setElementData(killer, "experience.rank", "Private") 
        elseif (tonumber(H) >= 401 and tonumber(H) <=600) then 
            setElementData(killer, "LV", 2) 
        elseif (tonumber(H) >= 601 and tonumber(H) <=800) then 
            setElementData(killer, "LV", 3) 
        elseif (tonumber(H) >= 801 and tonumber(H) <=1000) then 
            setElementData(killer, "LV", 4) 
end 
    end 
end 
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "LV", getAccountData(account, "LV") or "0") 
    setElementData(source, "EXP", getAccountData(account, "EEXP") or "0") 
    setElementData(source, "player.key", getAccountData(account, "player.key") or "Guest") 
    setElementData(source, "experience.rank", getAccountData(account, "experience.rank") or "Guest") 
end 
addEventHandler ("onPlayerLogin", root, onLogin) 
  
function onLogout (_,account) 
    setElementData(source, "LV", 0) 
    setElementData(source, "EXP", 0) 
    setElementData(source, "experience.rank", "Newbie") 
    setElementData(source, "player.key", "Guest") 
end 
addEventHandler ("onPlayerLogout", root, onLogout) 
  
function saveData(thePlayer, theAccount) 
local theAccount = getPlayerAccount(source) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        setAccountData (theAccount, "LV", getElementData(thePlayer, "LV")) 
        setAccountData (theAccount, "EEXP", getElementData(thePlayer, "EXP")) 
        setAccountData (theAccount, "experience.rank", getElementData(thePlayer, "experience.rank")) 
        setAccountData (theAccount, "player.key", getElementData(thePlayer, "player.key")) 
    end 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function () saveData(source, getPlayerAccount(source)) end) 
--addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 
  
  
addCommandHandler ( "setxp", 
    function ( thePlayer, _, who, EXP ) 
    if getElementData(thePlayer, "player.key") == "Zeyad" then 
    if ( who ) then 
        local EXP = tonumber (EXP) or 0 
        local ThePlayer = getPlayerFromParticalName ( who ) 
        if ( ThePlayer ) then 
            setElementData( ThePlayer,"EXP",EXP ) 
            outputChatBox("Your XP has been set to "..EXP, ThePlayer, 255, 0, 0, true) 
        else 
            outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) 
        end 
    else 
        outputChatBox("Couldn't find '"..who.."'", thePlayer, 255, 0, 0, true) 
    end 
    end 
    end 
) 
  
function getPlayerFromParticalName(thePlayerName) 
    local thePlayer = getPlayerFromName(thePlayerName) 
    if thePlayer then 
        return thePlayer 
    end 
    for _,thePlayer in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then 
            return thePlayer 
        end 
    end 
return false 
end 
  
function outputChange(dataName,oldValue) 
    if getElementType(source) == "player" and dataName == "experience.rank" and oldValue then  
        local newValue = getElementData(source,dataName) 
        outputChatBox("Congratulations ! Your rank is #FFFFFF'"..tostring(newValue).."'",source, 255, 0, 0, true) 
        triggerClientEvent(source, "onClientRankUp", source) 
    end 
end 
addEventHandler("onElementDataChange",getRootElement(),outputChange) 
  
addEventHandler("onPlayerLogin", root, 
function(_, account) 
    if not getAccountData(account, "player.key") then 
        setElementData(source, "player.key", getAccountName(account)) 
        setAccountData(account, "player.key", getElementData(source, "player.key")) 
    else 
    end 
end) 
  
addEvent("addToTeam", true) 
addEventHandler("addToTeam", root, 
function (playername, teamname) 
local player = getPlayerFromName(playername or "") 
local team = getTeamFromName(teamname or "") 
    if player and team then 
        local r, g, b = getTeamColor ( team ) 
        setPlayerTeam(player, team) 
        setPlayerNametagColor ( player, r, g, b ) 
        outputChatBox("You've been added to #FFFFFF"..getTeamName(team).."#006400", player, 255, 0, 0, true) 
   end 
end) 
  
addEvent("kickFromTeam", true) 
addEventHandler("kickFromTeam", root, 
function (playername, teamname) 
local player = getPlayerFromName(playername or "") 
local team = getTeamFromName(teamname or "") 
    if player and team then 
        local red, green, blue = math.random (50, 255), math.random (50, 255), math.random (50, 255) 
        setPlayerTeam(player, nil) 
        setPlayerNametagColor(player, red, green, blue) 
        outputChatBox("You've been kicked from #FFFFFF"..getTeamName(team).."#FF0000.", player, 255, 0, 0, true) 
    end 
end) 
  
addEvent("promotePlayer",true) 
addEventHandler("promotePlayer",root, 
function(playername, rank) 
local player = getPlayerFromName(playername or "") 
    if player then 
        if rank then 
            setElementData(player, "clan.rank", rank) 
            outputChatBox("You Have Been promoted To A #FFFFFF"..tostring(rank), player, 255, 0, 0, true) 
        end 
    end 
end) 
  
addEvent("DemotePlayer",true) 
addEventHandler("DemotePlayer",root, 
function(playername, rank) 
local player = getPlayerFromName(playername or "") 
    if player then 
        if rank then 
            setElementData(player, "clan.rank", rank) 
            outputChatBox("You Have Been Demoted To A #FFFFFF"..tostring(rank), player, 255, 0, 0, true) 
        end 
    end 
end) 
  
function loopFix( thePlayer, _, who, lossp ) 
if getElementData(thePlayer, "player.key") == "Zeyad" then 
    if ( who ) then 
        local LossC = tonumber (lossp) or 0 
        local ThePlayer = getPlayerFromParticalName ( who ) 
            if ( ThePlayer ) then 
                setElementData( ThePlayer,"EXP",LossC ) 
            end 
        end 
    end 
end 
addCommandHandler ( "fixbug", loopFix) 
  
function getPlayerFromParticalName(thePlayerName) 
    local thePlayer = getPlayerFromName(thePlayerName) 
    if thePlayer then 
        return thePlayer 
    end 
    for _,thePlayer in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then 
            return thePlayer 
        end 
    end 
return false 
end 

Link to comment
YES

if you mean yes the player LV data doesn't return false

the problem isn't from the code because its work fine for me

setElementData(root,'EXP',50) 
  
setElementData(root,'LV',3) 
  
levelUpTable = {   -- required experience to level up,e.g if someone is level 1 he would need 500 xp to level up 
[0] = "100", 
[1] = "500", 
[2] = "1000", 
[3] = "2000" 
} 
  
function levelRequired() 
local XP = getElementData(localPlayer,"EXP") 
local LV = getElementData(localPlayer,"LV") 
   dxDrawText("LV: "..LV.." XP: "..XP.."/"..levelUpTable[LV], 0, 0, sWidth, sHeight, tocolor(255, 0, 0, 255), (0.8/720)*sHeight, "bankgothic", "center", "center", false, false, true, true, false) 
end 
addEventHandler("onClientRender",root,levelRequired) 

try it to be sure that the problem not from ur code ( i just add 2 lines to test it )

The player XP sets to 50

and his level is 3 when the player joins that means that it works but what's wrong !!

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...