Jump to content

Need HELP URGENT! Animation!


FlyingSpoon

Recommended Posts

Posted

Well I am trying to get this animation to work on me when I hit a certain button, but it says bad argument,

SERVER SIDE

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

Posted

place the server side function

setPedAnimation 

  
--example 
setPedAnimation ( thePlayer, "VENDING", "VEND_Drink_P", 2.1, false) 
else 
setPedAnimation ( thePlayer )-- stop animation 

Posted

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) 

Posted

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) 

Posted

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 
) 

Posted
I think it works, but it doesn't set the animation on me for some reason, when I press my button nothing happens.

:lol::lol::lol:

create one button to add and stop, in panel

Animation: [On] [Off] :wink:

Posted

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

Posted

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 
) 
  
  

Posted
There's alot of Errors in Your Code , I dont know why you trigger for the resourceRoot ?

just I gave an example for him, the more he did not understand :lol::lol:

Posted

You didn't helped him since your example is wrong , use getLocalPlayer() instead of resourceRoot . I would fix it by myself but i'm currently on my phone.

Posted
You didn't helped him since your example is wrong , use getLocalPlayer() instead of resourceRoot . I would fix it by myself but i'm currently on my phone.

LOLL :lol:

I have not used resourceRoot, read my example of script :wink:

I used

getRootElement() 

:lol::lol:

Posted
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?

Posted

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) 
  
  

Posted

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 
 )    
Posted

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) 

Posted (edited)
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

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