kewizzle Posted April 1, 2017 Share Posted April 1, 2017 using progress bars to show all the players weapon stats when the shop is opened but it doesnt work addEventHandler("onClientMarkerHit", skillshop, function() local stat8 = getPedStat (getLocalPlayer(),77) if stat8 == 0 then guiProgressBarSetProgress(ak47Pr, 0) if stat8 == 100 then guiProgressBarSetProgress(ak47Pr, 10) if stat8 == 200 then guiProgressBarSetProgress(ak47Pr, 20) if stat8 == 300 then guiProgressBarSetProgress(ak47Pr, 30) if stat8 == 400 then guiProgressBarSetProgress(ak47Pr, 40) if stat8 == 500 then guiProgressBarSetProgress(ak47Pr, 50) if stat8 == 600 then guiProgressBarSetProgress(ak47Pr, 60) if stat8 == 700 then guiProgressBarSetProgress(ak47Pr, 70) if stat8 == 800 then guiProgressBarSetProgress(ak47Pr, 80) if stat8 == 900 then guiProgressBarSetProgress(ak47Pr, 90) if stat8 == 1000 then guiProgressBarSetProgress(ak47Pr, 100) end end end end end end end end end end end end) end ) Link to comment
_DrXenon Posted April 1, 2017 Share Posted April 1, 2017 replace all the 'if's with 'elseif's and use only one end to end all the 'if' and the 'elseif's, another end for the function and a ')' to close '(' at line 1. Link to comment
kewizzle Posted April 2, 2017 Author Share Posted April 2, 2017 1 hour ago, SuperCroz said: replace all the 'if's with 'elseif's and use only one end to end all the 'if' and the 'elseif's, another end for the function and a ')' to close '(' at line 1. i did this addEventHandler("onClientMarkerHit", skillshop, function() local stat = getPlayerStat (getLocalPlayer(),69) local stat1 = getPlayerStat (getLocalPlayer(),70) local stat2 = getPlayerStat (getLocalPlayer(),71) local stat3 = getPlayerStat (getLocalPlayer(),72) local stat4 = getPlayerStat (getLocalPlayer(),73) local stat5 = getPlayerStat (getLocalPlayer(),74) local stat6 = getPlayerStat (getLocalPlayer(),75) local stat7 = getPlayerStat (getLocalPlayer(),76) local stat8 = getPlayerStat (getLocalPlayer(),77) local stat9 = getPlayerStat (getLocalPlayer(),78) guiProgressBarSetProgress(pistolPr, stat) guiProgressBarSetProgress(silencedPr, stat1) guiProgressBarSetProgress(deaglePr, stat2) guiProgressBarSetProgress(ShotgPr, stat3) guiProgressBarSetProgress(sawnoffPr, stat4) guiProgressBarSetProgress(spazPr, stat5) guiProgressBarSetProgress(tech9Pr, stat6) guiProgressBarSetProgress(mp5Pr, stat7) guiProgressBarSetProgress(ak47Pr, stat8) guiProgressBarSetProgress(m4Pr, stat9) end) Link to comment
Mr.Loki Posted April 2, 2017 Share Posted April 2, 2017 Even shorter addEventHandler("onClientMarkerHit", skillshop, function() local lp = localPlayer guiProgressBarSetProgress(pistolPr, getPlayerStat (lp,69)) guiProgressBarSetProgress(silencedPr, getPlayerStat (lp,70)) guiProgressBarSetProgress(deaglePr, getPlayerStat (lp,71)) guiProgressBarSetProgress(ShotgPr, getPlayerStat (lp,72)) guiProgressBarSetProgress(sawnoffPr, getPlayerStat (lp,73)) guiProgressBarSetProgress(spazPr, getPlayerStat (lp,74)) guiProgressBarSetProgress(tech9Pr, getPlayerStat (lp,75)) guiProgressBarSetProgress(mp5Pr, getPlayerStat (lp,76)) guiProgressBarSetProgress(ak47Pr, getPlayerStat (lp,77)) guiProgressBarSetProgress(m4Pr, getPlayerStat (lp,78)) end) 1 Link to comment
kewizzle Posted April 2, 2017 Author Share Posted April 2, 2017 1 hour ago, Mr.Loki said: Even shorter addEventHandler("onClientMarkerHit", skillshop, function() local lp = localPlayer guiProgressBarSetProgress(pistolPr, getPlayerStat (lp,69)) guiProgressBarSetProgress(silencedPr, getPlayerStat (lp,70)) guiProgressBarSetProgress(deaglePr, getPlayerStat (lp,71)) guiProgressBarSetProgress(ShotgPr, getPlayerStat (lp,72)) guiProgressBarSetProgress(sawnoffPr, getPlayerStat (lp,73)) guiProgressBarSetProgress(spazPr, getPlayerStat (lp,74)) guiProgressBarSetProgress(tech9Pr, getPlayerStat (lp,75)) guiProgressBarSetProgress(mp5Pr, getPlayerStat (lp,76)) guiProgressBarSetProgress(ak47Pr, getPlayerStat (lp,77)) guiProgressBarSetProgress(m4Pr, getPlayerStat (lp,78)) end) unfortunately i removed the progress bars because they wouldnt update everytime i hit the marker. If you knew a solution id add this back. Link to comment
#BrosS Posted April 2, 2017 Share Posted April 2, 2017 addEventHandler("onClientMarkerHit", skillshop, function() local stat8 = getPedStat (getLocalPlayer(),77) if stat8 == 0 then guiProgressBarSetProgress(ak47Pr, 0) elseif stat8 == 100 then guiProgressBarSetProgress(ak47Pr, 10) elseif stat8 == 200 then guiProgressBarSetProgress(ak47Pr, 20) elseif stat8 == 300 then guiProgressBarSetProgress(ak47Pr, 30) elseif stat8 == 400 then guiProgressBarSetProgress(ak47Pr, 40) elseif stat8 == 500 then guiProgressBarSetProgress(ak47Pr, 50) elseif stat8 == 600 then guiProgressBarSetProgress(ak47Pr, 60) elseif stat8 == 700 then guiProgressBarSetProgress(ak47Pr, 70) elseif stat8 == 800 then guiProgressBarSetProgress(ak47Pr, 80) elseif stat8 == 900 then guiProgressBarSetProgress(ak47Pr, 90) elseif stat8 == 1000 then guiProgressBarSetProgress(ak47Pr, 100) end end ) 1 Link to comment
Mr.Loki Posted April 2, 2017 Share Posted April 2, 2017 12 minutes ago, kewizzle said: unfortunately i removed the progress bars because they wouldnt update everytime i hit the marker. If you knew a solution id add this back. Can you show the previous code? Link to comment
kewizzle Posted April 2, 2017 Author Share Posted April 2, 2017 1 hour ago, Mr.Loki said: Can you show the previous code? i had it like this with all the stats, was testing it while using the button and everytime i clicked the button it wouldnt change. local stat8 = getPlayerStat (getLocalPlayer(),77) addEventHandler("onClientGUIClick", ak47B, function() if source == ak47B then triggerServerEvent ("setAK471",getLocalPlayer(),setAK471) guiProgressBarSetProgress(ak47Pr,tonumber(stat8/10)) end end) end) Link to comment
Mr.Loki Posted April 2, 2017 Share Posted April 2, 2017 (edited) line 3 change ak47B to resourceRoot and if that does not work change it to root addEventHandler("onClientGUIClick", resourceRoot, function() Edited April 2, 2017 by Mr.Loki Link to comment
kewizzle Posted April 2, 2017 Author Share Posted April 2, 2017 1 hour ago, Mr.Loki said: line 3 change ak47B to resourceRoot and if that does not work change it to root addEventHandler("onClientGUIClick", resourceRoot, function() unfortunately that didnt work, i didnt think it would. but just tested. Link to comment
kewizzle Posted April 2, 2017 Author Share Posted April 2, 2017 1 hour ago, Mr.Loki said: show what you did. tested this: local stat8 = getPlayerStat (getLocalPlayer(),77) addEventHandler("onClientGUIClick", resourceRoot, function() if source == ak47B then triggerServerEvent ("setAK471",getLocalPlayer(),setAK471) guiProgressBarSetProgress(ak47Pr,tonumber(stat8/10)) end end) end) And This: local stat8 = getPlayerStat (getLocalPlayer(),77) addEventHandler("onClientGUIClick", root, function() if source == ak47B then triggerServerEvent ("setAK471",getLocalPlayer(),setAK471) guiProgressBarSetProgress(ak47Pr,tonumber(stat8/10)) end end) end) Link to comment
Mr.Loki Posted April 2, 2017 Share Posted April 2, 2017 Can u paste the full gui code? I want to test it. Link to comment
kewizzle Posted April 2, 2017 Author Share Posted April 2, 2017 1 hour ago, Mr.Loki said: Can you show the previous code? i can but one second im adding an exit button atm. 1 hour ago, Mr.Loki said: Can u paste the full gui code? I want to test it. before i do that i just tested this guys code that posted before you it works, but i need to fix it to on button click as well if i cant get that to work ill be back. 1 hour ago, Mr.Loki said: Can you show the previous code? okay it works on marker hit but when i press the button the progressbar goes back down for some reason and stays there. addEventHandler("onClientGUIClick", ak47B, function() if source == ak47B then triggerServerEvent ("setAK471",getLocalPlayer(),setAK471) if getPlayerStat(getLocalPlayer(),77) == 0 then guiSetText(ak47B, "$2500") end if getPlayerStat(getLocalPlayer(),77) == 100 then guiSetText(ak47B, "$2600") end if getPlayerStat(getLocalPlayer(),77) == 200 then guiSetText(ak47B, "$2700") end if getPlayerStat(getLocalPlayer(),77) == 300 then guiSetText(ak47B, "$2800") end if getPlayerStat(getLocalPlayer(),77) == 400 then guiSetText(ak47B, "$2900") end if getPlayerStat(getLocalPlayer(),77) == 500 then guiSetText(ak47B, "$3000") end if getPlayerStat(getLocalPlayer(),77) == 600 then guiSetText(ak47B, "$3100") end if getPlayerStat(getLocalPlayer(),77) == 700 then guiSetText(ak47B, "$3200") end if getPlayerStat(getLocalPlayer(),77) == 800 then guiSetText(ak47B, "$3300") end if getPlayerStat(getLocalPlayer(),77) == 900 then guiSetText(ak47B, "$3400") end if getPlayerStat(getLocalPlayer(),77) == 1000 then guiSetText(ak47B, "Max!") end local stat8 = getPedStat (getLocalPlayer(),77) if stat8 == 0 then guiProgressBarSetProgress(ak47Pr, 0) elseif stat8 == 100 then guiProgressBarSetProgress(ak47Pr, 10) elseif stat8 == 200 then guiProgressBarSetProgress(ak47Pr, 20) elseif stat8 == 300 then guiProgressBarSetProgress(ak47Pr, 30) elseif stat8 == 400 then guiProgressBarSetProgress(ak47Pr, 40) elseif stat8 == 500 then guiProgressBarSetProgress(ak47Pr, 50) elseif stat8 == 600 then guiProgressBarSetProgress(ak47Pr, 60) elseif stat8 == 700 then guiProgressBarSetProgress(ak47Pr, 70) elseif stat8 == 800 then guiProgressBarSetProgress(ak47Pr, 80) elseif stat8 == 900 then guiProgressBarSetProgress(ak47Pr, 90) elseif stat8 == 1000 then guiProgressBarSetProgress(ak47Pr, 100) end end end) Link to comment
kewizzle Posted April 2, 2017 Author Share Posted April 2, 2017 simplified it a little bit. addEventHandler("onClientGUIClick", ak47B, function() if source == ak47B then local stat8 = getPedStat (getLocalPlayer(),77) local SPr = guiProgressBarSetProgress local gST = guiSetText triggerServerEvent ("setAK471",getLocalPlayer(),setAK471) if stat8 == 0 then gST(ak47B, "$2500") elseif stat8 == 100 then gST(ak47B, "$2600") elseif stat8 == 200 then gST(ak47B, "$2700") elseif stat8 == 300 then gST(ak47B, "$2800") elseif stat8 == 400 then gST(ak47B, "$2900") elseif stat8 == 500 then gST(ak47B, "$3000") elseif stat8 == 600 then gST(ak47B, "$3100") elseif stat8 == 700 then gST(ak47B, "$3200") elseif stat8 == 800 then gST(ak47B, "$3300") elseif stat8 == 900 then gST(ak47B, "$3400") elseif stat8 == 1000 then gST(ak47B, "Max!") end if stat8 == 0 then SPr(ak47Pr, 0) elseif stat8 == 100 then SPr(ak47Pr, 10) elseif stat8 == 200 then SPr(ak47Pr, 20) elseif stat8 == 300 then SPr(ak47Pr, 30) elseif stat8 == 400 then SPr(ak47Pr, 40) elseif stat8 == 500 then SPr(ak47Pr, 50) elseif stat8 == 600 then SPr(ak47Pr, 60) elseif stat8 == 700 then SPr(ak47Pr, 70) elseif stat8 == 800 then SPr(ak47Pr, 80) elseif stat8 == 900 then SPr(ak47Pr, 90) elseif stat8 == 1000 then SPr(ak47Pr, 100) end end end) Here's my gui: GUIEditor = { label = {} } local screenW, screenH = guiGetScreenSize() skillwindow = guiCreateWindow((screenW - 462) / 2, (screenH - 328) / 2, 462, 328, "Kewizzle's Skill Shop", false) guiWindowSetSizable(skillwindow, false) guiSetProperty(skillwindow, "CaptionColour", "FF0EECCA") guiSetVisible( skillwindow, not guiGetVisible( skillwindow ) ) ak47L = guiCreateLabel(10, 24, 74, 15, "AK-47 Skill:", false, skillwindow) guiSetFont(ak47L, "clear-normal") guiLabelSetColor(ak47L, 254, 0, 0) ak47Pr = guiCreateProgressBar(104, 24, 234, 15, false, skillwindow) tech9L = guiCreateLabel(10, 49, 74, 15, "Tech-9 Skill:", false, skillwindow) guiLabelSetColor(tech9L, 246, 80, 7) tech9Pr = guiCreateProgressBar(104, 48, 234, 16, false, skillwindow) pistolL = guiCreateLabel(10, 74, 74, 15, "Shotgun Skill:", false, skillwindow) guiLabelSetColor(pistolL, 246, 153, 6) ShotgPr = guiCreateProgressBar(104, 74, 234, 15, false, skillwindow) GUIEditor.label[1] = guiCreateLabel(10, 99, 74, 15, "Pistol Skill:", false, skillwindow) guiLabelSetColor(GUIEditor.label[1], 246, 203, 5) pistolPr = guiCreateProgressBar(104, 99, 234, 15, false, skillwindow) silenceL = guiCreateLabel(10, 124, 74, 15, "Silenced Skill:", false, skillwindow) guiLabelSetColor(silenceL, 181, 236, 13) silencedPr = guiCreateProgressBar(104, 124, 234, 15, false, skillwindow) sniperL = guiCreateLabel(10, 149, 74, 15, "Sniper Skill:", false, skillwindow) guiLabelSetColor(sniperL, 13, 235, 28) sniperPr = guiCreateProgressBar(104, 149, 234, 15, false, skillwindow) mp5L = guiCreateLabel(10, 174, 74, 15, "MP5 Skill:", false, skillwindow) guiLabelSetColor(mp5L, 15, 232, 168) mp5Pr = guiCreateProgressBar(104, 173, 234, 16, false, skillwindow) m4L = guiCreateLabel(10, 199, 74, 15, "M4 Skill:", false, skillwindow) guiLabelSetColor(m4L, 17, 202, 229) m4Pr = guiCreateProgressBar(104, 199, 234, 15, false, skillwindow) spazPr = guiCreateProgressBar(104, 224, 234, 15, false, skillwindow) spazL = guiCreateLabel(10, 226, 74, 13, "Spaz12 Skill:", false, skillwindow) guiLabelSetColor(spazL, 38, 18, 227) deagleL = guiCreateLabel(10, 249, 74, 15, "Deagle Skill:", false, skillwindow) guiLabelSetColor(deagleL, 165, 18, 226) deaglePr = guiCreateProgressBar(104, 249, 234, 15, false, skillwindow) ak47B = guiCreateButton(353, 24, 83, 15, "select", false, skillwindow) guiSetProperty(ak47B, "NormalTextColour", "FF05EE2B") tech9B = guiCreateButton(353, 48, 83, 16, "select", false, skillwindow) guiSetProperty(tech9B, "NormalTextColour", "FF05EE2B") shotgunB = guiCreateButton(354, 74, 82, 15, "select", false, skillwindow) guiSetProperty(shotgunB, "NormalTextColour", "FF05EE2B") pistolB = guiCreateButton(354, 99, 82, 15, "select", false, skillwindow) guiSetProperty(pistolB, "NormalTextColour", "FF05EE2B") silenceB = guiCreateButton(354, 123, 82, 16, "select", false, skillwindow) guiSetProperty(silenceB, "NormalTextColour", "FF05EE2B") sniperB = guiCreateButton(354, 147, 82, 16, "select", false, skillwindow) guiSetProperty(sniperB, "NormalTextColour", "FF05EE2B") mp5B = guiCreateButton(353, 173, 83, 16, "select", false, skillwindow) guiSetProperty(mp5B, "NormalTextColour", "FF05EE2B") m4B = guiCreateButton(353, 197, 83, 17, "select", false, skillwindow) guiSetProperty(m4B, "NormalTextColour", "FF05EE2B") spazB = guiCreateButton(354, 223, 82, 16, "select", false, skillwindow) guiSetProperty(spazB, "NormalTextColour", "FF05EE2B") deagleB = guiCreateButton(354, 249, 82, 15, "select", false, skillwindow) guiSetProperty(deagleB, "NormalTextColour", "FF05EE2B") exitShop = guiCreateButton(180, 281, 102, 37, "Exit", false, skillwindow) guiSetProperty(exitShop, "NormalTextColour", "FFFE0005") Link to comment
kewizzle Posted April 2, 2017 Author Share Posted April 2, 2017 if you are trying to get it to work you dont have to worry, the way i have it setup now works just fine. I removed the progress bars and just use button text to tell the player their current progress. 1 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