HeK Posted April 13, 2013 Share Posted April 13, 2013 (edited) I'm having these errors in debugscript 3, it says "ERROR: Server triggered clientside event hideVendorGUI, but event is not added clientside". I have checked it and it is added in clientside. What should i do? Edited April 15, 2013 by Guest Link to comment
Renkon Posted April 13, 2013 Share Posted April 13, 2013 Are you triggering it onPlayerJoin? Link to comment
HeK Posted April 13, 2013 Author Share Posted April 13, 2013 (edited) On marker hit. Edited April 15, 2013 by Guest Link to comment
Castillo Posted April 14, 2013 Share Posted April 14, 2013 Your script has many problems, I've fixed them for you, but next time use debugscript ( /debugscript 3 in-game ). -- client side: GUIEditor = { button = {}, window = {} } GUIEditor.window[1] = guiCreateWindow(510, 418, 264, 162, "Chilli Dogs Vendor", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1],false) GUIEditor.button[1] = guiCreateButton(19,42,108,31, "Chili | 5HP | $10", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(101, 129, 65, 21, "Close", false, GUIEditor. window[1]) GUIEditor.button[3] = guiCreateButton(137, 42, 108, 31, "Ace | 10HP | $15", false, GUIEditor. window[1]) GUIEditor.button[4] = guiCreateButton(137, 88, 114, 31, "Mega | 20HP | $20", false, GUIEditor. window[1]) GUIEditor.button[5] = guiCreateButton(13, 88, 114, 31, "Super | 25HP | $25", false, GUIEditor. window[1]) function showVendorGUI ( ) guiSetVisible ( GUIEditor.window[1], true ) showCursor ( true ) end addEvent ( "showVendorGUI", true ) addEventHandler ( "showVendorGUI", getRootElement(), showVendorGUI ) addEvent ( "hideVendorGUI", true ) addEventHandler ( "hideVendorGUI", getRootElement(), function ( ) guiSetVisible ( GUIEditor.window[1], false ) showCursor ( false ) end ) addEventHandler ( "onClientGUIClick", getRootElement(), function ( ) if ( source == GUIEditor.button[2] ) then guiSetVisible ( GUIEditor.window[1], false ) showCursor ( false ) elseif ( source == GUIEditor.button[1] ) then triggerServerEvent ( "buyFood", localPlayer, 10 ) elseif ( source == GUIEditor.button[3] ) then triggerServerEvent ( "buyFood", localPlayer, 15 ) elseif ( source == GUIEditor.button[4] ) then triggerServerEvent ( "buyFood", localPlayer, 20 ) elseif ( source == GUIEditor.button[5] ) then triggerServerEvent ( "buyFood", localPlayer, 25 ) end end ) -- server side: --Markers vendor1 = createMarker ( 999.921, -1850.50, 11.8, "cylinder", 1.2, 100, 0, 0, 115 ) vendor2 = createMarker ( 388.86, -2073.04, 6.8, "cylinder", 1.2, 100, 0, 0, 115 ) --Vendors ped1 = createPed ( 168, 1000.78 ,-1848.05, 12.82 ) ped2 = createPed ( 168, 388.86, -2070.44, 8 ) setPedRotation ( ped1, 155 ) setPedRotation ( ped2, 180 ) function showGUI ( hitPlayer ) triggerClientEvent ( hitPlayer, "showVendorGUI", getRootElement(), hitPlayer ) end addEventHandler ( "onMarkerHit", vendor1, showGUI ) addEventHandler ( "onMarkerHit", vendor2, showGUI ) function hideGUI ( leavePlayer ) triggerClientEvent ( leavePlayer, "hideVendorGUI", leavePlayer ) end addEventHandler ( "onMarkerLeave", vendor1, hideGUI ) addEventHandler ( "onMarkerLeave", vendor2, hideGUI ) addEvent ( "buyFood", true ) addEventHandler ( "buyFood", root, function ( cost ) if ( getPlayerMoney ( client ) < cost ) then return outputChatBox ( "You don't have enough money!", client, 255, 0, 0 ) end if ( cost == 10 ) then outputChatBox ( "(Local) Vendor: There you go sir, have a nice day.", client, 225, 230, 0 ) elseif ( cost == 15 ) then outputChatBox ( "(Local) Vendor: There you go sir, have a nice day.", client, 225, 230, 0 ) elseif ( cost == 20 ) then outputChatBox ( "(Local) Vendor: There you go sir, have a nice day.", client, 225, 230, 0 ) elseif ( cost == 25 ) then outputChatBox ( "(Local) Vendor: There you go sir, have a nice day.", client, 225, 230, 0 ) end takePlayerMoney ( client, cost ) setElementHealth ( client, ( getElementHealth ( client ) + cost ) ) end ) Link to comment
HeK Posted April 14, 2013 Author Share Posted April 14, 2013 Thanks a lot Castillo, that fixed all my problems and you made the script much 'easier' to work with, sorry for bothering and thanks a lot for your time. Link to comment
HeK Posted April 14, 2013 Author Share Posted April 14, 2013 Another thing Castillo, how do i make it that vehicles cannot open the GUI and that when a player presses the button he has to wait about 3 seconds for it to be "clickable" again. Sorry for bothering s: Link to comment
Castillo Posted April 14, 2013 Share Posted April 14, 2013 When hit the marker, check if the player is on a vehicle with: isPedInVehicle About waiting timer, you can either use timers: setTimer isTimer or calculate the time passed with: getTickCount Link to comment
HeK Posted April 14, 2013 Author Share Posted April 14, 2013 I tried with setTimer, but i didn't understand that much about it, i tried to make it in client side but it didn't work. Could you explain how i should do it for a GUI? Link to comment
Castillo Posted April 14, 2013 Share Posted April 14, 2013 You can disable the button after bought, then set a 3 seconds timer to enable it again. Use: setTimer guiSetEnabled Link to comment
HeK Posted April 14, 2013 Author Share Posted April 14, 2013 (edited) I made it that i can disable each button, but the problem is that i can use the other buttons. How can i disable every button at the same time? Edited April 15, 2013 by Guest Link to comment
Castillo Posted April 14, 2013 Share Posted April 14, 2013 Or... instead of disabling each button, just set a timer, and when try to buy again, check if that timer is still alive with isTimer. Link to comment
HeK Posted April 15, 2013 Author Share Posted April 15, 2013 Alright i've done it, thanks a lot and sorry for bothering. 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