Jump to content

Need HELP URGENT! Animation!


FlyingSpoon

Recommended Posts

server.lua:3: 'end' expected (to close 'function' at line 1) near 'else'

server.lua:3: 'end' expected (to close 'function' at line 1) near 'else'

function tDrink () 
setPedAnimation ( thePlayer, "VENDING", "VEND_Drink_P", 2.1, false) 
else 
setPedAnimation ( thePlayer ) 
end 
addEvent("tDrink", true) 
addEventHandler("tDrink", root, tDrink) 

Link to comment

Look my example

server.lua

function dance (source) 
    daBlockz = getElementData(root,"blockz") 
    daAnimz = getElementData(root,"animz") 
        if daBlockz == "dancing" and daAnimz == "dnce_m_b" then 
            setPedAnimation(source,false) 
        else 
            setPedAnimation ( source, "DANCING", "dnce_m_b") 
        end 
    end 
addCommandHandler("dance1",dance) 

Link to comment

in my animation panel is so

addEvent ("AnimationOn", true) 
addEventHandler ("AnimationOn", getRootElement(), 
function() 
setPedAnimation ( source, "DANCING", "dnce_m_b") 
end 
) 
-------- 
addEvent ("AnimationOff", true) 
addEventHandler ("Animationoff", getRootElement(), 
function() 
setPedAnimation ( source ) 
end 
) 

Link to comment

CLIENT -

function giveDrink() 
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("onClientMarkerHit", root, giveDrink) 
  
function takeFood() 
if source == wDrink then 
triggerServerEvent("tDrink", resourceRoot) 
guiSetVisible(eatMenu,false) 
showCursor(false) 
  end 
end 
addEventHandler("onClientGUIClick", root, takeFood) 

SERVER -

  
addEvent ("tDrink", true) 
addEventHandler ("tDrink", getRootElement(), 
function() 
setPedAnimation ( source, "DANCING", "dnce_m_b") 
end 
) 
-------- 
addEvent ("tDrinko", true) 
addEventHandler ("tDrinko", getRootElement(), 
function() 
setPedAnimation ( source ) 
end 
) 

This is what I got

Link to comment

client.lua

function takeFood() 
if source == wDrink then 
triggerServerEvent("tDrink", resourceRoot) 
guiSetVisible(eatMenu,false) 
showCursor(false) 
  end 
end 
addEventHandler("onClientGUIClick", root, takeFood) 
  
--stop animation [example button 02] 
function StopAnimation() 
if source == wDrink then 
triggerServerEvent("AnimationOff", resourceRoot) 
guiSetVisible(eatMenu,false) 
showCursor(false) 
  end 
end 
addEventHandler("onClientGUIClick", root, StopAnimation) -- look stop 
  
  

server.lua

addEvent ("tDrink", true) 
addEventHandler ("tDrink", getRootElement(), 
function() 
setPedAnimation ( source, "DANCING", "dnce_m_b") 
end 
) 
  
--stop animation [example button 02] 
addEvent ("AnimationOff", true) 
addEventHandler ("AnimationOff", getRootElement(), 
function() 
setPedAnimation ( source ) 
end 
) 
  
  

Link to comment
function takeFood() 
if source == wDrink then 
triggerServerEvent("tDrink", getLocalPlayer()) 
guiSetVisible(eatMenu,false) 
showCursor(false) 
  end 
end 
addEventHandler("onClientGUIClick", root, takeFood) 
  
--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) -- look stop 

There are no errors outputted in debugscript or MTA Console it seems to work but the animation is not set on me? Why?

Link to comment

Client side is correct now,

Try this , but remember i didn't tested it.

addEvent ("tDrink", true) 
addEventHandler ("tDrink", getRootElement(), 
function() 
setPedAnimation ( client, "dancing", "dnce_m_b") 
end) 
  
  
--stop animation [example button 02] 
addEvent ("AnimationOff", true) 
addEventHandler ("AnimationOff", getRootElement(), 
function() 
setPedAnimation ( client ) 
end) 
  
  

Link to comment

Try This ,

---Client.lua 
addEventHandler("onClientMarkerHit", root, 
function ( ) 
if ( localPlayer == 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 (localPlayer == wDrink ) then  
   triggerServerEvent("tDrink", localPlayer) 
   guiSetVisible(eatMenu,false) 
   showCursor(false) 
    end 
end 
)6 

--Server.lua 
addEvent('tDrink', true ) 
addEventHandler('tDrink', root, 
function ( ) 
    daBlockz = getElementData(root,"blockz") 
    daAnimz = getElementData(root,"animz") 
        if daBlockz == "DANCING" and daAnimz == "dnce_m_b" then 
            setPedAnimation(source,false) 
        else 
        setTimer( setPedAnimation, 100, 1, source, "DANCING", "dnce_m_b" ) 
        end 
    end 
 )    
Link to comment

Nope don't work still here's the full code -

CLIENT SIDE

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) 
  
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 (localPlayer == wDrink ) then 
   triggerServerEvent("tDrink", localPlayer) 
   guiSetVisible(eatMenu,false) 
   showCursor(false) 
    end 
end 
) 
  
--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) 

SERVER SIDE

addEvent('tDrink', true ) 
addEventHandler('tDrink', root, 
function ( ) 
    daBlockz = getElementData(root,"blockz") 
    daAnimz = getElementData(root,"animz") 
        if daBlockz == "DANCING" and daAnimz == "dnce_m_b" then 
            setPedAnimation(source,false) 
        else 
        setTimer( setPedAnimation, 100, 1, source, "DANCING", "dnce_m_b" ) 
        end 
    end 
 )   
  
--stop animation [example button 02] 
addEvent ("AnimationOff", true) 
addEventHandler ("AnimationOff", getRootElement(), 
function() 
setPedAnimation ( client ) 
end) 

Link to comment
addEvent('tDrink', true ) 
addEventHandler('tDrink', root, 
    function ( ) 
        local daBlockz = getElementData(source,"blockz") -- Changed root => source 
        local daAnimz = getElementData(source,"animz")  -- Changed root => source 
        if daBlockz == "DANCING" and daAnimz == "dnce_m_b" then 
            setPedAnimation(source, false) 
        else 
            setTimer( function(player) setPedAnimation(player, "DANCING", "dnce_m_b" , -1, true, true, true, true) setElementData(player, "blockz", "DANCING") setElementData(player, "animz", "dnce_m_b") end, 100, 1, source) --Edited timer to also set new element data for blockz and animz 
        end 
    end 
 )  

Everything else should be alright.

Edited by Guest
Link to comment

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...