lsd1999 Posted March 29, 2015 Share Posted March 29, 2015 How to make written under the radar level and exp? Here is the code: function experience () for i, pPlayer in ipairs( getElementsByType( "player" ) ) do local pAccount = getPlayerAccount( pPlayer ) local exp = getAccountData(pAccount, "exp") local exps = tonumber(getAccountData(pAccount, "exp")) local lvls = tonumber(getAccountData(pAccount, "lvl")) local needexp = lvls * 4 if not exp then setAccountData(pAccount, "exp", 1) setAccountData(pAccount, "allexp", 1) setAccountData(pAccount, "lvl", 1) outputChatBox("Your experience: " .. exps .. "/" .. needexp, getRootElement(), 0, 255, 0) else setAccountData(pAccount, "exp", exps + 1) if exps == needexp then setAccountData(pAccount, "lvl", lvls + 1) setAccountData(pAccount, "exp", 1) outputChatBox("Your lvl is up to " .. lvls + 1 .. "!", getRootElement(), 0, 255, 0) else outputChatBox("Your experience: " .. exps .. "/" .. needexp, getRootElement(), 0, 255, 0) end end end end setTimer(experience, 3600000, 0) Link to comment
Ryancit2 Posted March 29, 2015 Share Posted March 29, 2015 You mean you want to print player XP-Level under radar? Try this: dxDrawText Link to comment
lsd1999 Posted March 29, 2015 Author Share Posted March 29, 2015 You mean you want to print player XP-Level under radar? Try this: dxDrawText I know that you want to use dxDrawText. But where this function to insert the code? Link to comment
WhoAmI Posted March 29, 2015 Share Posted March 29, 2015 Well. You can do like that. server function experience () for i, pPlayer in ipairs( getElementsByType( "player" ) ) do local pAccount = getPlayerAccount( pPlayer ) local exp = getAccountData(pAccount, "exp") local exps = tonumber(getAccountData(pAccount, "exp")) local lvls = tonumber(getAccountData(pAccount, "lvl")) local needexp = lvls * 4 if not exp then setAccountData(pAccount, "exp", 1) setAccountData(pAccount, "allexp", 1) setAccountData(pAccount, "lvl", 1) outputChatBox("Your experience: " .. exps .. "/" .. needexp, pPlayer, 0, 255, 0) else setAccountData(pAccount, "exp", exps + 1) if exps == needexp then setAccountData(pAccount, "lvl", lvls + 1) setAccountData(pAccount, "exp", 1) outputChatBox("Your lvl is up to " .. lvls + 1 .. "!", pPlayer, 0, 255, 0) else outputChatBox("Your experience: " .. exps .. "/" .. needexp, pPlayer, 0, 255, 0) end end triggerClientEvent ( pPlayer, "drawDxText", pPlayer, exps, needexp ) end end setTimer(experience, 3600000, 0) addEventHandler ( "onPlayerLogin", root, function ( _, account ) if ( account ) then local exp = tonumber ( getAccountData ( account, "exp" ) ) local lvl = tonumber ( getAccountData ( account, "lvl" ) ) if ( exp and lvl ) then local needExp = lvl * 4 triggerClientEvent ( source, "drawDxText", source, exp, needExp ) end end end ) client text = "" addEvent ( "drawDxText", true ) addEventHandler ( "drawDxText", root, function ( exp, needExp ) text = exp .. "/" .. needExp end ) addEventHandler ( "onClientRender", root, function ( ) if ( string.len ( text ) > 0 ) then dxDrawText ( text, 0, 0 ) end end ) Should work imo. Didn't test. Link to comment
lsd1999 Posted March 30, 2015 Author Share Posted March 30, 2015 Dont show the level and exp Link to comment
Ryancit2 Posted March 30, 2015 Share Posted March 30, 2015 This will work now, tested code: text = "" function setText(xp, nxp) text = "Experience: ".. xp .. "/" .. nxp end addEvent("drawDxText", true) addEventHandler("drawDxText", root, setText) function renderText() if (#text > 0) then local sw, sh = guiGetScreenSize() dxDrawText (text, 50, sy-50) end end addEventHandler("onClientRender", root, renderText) Now trigger these functions by serverside via: triggerClientEvent(source, "drawDxText", source, experience, neededExp) -- Here, source is the specific player who will see text under radar. Link to comment
lsd1999 Posted March 31, 2015 Author Share Posted March 31, 2015 Doesn't not work. Can you give me a code? Please Link to comment
Ryancit2 Posted March 31, 2015 Share Posted March 31, 2015 Its working fine for me, tell me how are you doing it? It'll show exp under the minimap. Link to comment
lsd1999 Posted March 31, 2015 Author Share Posted March 31, 2015 Its working fine for me, tell me how are you doing it? It'll show exp under the minimap. Client text = "" function setText(exp, needexp) text = "Experience: ".. exp .. "/" .. needexp end addEvent("drawDxText", true) addEventHandler("drawDxText", root, setText) function renderText() if (#text > 0) then local sw, sh = guiGetScreenSize() dxDrawText (text, 50, sy-50) end end addEventHandler("onClientRender", root, renderText) Sever function experience () for i, pPlayer in ipairs( getElementsByType( "player" ) ) do local pAccount = getPlayerAccount( pPlayer ) local exp = getAccountData(pAccount, "exp") local exps = tonumber(getAccountData(pAccount, "exp")) local lvls = tonumber(getAccountData(pAccount, "lvl")) local needexp = lvls * 4 if not exp then setAccountData(pAccount, "exp", 1) setAccountData(pAccount, "allexp", 1) setAccountData(pAccount, "lvl", 1) outputChatBox("Your experience: " .. exps .. "/" .. needexp, pPlayer, 0, 255, 0) else setAccountData(pAccount, "exp", exps + 1) if exps == needexp then setAccountData(pAccount, "lvl", lvls + 1) setAccountData(pAccount, "exp", 1) outputChatBox("Your lvl is up to " .. lvls + 1 .. "!", pPlayer, 0, 255, 0) else outputChatBox("Your experience: " .. exps .. "/" .. needexp, pPlayer, 0, 255, 0) end end triggerClientEvent(source, "drawDxText", source, exp, needexp) end end setTimer(experience, 3600000, 0) addEventHandler ( "onPlayerLogin", root, function ( _, paccount ) if ( account ) then local exp = tonumber ( getAccountData ( paccount, "exp" ) ) local lvl = tonumber ( getAccountData ( paccount, "lvl" ) ) if ( exp and lvl ) then local needExp = lvl * 4 triggerClientEvent(source, "drawDxText", source, exp, needexp) end end end ) Link to comment
Ryancit2 Posted March 31, 2015 Share Posted March 31, 2015 On server.lua:line#23, i said change 'source' with player value whom the text should be sent, try this: triggerClientEvent(pPlayer, "drawDxText", pPlayer, exp, needexp) Link to comment
lsd1999 Posted March 31, 2015 Author Share Posted March 31, 2015 On server.lua:line#23, i said change 'source' with player value whom the text should be sent, try this: triggerClientEvent(pPlayer, "drawDxText", pPlayer, exp, needexp) Dont work Link to comment
lsd1999 Posted March 31, 2015 Author Share Posted March 31, 2015 client text = "" function setText(exp, needxp) text = "Experience: ".. exp .. "/" .. needexp end addEvent("drawDxText", true) addEventHandler("drawDxText", root, setText) function renderText() if (#text > 0) then local sw, sh = guiGetScreenSize() dxDrawText (text, 50, sy-50) end end addEventHandler("onClientRender", root, renderText) server function experience () for i, pPlayer in ipairs( getElementsByType( "player" ) ) do local pAccount = getPlayerAccount( pPlayer ) local exp = getAccountData(pAccount, "exp") local exps = tonumber(getAccountData(pAccount, "exp")) local lvls = tonumber(getAccountData(pAccount, "lvl")) local needexp = lvls * 4 if not exp then setAccountData(pAccount, "exp", 1) setAccountData(pAccount, "allexp", 1) setAccountData(pAccount, "lvl", 1) outputChatBox("Your experience: " .. exps .. "/" .. needexp, pPlayer, 0, 255, 0) else setAccountData(pAccount, "exp", exps + 1) if exps == needexp then setAccountData(pAccount, "lvl", lvls + 1) setAccountData(pAccount, "exp", 1) outputChatBox("Your lvl is up to " .. lvls + 1 .. "!", pPlayer, 0, 255, 0) else outputChatBox("Your experience: " .. exps .. "/" .. needexp, pPlayer, 0, 255, 0) end end triggerClientEvent ( pPlayer, "drawDxText", pPlayer, exps, needexp ) end end setTimer(experience, 3600000, 0) addEventHandler ( "onPlayerLogin", root, function ( _, account ) if ( account ) then local exp = tonumber ( getAccountData ( account, "exp" ) ) local lvl = tonumber ( getAccountData ( account, "lvl" ) ) if ( exp and lvl ) then local needExp = lvl * 4 triggerClientEvent(source, "drawDxText", source, experience, needexp) end end end ) Link to comment
Ryancit2 Posted April 1, 2015 Share Posted April 1, 2015 Add this in 'else' after line#20: triggerClientEvent(pPlayer, "drawDxText", pPlayer, exp, needexp) Link to comment
JR10 Posted April 1, 2015 Share Posted April 1, 2015 He already has that at the end of the for loop. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now