Addlibs Posted February 24, 2015 Share Posted February 24, 2015 Updated the previous post, try it now Link to comment
FlyingSpoon Posted February 24, 2015 Author Share Posted February 24, 2015 Still don't ;( Doesn't set the animation on me ;( I can give you my gameserver IP and you can see it for yourself? Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 The problem is that you're comparing the localPlayer which is an element (userdata value) to a gui-element, so the check always returns false and the event is not even triggered. if (localPlayer == wDrink ) then Should be: if (source == wDrink ) then This why you need to learn how to debug your code, a simple outputDebugString with any message in the server-side event handler would have shown that the event is not even triggered. Link to comment
FlyingSpoon Posted February 24, 2015 Author Share Posted February 24, 2015 I have done that on my code as the code wouldnt work, I still did that didnt impact anything still the same. Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 Did you add a debug message like I said? This way we don't have to go through your code looking for bugs ourselves. Add a debug message in the server-side event handler first thing and check if it's output. Don't forget to also check for errors. Link to comment
Addlibs Posted February 24, 2015 Share Posted February 24, 2015 It doesn't work since both tDrink and AnimationOff are triggered when you press wDrink button. You can remove --stop animation [example button 02] function StopAnimation() if source == wDrink then triggerServerEvent("AnimationOff", getLocalPlayer()) guiSetVisible(eatMenu,false) showCursor(false) end end addEventHandler("onClientGUIClick", root, StopAnimation) --stop animation [example button 02] addEvent ("AnimationOff", true) addEventHandler ("AnimationOff", getRootElement(), function() setPedAnimation ( client ) end) since you've made tDrink stop the animation if it's already playing. I have also noticed that you'd have to turn off 'loop' from the animation, otherwise players might get stuck when they drink and close their panel — becoming unable to move in to the marker once again due to animation. Link to comment
FlyingSpoon Posted February 24, 2015 Author Share Posted February 24, 2015 WARNING: client.lua:27: Bad argument @ 'triggerServerEvent' [Expected element at argument 2, got nil] function sLobby() setElementPosition ( getLocalPlayer(), 583, -2838, 62 ) local localPlayerName = getPlayerName(getLocalPlayer()) outputChatBox("[iNFO] "..localPlayerName.." has entered the lobby!", 255, 136, 0) end addCommandHandler("lobby", sLobby) localPlayer = source --foodPed = createPed(211, 559.29999, -2856.8, 61.4) dMarker = createMarker(560, -2855, 62, "cylinder", 1.5, 255, 255, 255, 1) addEventHandler("onClientMarkerHit", root, function ( ) if ( source == dMarker ) then eatMenu = guiCreateWindow(441, 242, 130, 111, "Lobby v0.1", false) guiWindowSetSizable(eatMenu, false) wDrink = guiCreateButton(11, 32, 108, 29, "Whiskey", false, eatMenu) wFood = guiCreateButton(11, 67, 108, 29, "Sandwich", false, eatMenu) showCursor(true) end end ) addEventHandler("onClientGUIClick", root, function ( ) if (source == wDrink ) then triggerServerEvent("tDrink", localPlayer) guiSetVisible(eatMenu,false) showCursor(false) end end ) Link to comment
xeon17 Posted February 24, 2015 Share Posted February 24, 2015 triggerServerEvent("tDrink", getLocalPlayer()) Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 Why the hell is line 7 there? localPlayer = source This is deleting the localPlayer variable's value, so it's nil. Remove the line. Link to comment
FlyingSpoon Posted February 24, 2015 Author Share Posted February 24, 2015 Yay ty JR10! Your awesome Link to comment
FlyingSpoon Posted February 24, 2015 Author Share Posted February 24, 2015 It worked once now it stopped working haha, wtf? 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