FlyingSpoon Posted February 23, 2015 Posted February 23, 2015 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) GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
#RooTs Posted February 23, 2015 Posted February 23, 2015 place the server side function setPedAnimation --example setPedAnimation ( thePlayer, "VENDING", "VEND_Drink_P", 2.1, false) else setPedAnimation ( thePlayer )-- stop animation
FlyingSpoon Posted February 23, 2015 Author Posted February 23, 2015 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) GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
#RooTs Posted February 23, 2015 Posted February 23, 2015 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)
FlyingSpoon Posted February 23, 2015 Author Posted February 23, 2015 Doesn't set the animation for me. GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
#RooTs Posted February 23, 2015 Posted February 23, 2015 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 )
FlyingSpoon Posted February 23, 2015 Author Posted February 23, 2015 I think it works, but it doesn't set the animation on me for some reason, when I press my button nothing happens. GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
#RooTs Posted February 23, 2015 Posted February 23, 2015 I think it works, but it doesn't set the animation on me for some reason, when I press my button nothing happens. create one button to add and stop, in panel Animation: [On] [Off]
FlyingSpoon Posted February 23, 2015 Author Posted February 23, 2015 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 GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
#RooTs Posted February 23, 2015 Posted February 23, 2015 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 )
FlyingSpoon Posted February 23, 2015 Author Posted February 23, 2015 Don't seem to work. GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
FlyingSpoon Posted February 23, 2015 Author Posted February 23, 2015 Please help, I can PM you full script? GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
#RooTs Posted February 23, 2015 Posted February 23, 2015 Please help, I can PM you full script? okay give-me
Max+ Posted February 24, 2015 Posted February 24, 2015 There's alot of Errors in Your Code , I dont know why you trigger for the resourceRoot ? - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
#RooTs Posted February 24, 2015 Posted February 24, 2015 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
xeon17 Posted February 24, 2015 Posted February 24, 2015 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. A unique GangWar gamemode waiting for you!Click here for more information.
#RooTs Posted February 24, 2015 Posted February 24, 2015 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 I have not used resourceRoot, read my example of script I used getRootElement()
FlyingSpoon Posted February 24, 2015 Author Posted February 24, 2015 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? GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
xeon17 Posted February 24, 2015 Posted February 24, 2015 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) A unique GangWar gamemode waiting for you!Click here for more information.
FlyingSpoon Posted February 24, 2015 Author Posted February 24, 2015 Idk if it's right or wrong But when I press the button for some reason the animation isnt set, you can see the pictures in the spoiler - GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
Max+ Posted February 24, 2015 Posted February 24, 2015 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 ) - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
FlyingSpoon Posted February 24, 2015 Author Posted February 24, 2015 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) GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
Addlibs Posted February 24, 2015 Posted February 24, 2015 (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 February 24, 2015 by Guest Previously known as MrTasty.
FlyingSpoon Posted February 24, 2015 Author Posted February 24, 2015 Dont work. GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
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