NodZen_42 Posted July 16, 2018 Share Posted July 16, 2018 (edited) Hello guys, i need help with this. The idea is to create a dxDrawimage according to the zombie kills of the player, but it does not work. exports.scoreboard:addScoreboardColumn('Zombie kills') addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer) givePlayerMoney(killer,50) addPlayerZombieKills(killer) end) function addPlayerZombieKills(killer) local account = getPlayerAccount(killer) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") if not zombieKills then setAccountData(account,"Zombie kills",0) end setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) end addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") if zombieKills then setElementData(source,"Zombie kills",tostring(zombieKills)) else setElementData(source,"Zombie kills",0) end end) addEvent("onZombieWasted", true) addEventHandler("onZombieWasted", root, function (killer) addPlayerRanks (killer) end ) function addPlayerRanks(killer) local account = getPlayerAccount(source) local zombie_kills = getAccountData(account, "Zombie kills") if (zombie_kills >=0) and (zombie_kills <= 100) then setElementData(source, "Medalla", "Novato") elseif (zombie_kills >=101) and (zombie_kills <= 500) then setElementData(source, "Medalla", "Experimentado") end end ---------client local screenW, screenH = guiGetScreenSize() addEventHandler("onClientRender", root, function () local datos_cuenta = getElementData(source, "Medalla") if datos_cuenta == "Novato" then dxDrawImage(screenW-250, screenH-70,80,80,"Rangos/Novato.png") elseif datos_cuenta == "Experimentado" then dxDrawImage(screenW-250, screenH-70,80,80,"Rangos/Experimentado.png") end end ) Any help? Thanks. Edited July 16, 2018 by NodZen_42 Link to comment
Infinity# Posted July 17, 2018 Share Posted July 17, 2018 Give me the image below, and I'll write it down for you. Everything you've above is right and it should work. local screenW, screenH = guiGetScreenSize() addEventHandler("onClientRender", root, function() local zombieKills = tonumber(getElementData(localPlayer, "Zombie kills")) or 'None' dxDrawRectangle(screenW * 0.0454, screenH * 0.6263, screenW * 0.1691, screenH * 0.0404, tocolor(0, 0, 0, 155), false) dxDrawText("Zombie Kills: ".. zombieKills .."", screenW * 0.0527, screenH * 0.6406, screenW * 0.2072, screenH * 0.6536, tocolor(255, 255, 255, 255), 1.20, "clear", "center", "center", false, false, false, false, false) end) This code will draw a rectangle and a text showing the player's zombie kills. You can add a line to it with the dxDrawImage above, based on the player's zombie kills what image should it draw since that is what you want. So the player can know their rank by the number of zombie kills they've. Perhaps you can even make another line for dxDrawText to show the name of the rank as well. 6 hours ago, NodZen_42 said: Hello guys, i need help with this. The idea is to create a dxDrawimage according to the zombie kills of the player, but it does not work. exports.scoreboard:addScoreboardColumn('Zombie kills') addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer) givePlayerMoney(killer,50) addPlayerZombieKills(killer) end) function addPlayerZombieKills(killer) local account = getPlayerAccount(killer) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") if not zombieKills then setAccountData(account,"Zombie kills",0) end setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) end addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") if zombieKills then setElementData(source,"Zombie kills",tostring(zombieKills)) else setElementData(source,"Zombie kills",0) end end) addEvent("onZombieWasted", true) addEventHandler("onZombieWasted", root, function (killer) addPlayerRanks (killer) end ) function addPlayerRanks(killer) local account = getPlayerAccount(source) local zombie_kills = getAccountData(account, "Zombie kills") if (zombie_kills >=0) and (zombie_kills <= 100) then setElementData(source, "Medalla", "Novato") elseif (zombie_kills >=101) and (zombie_kills <= 500) then setElementData(source, "Medalla", "Experimentado") end end ---------client local screenW, screenH = guiGetScreenSize() addEventHandler("onClientRender", root, function () local datos_cuenta = getElementData(source, "Medalla") if datos_cuenta == "Novato" then dxDrawImage(screenW-250, screenH-70,80,80,"Rangos/Novato.png") elseif datos_cuenta == "Experimentado" then dxDrawImage(screenW-250, screenH-70,80,80,"Rangos/Experimentado.png") end end ) Any help? Thanks. Here you go: If there's anything missing/bugging, let me know. Untested but this should work 100%. And it'll open up more possibilities. exports.scoreboard:addScoreboardColumn('Zombie kills') addEvent("onZombieWasted",true) addEventHandler("onZombieWasted", root, function(killer) givePlayerMoney(killer, 50) addPlayerZombieKills(killer) end) function addPlayerZombieKills(killer) if isElement(killer) then if getElementData(killer, "Zombie kills") then local zombieKills = tonumber(getElementData(killer, "Zombie kills")) setElementData(killer, "Zombie kills", zombieKills + 1) else setElementData(killer, "Zombie kills", 1) outputChatBox("'Zombie kills' stats are now being recorded on your account", killer, 0, 200, 0, false) end end end addEventHandler("onPlayerLogin", root, function(_, account) if isGuestAccount(account) then return end if getPlayerAccount(source) and getAccountData(account, "Zombie kills") then local zombieKills = getAccountData(account, "Zombie kills") if zombieKills then setElementData(source, "Zombie kills", tostring(zombieKills)) else setElementData(source, "Zombie kills", 0) outputChatBox("'Zombie kills' stats are now being recorded on your account", source, 0, 200, 0, false) end end end) function saveZombieData() if getPlayerAccount(source) then local account = getPlayerAccount(source) if getAccountData(account, "Zombie kills") then local zombieKills = tonumber(getElementData(source, "Zombie kills")) if zombieKills then setAccountData(account, "Zombie kills", zombieKills) end end end end addEventHandler("onPlayerQuit", root, saveZombieData) addEventHandler("onPlayerLogout", root, saveZombieData) 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