undefined Posted March 23, 2014 Share Posted March 23, 2014 (edited) Client function status() SWindow = guiCreateWindow(448, 278, 687, 321, "Status", false) guiWindowSetSizable(SWindow, false) guiSetAlpha(SWindow, 0.60) PGrid = guiCreateGridList(10, 33, 667, 44, false, SWindow) PLabelSol = guiCreateLabel(11, 10, 91, 24, "Pistol", false, PGrid) guiSetFont(PLabelSol, "default-bold-small") guiLabelSetHorizontalAlign(PLabelSol, "center", false) guiLabelSetVerticalAlign(PLabelSol, "center") PLabelSag = guiCreateLabel(567, 10, 91, 24, "Pistol", false, PGrid) guiSetFont(PLabelSag, "default-bold-small") guiLabelSetHorizontalAlign(PLabelSag, "center", false) guiLabelSetVerticalAlign(PLabelSag, "center") PLevel1 = guiCreateButton(112, 11, 81, 23, "Level 1", false, PGrid) PLevel2 = guiCreateButton(203, 11, 81, 23, "Level 2", false, PGrid) PLevel3 = guiCreateButton(294, 11, 81, 23, "Level 3", false, PGrid) PLevel4 = guiCreateButton(385, 11, 81, 23, "Level 4", false, PGrid) PLevel5 = guiCreateButton(476, 11, 81, 23, "Level 5", false, PGrid) addEventHandler ( "onClientGUIClick", PLevel1, PLev1, false ) addEventHandler ( "onClientGUIClick", PLevel2, PLev2, false ) addEventHandler ( "onClientGUIClick", PLevel3, PLev3, false ) addEventHandler ( "onClientGUIClick", PLevel4, PLev4, false ) addEventHandler ( "onClientGUIClick", PLevel5, PLev5, false ) end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), status ) function statusop() if (guiGetVisible (SWindow) == true) then guiSetVisible(SWindow, false) showCursor(false) elseif (guiGetVisible (SWindow) == false) then guiSetVisible(SWindow, true) showCursor(true) end end bindKey ("F7", "down", statusop) Server function PLev1 () takePlayerMoney ( source, 5000 ) setPedStat(source, 69, 200) end addEventHandler ( "onClientGUIClick", getRootElement(), PLev1 ) function PLev2 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 20000 ) setPedStat(source, 69, stat+200) end addEventHandler ( "onClientGUIClick", getRootElement(), PLev2 ) function PLev3 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 40000 ) setPedStat(source, 69, stat+200) end addEventHandler ( "onClientGUIClick", getRootElement(), PLev3 ) function PLev4 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 65000 ) setPedStat(source, 69, stat+200) end addEventHandler ( "onClientGUIClick", getRootElement(), PLev4 ) function PLev5 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 95000 ) setPedStat(source, 69, stat+200) end addEventHandler ( "onClientGUIClick", getRootElement(), PLev5 ) Why not worrk!! Edited March 25, 2014 by Guest Link to comment
Karuzo Posted March 23, 2014 Share Posted March 23, 2014 Could you please explain what doesn't work? But i think you mean the addEventHandler. Well you have to trigger to the server. Link to comment
undefined Posted March 23, 2014 Author Share Posted March 23, 2014 State does not change and does not take money. Link to comment
Karuzo Posted March 23, 2014 Share Posted March 23, 2014 You can't use onClientGUIClick since as the name says its onCLIENTGuiClick and just a Client Event. As i said you have to trigger from the client to the server. triggerServerEvent --and addEvent addEventHandler Link to comment
LiOneLMeSsIShoT Posted March 23, 2014 Share Posted March 23, 2014 Try this: Server: function PLev1 () takePlayerMoney ( source, 5000 ) setPedStat(source, 69, 200) end addEvent ("Stats1", true) addEventHandler ( "Stats1", getRootElement(), PLev1 ) function PLev2 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 20000 ) setPedStat(source, 69, stat+200) end addEvent ("Stats2", true) addEventHandler ( "Stats2", getRootElement(), PLev2 ) function PLev3 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 40000 ) setPedStat(source, 69, stat+200) end addEvent ("Stats3", true) addEventHandler ( "Stats3", getRootElement(), PLev3 ) function PLev4 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 65000 ) setPedStat(source, 69, stat+200) end addEvent ("Stats4", true) addEventHandler ( "Stats4", getRootElement(), PLev4 ) function PLev5 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 95000 ) setPedStat(source, 69, stat+200) end addEvent ("Stats5", true) addEventHandler ( "Stats5", getRootElement(), PLev5 ) client: function status() SWindow = guiCreateWindow(448, 278, 687, 321, "Status", false) guiWindowSetSizable(SWindow, false) guiSetAlpha(SWindow, 0.60) PGrid = guiCreateGridList(10, 33, 667, 44, false, SWindow) PLabelSol = guiCreateLabel(11, 10, 91, 24, "Pistol", false, PGrid) guiSetFont(PLabelSol, "default-bold-small") guiLabelSetHorizontalAlign(PLabelSol, "center", false) guiLabelSetVerticalAlign(PLabelSol, "center") PLabelSag = guiCreateLabel(567, 10, 91, 24, "Pistol", false, PGrid) guiSetFont(PLabelSag, "default-bold-small") guiLabelSetHorizontalAlign(PLabelSag, "center", false) guiLabelSetVerticalAlign(PLabelSag, "center") PLevel1 = guiCreateButton(112, 11, 81, 23, "Level 1", false, PGrid) PLevel2 = guiCreateButton(203, 11, 81, 23, "Level 2", false, PGrid) PLevel3 = guiCreateButton(294, 11, 81, 23, "Level 3", false, PGrid) PLevel4 = guiCreateButton(385, 11, 81, 23, "Level 4", false, PGrid) PLevel5 = guiCreateButton(476, 11, 81, 23, "Level 5", false, PGrid) addEventHandler ( "onClientGUIClick", PLevel1, PLev1, false ) addEventHandler ( "onClientGUIClick", PLevel2, PLev2, false ) addEventHandler ( "onClientGUIClick", PLevel3, PLev3, false ) addEventHandler ( "onClientGUIClick", PLevel4, PLev4, false ) addEventHandler ( "onClientGUIClick", PLevel5, PLev5, false ) ---ClientToServerHandlers addEventHandler ("onClientGUIClick", PLevel1, PLev11, false) addEventHandler ("onClientGUIClick", PLevel2, PLev22, false) addEventHandler ("onClientGUIClick", PLevel3, PLev33, false) addEventHandler ("onClientGUIClick", PLevel4, PLev44, false) addEventHandler ("onClientGUIClick", PLevel5, PLev55, false) end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), status ) function statusop() if (guiGetVisible (SWindow) == true) then guiSetVisible(SWindow, false) showCursor(false) elseif (guiGetVisible (SWindow) == false) then guiSetVisible(SWindow, true) showCursor(true) end end bindKey ("F7", "down", statusop) function PLev11 () triggerServerEvent ("Stats1", localPlayer) end function PLev22 () triggerServerEvent ("Stats2", localPlayer) end function PLev33 () triggerServerEvent ("Stats3", localPlayer) end function PLev44 () triggerServerEvent ("Stats4", localPlayer) end function PLev55 () triggerServerEvent ("Stats5", localPlayer) end And this: addEventHandler ( "onClientGUIClick", PLevel1, PLev1, false ) addEventHandler ( "onClientGUIClick", PLevel2, PLev2, false ) addEventHandler ( "onClientGUIClick", PLevel3, PLev3, false ) addEventHandler ( "onClientGUIClick", PLevel4, PLev4, false ) addEventHandler ( "onClientGUIClick", PLevel5, PLev5, false ) Dosen't Give any sense...do you have functions for this event Handlers? Link to comment
undefined Posted March 23, 2014 Author Share Posted March 23, 2014 function status() SWindow = guiCreateWindow(448, 278, 687, 321, "Status", false) guiWindowSetSizable(SWindow, false) guiSetAlpha(SWindow, 0.60) PGrid = guiCreateGridList(10, 33, 667, 44, false, SWindow) PLabelSol = guiCreateLabel(11, 10, 91, 24, "Pistol", false, PGrid) guiSetFont(PLabelSol, "default-bold-small") guiLabelSetHorizontalAlign(PLabelSol, "center", false) guiLabelSetVerticalAlign(PLabelSol, "center") PLabelSag = guiCreateLabel(567, 10, 91, 24, "Pistol", false, PGrid) guiSetFont(PLabelSag, "default-bold-small") guiLabelSetHorizontalAlign(PLabelSag, "center", false) guiLabelSetVerticalAlign(PLabelSag, "center") PLevel1 = guiCreateButton(112, 11, 81, 23, "Level 1", false, PGrid) PLevel2 = guiCreateButton(203, 11, 81, 23, "Level 2", false, PGrid) PLevel3 = guiCreateButton(294, 11, 81, 23, "Level 3", false, PGrid) PLevel4 = guiCreateButton(385, 11, 81, 23, "Level 4", false, PGrid) PLevel5 = guiCreateButton(476, 11, 81, 23, "Level 5", false, PGrid) triggerServerEvent ( "PLev1", source ) triggerServerEvent ( "PLev2", source ) triggerServerEvent ( "PLev3", source ) triggerServerEvent ( "PLev4", source ) triggerServerEvent ( "PLev5", source ) end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), status ) function statusop() if (guiGetVisible (SWindow) == true) then guiSetVisible(SWindow, false) showCursor(false) elseif (guiGetVisible (SWindow) == false) then guiSetVisible(SWindow, true) showCursor(true) end end bindKey ("F7", "down", statusop) function PistolLevel1 () takePlayerMoney ( source, 5000 ) setPedStat(source, 69, 200) end addEvent( "PLev1", true ) addEventHandler( "PLev1", root, PistolLevel1 ) function PistolLevel2 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 20000 ) setPedStat(source, 69, stat+200) end addEvent( "PLev2", true ) addEventHandler( "PLev2", root, PistolLevel2 ) function PistolLevel3 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 40000 ) setPedStat(source, 69, stat+200) end addEvent( "PLev3", true ) addEventHandler( "PLev3", root, PistolLevel3 ) function PistolLevel4 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 65000 ) setPedStat(source, 69, stat+200) end addEvent( "PLev4", true ) addEventHandler( "PLev4", root, PistolLevel4 ) function PistolLevel5 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 95000 ) setPedStat(source, 69, stat+200) end addEvent( "PLev5", true ) addEventHandler( "PLev5", root, PistolLevel5 ) Link to comment
Karuzo Posted March 23, 2014 Share Posted March 23, 2014 That because your client file is loaded before serverside file. Make it like that in the meta: server.lua client.lua Link to comment
LiOneLMeSsIShoT Posted March 23, 2014 Share Posted March 23, 2014 function status() SWindow = guiCreateWindow(448, 278, 687, 321, "Status", false) guiWindowSetSizable(SWindow, false) guiSetAlpha(SWindow, 0.60) PGrid = guiCreateGridList(10, 33, 667, 44, false, SWindow) PLabelSol = guiCreateLabel(11, 10, 91, 24, "Pistol", false, PGrid) guiSetFont(PLabelSol, "default-bold-small") guiLabelSetHorizontalAlign(PLabelSol, "center", false) guiLabelSetVerticalAlign(PLabelSol, "center") PLabelSag = guiCreateLabel(567, 10, 91, 24, "Pistol", false, PGrid) guiSetFont(PLabelSag, "default-bold-small") guiLabelSetHorizontalAlign(PLabelSag, "center", false) guiLabelSetVerticalAlign(PLabelSag, "center") PLevel1 = guiCreateButton(112, 11, 81, 23, "Level 1", false, PGrid) PLevel2 = guiCreateButton(203, 11, 81, 23, "Level 2", false, PGrid) PLevel3 = guiCreateButton(294, 11, 81, 23, "Level 3", false, PGrid) PLevel4 = guiCreateButton(385, 11, 81, 23, "Level 4", false, PGrid) PLevel5 = guiCreateButton(476, 11, 81, 23, "Level 5", false, PGrid) triggerServerEvent ( "PLev1", source ) triggerServerEvent ( "PLev2", source ) triggerServerEvent ( "PLev3", source ) triggerServerEvent ( "PLev4", source ) triggerServerEvent ( "PLev5", source ) end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), status ) function statusop() if (guiGetVisible (SWindow) == true) then guiSetVisible(SWindow, false) showCursor(false) elseif (guiGetVisible (SWindow) == false) then guiSetVisible(SWindow, true) showCursor(true) end end bindKey ("F7", "down", statusop) function PistolLevel1 () takePlayerMoney ( source, 5000 ) setPedStat(source, 69, 200) end addEvent( "PLev1", true ) addEventHandler( "PLev1", root, PistolLevel1 ) function PistolLevel2 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 20000 ) setPedStat(source, 69, stat+200) end addEvent( "PLev2", true ) addEventHandler( "PLev2", root, PistolLevel2 ) function PistolLevel3 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 40000 ) setPedStat(source, 69, stat+200) end addEvent( "PLev3", true ) addEventHandler( "PLev3", root, PistolLevel3 ) function PistolLevel4 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 65000 ) setPedStat(source, 69, stat+200) end addEvent( "PLev4", true ) addEventHandler( "PLev4", root, PistolLevel4 ) function PistolLevel5 () local stat = getPedStat ( source, 69 ) takePlayerMoney ( source, 95000 ) setPedStat(source, 69, stat+200) end addEvent( "PLev5", true ) addEventHandler( "PLev5", root, PistolLevel5 ) You have Changed the addEvent TO Plev5 and ...Plev 4 ..etc.....IT and removed the functions from client side! so how do you thnk the triggers will work? Can you just Copy the script i posted and try it without changing the triggerServerEvent and addEvents? Link to comment
undefined Posted March 23, 2014 Author Share Posted March 23, 2014 Oh, sorry. Meta.xml ''m also delete the server. And thank you Krzo andLiOneLMeSsIShoT. However, there will be more a question. Without pressing Level 1, Level 2-3-4-5 is not pressed how can I do? Link to comment
LiOneLMeSsIShoT Posted March 23, 2014 Share Posted March 23, 2014 Oh, sorry. Meta.xml ''m also delete the server. And thank you Krzo andLiOneLMeSsIShoT. However, there will be more a question. Without pressing Level 1, Level 2-3-4-5 is not pressed how can I do? guiSetEnabled setElementData Link to comment
Karuzo Posted March 23, 2014 Share Posted March 23, 2014 Without pressing Level 1, Level 2-3-4-5 is not pressed how can I do? How do you mean that ? Link to comment
undefined Posted March 23, 2014 Author Share Posted March 23, 2014 While level 1 is not active, a without Level 2, Level 3, Level 4 and Level 5 not active. In addition to Level 1 After activating Pressing not click it again. (My English is very bad. Sry.) Link to comment
Karuzo Posted March 23, 2014 Share Posted March 23, 2014 I didn't understand anything, sorry. Use Google Tranlator if you're english is not good. Link to comment
LiOneLMeSsIShoT Posted March 23, 2014 Share Posted March 23, 2014 While level 1 is not active, a without Level 2, Level 3, Level 4 and Level 5 not active. In addition to Level 1 After activating Pressing not click it again. (My English is very bad. Sry.) Yes i understand what do you want.. and it have some ways to do that and you can try: guiSetEnabled setElementData for me it's Easy way. Link to comment
undefined Posted March 23, 2014 Author Share Posted March 23, 2014 Lionel, bro. This is very tangled. Could you give information about how do I do? Link to comment
-.Paradox.- Posted March 23, 2014 Share Posted March 23, 2014 (edited) if getPedStat(weaponid, statid) then guiSetEnabled(...) end Edited March 23, 2014 by Guest Link to comment
LiOneLMeSsIShoT Posted March 23, 2014 Share Posted March 23, 2014 Lionel, bro. This is very tangled. Could you give information about how do I do? Loook i have made an example for you: function btn1 (button, state) if (button == "left" and state == "up") then if ( guiGetEnabled (PLeve11) == true and not getElementData (localPlayer, "Enabled1") ) then guiSetEnabled (PLeve11, false) setElementData (localPlayer, "Enabled1", true) guiSetEnabled (PLeve12, true) end end end addEventHandler ("onClientGUIClick", PLevel1, btn1, false) Link to comment
LiOneLMeSsIShoT Posted March 23, 2014 Share Posted March 23, 2014 if getPedStat(weaponid, statid) then setGuiEnabled(...) end And this Example is Good too. Link to comment
LiOneLMeSsIShoT Posted March 23, 2014 Share Posted March 23, 2014 if getPedStat(weaponid, statid) then setGuiEnabled(...) end And this Example is Good too. but changed " setGuiEnabled to guiSetEnabled Link to comment
-.Paradox.- Posted March 23, 2014 Share Posted March 23, 2014 Btw, guiSetEnabled is client side only, and setPedStat is serverside, so you have to trigger it Link to comment
undefined Posted March 23, 2014 Author Share Posted March 23, 2014 Thank you Lioner. I will try your example. But before doing anything else. Look at that, will you? --Shotgun----Shotgun-- function SLev1 () takePlayerMoney ( source, 5000 ) setPedStat(source, 72 and 73, 200) end addEvent ("SStats1", true) addEventHandler ( "SStats1", getRootElement(), SLev1 ) function SLev2 () local stat = getPedStat ( source, 72 and 73 ) takePlayerMoney ( source, 20000 ) setPedStat(source, 72 and 73, stat+200) end addEvent ("SStats2", true) addEventHandler ( "SStats2", getRootElement(), SLev2 ) function SLev3 () local stat = getPedStat ( source, 72 and 73 ) takePlayerMoney ( source, 40000 ) setPedStat(source, 72 and 73, stat+200) end addEvent ("SStats3", true) addEventHandler ( "SStats3", getRootElement(), SLev3 ) function SLev4 () local stat = getPedStat ( source, 72 and 73 ) takePlayerMoney ( source, 65000 ) setPedStat(source, 72 and 73, stat+200) end addEvent ("SStats4", true) addEventHandler ( "SStats4", getRootElement(), SLev4 ) function SLev5 () local stat = getPedStat ( source, 72 and 73 ) takePlayerMoney ( source, 95000 ) setPedStat(source, 72 and 73, stat+200) end addEvent ("SStats5", true) addEventHandler ( "SStats5", getRootElement(), SLev5 ) --Shotgun----Shotgun-- 72: WEAPONTYPE_SHOTGUN_SKILL 73: WEAPONTYPE_SAWNOFF_SHOTGUN_SKILL This is only raises the sawn-off-shotgun. What's the problem? Link to comment
LiOneLMeSsIShoT Posted March 23, 2014 Share Posted March 23, 2014 Thank you Lioner. I will try your example. But before doing anything else. Look at that, will you? --Shotgun----Shotgun-- function SLev1 () takePlayerMoney ( source, 5000 ) setPedStat(source, 72 and 73, 200) end addEvent ("SStats1", true) addEventHandler ( "SStats1", getRootElement(), SLev1 ) function SLev2 () local stat = getPedStat ( source, 72 and 73 ) takePlayerMoney ( source, 20000 ) setPedStat(source, 72 and 73, stat+200) end addEvent ("SStats2", true) addEventHandler ( "SStats2", getRootElement(), SLev2 ) function SLev3 () local stat = getPedStat ( source, 72 and 73 ) takePlayerMoney ( source, 40000 ) setPedStat(source, 72 and 73, stat+200) end addEvent ("SStats3", true) addEventHandler ( "SStats3", getRootElement(), SLev3 ) function SLev4 () local stat = getPedStat ( source, 72 and 73 ) takePlayerMoney ( source, 65000 ) setPedStat(source, 72 and 73, stat+200) end addEvent ("SStats4", true) addEventHandler ( "SStats4", getRootElement(), SLev4 ) function SLev5 () local stat = getPedStat ( source, 72 and 73 ) takePlayerMoney ( source, 95000 ) setPedStat(source, 72 and 73, stat+200) end addEvent ("SStats5", true) addEventHandler ( "SStats5", getRootElement(), SLev5 ) --Shotgun----Shotgun-- 72: WEAPONTYPE_SHOTGUN_SKILL 73: WEAPONTYPE_SAWNOFF_SHOTGUN_SKILL This is only raises the sawn-off-shotgun. What's the problem? what the hell is that dude? local stat = getPedStat ( source, 72 and 73 ) you can't use "72 and 73...it handle only 1 vairable and also why are you defining the stat every time you use it in function? Try this: --Shotgun----Shotgun-- local stat1 local stat2 addEventHandler ("onPlayerJoin", root, function () stat1 = getPedStat ( source, 72) stat2 = getPedStat ( source, 73) end ) function SLev1 () takePlayerMoney ( source, 5000 ) setPedStat(source,stat1, 200) setPedStat(source,stat2, 200) end addEvent ("SStats1", true) addEventHandler ( "SStats1", getRootElement(), SLev1 ) function SLev2 () takePlayerMoney ( source, 20000 ) setPedStat(source, stat1, stat+200) setPedStat(source, stat2, stat+200) end addEvent ("SStats2", true) addEventHandler ( "SStats2", getRootElement(), SLev2 ) function SLev3 () takePlayerMoney ( source, 40000 ) setPedStat(source, stat1, stat+200) setPedStat(source, stat2, stat+200) end addEvent ("SStats3", true) addEventHandler ( "SStats3", getRootElement(), SLev3 ) function SLev4 () takePlayerMoney ( source, 65000 ) setPedStat(source, stat1, stat+200) setPedStat(source, stat2, stat+200) end addEvent ("SStats4", true) addEventHandler ( "SStats4", getRootElement(), SLev4 ) function SLev5 () takePlayerMoney ( source, 95000 ) setPedStat(source, stat1, stat+200) setPedStat(source, stat2, stat+200) end addEvent ("SStats5", true) addEventHandler ( "SStats5", getRootElement(), SLev5 ) --Shotgun----Shotgun-- [/lua] 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