Jump to content

Need HELP URGENT! Animation!


FlyingSpoon

Recommended Posts

Posted

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.

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted

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.

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted

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.

Previously known as MrTasty.

Posted

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 
) 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...