Gravestone Posted February 26, 2016 Share Posted February 26, 2016 I want to disable animation when the ped is in vehicle. I tried this, but it didn't work. Any help please? function stopAnimation2() if isPedInVehicle (g_Me) then server.setPedAnimation(g_Me, false) end Link to comment
Dimos7 Posted February 26, 2016 Share Posted February 26, 2016 function stopAnimation2(thePlayer) if isPedInVehicle(thePlayer) then setPedAnimation(thePlayer, false) end end Link to comment
KariiiM Posted February 26, 2016 Share Posted February 26, 2016 Be sure to add the function name in some where because 'thePlayer' isn't defined Link to comment
Gravestone Posted February 26, 2016 Author Share Posted February 26, 2016 I had the animation code in freeroam file. This is the code: --------------------------- --- Set animation window --------------------------- function applyAnimation(leaf) if type(leaf) ~= 'table' then leaf = getSelectedGridListLeaf(wndAnim, 'animlist') if not leaf then return end end server.setPedAnimation(g_Me, leaf.parent.name, leaf.name, true, true) end function stopAnimation() server.setPedAnimation(g_Me, false) end wndAnim = { 'wnd', text = 'Set animation', width = 250, x = -20, y = 0.3, controls = { { 'lst', id='animlist', width=230, height=290, columns={ {text='Animation', attr='name'} }, rows={xml='animations.xml', attrs={'name'}}, expandlastlevel=false, onitemdoubleclick=applyAnimation }, {'btn', id='set', onclick=applyAnimation}, {'btn', id='stop', onclick=stopAnimation}, {'btn', id='close', closeswindow=true} } } addCommandHandler('anim', function(command, lib, name) server.setPedAnimation(g_Me, lib, name, true, true) end ) The definition for this g_Me is "g_Me = getLocalPlayer()" Link to comment
KariiiM Posted February 26, 2016 Share Posted February 26, 2016 Well try this, it should works function stopAnimation2() local _vehicle = getPedOccupiedVehicle (g_Me) if _vehicle then server.setPedAnimation(g_Me, false) end end Link to comment
Gravestone Posted February 26, 2016 Author Share Posted February 26, 2016 Nope, did not work. Link to comment
DakiLLa Posted February 26, 2016 Share Posted February 26, 2016 (edited) Can you explain, you don't want to set animation if player is in vehicle, right? If so, try this code (replace applyAnimation() function): function applyAnimation(leaf) if type(leaf) ~= 'table' then leaf = getSelectedGridListLeaf(wndAnim, 'animlist') if not leaf then return end end --if not isPedInVehicle(g_Me) then if not getPedOccupiedVehicle(g_Me) then server.setPedAnimation(g_Me, leaf.parent.name, leaf.name, true, true) end end Edited February 27, 2016 by Guest Link to comment
KariiiM Posted February 26, 2016 Share Posted February 26, 2016 btw it's client side, and isPedInVehicle doesn't work there that's why, I changed isPedIn... to getPedOccupiedVehicle Link to comment
DakiLLa Posted February 27, 2016 Share Posted February 27, 2016 KariiiM, oh, alright, corrected my code Link to comment
Gravestone Posted February 27, 2016 Author Share Posted February 27, 2016 Thanks DakiLLa, it worked. But still there is a problem that anim binds are working when in a vehicle although the animation isn't working from F1 / Animation. Tried this, but didn't work: addCommandHandler('anim', function(command, lib, name) if not getPedOccupiedVehicle(g_Me) then server.setPedAnimation(g_Me, lib, name, true, true) end ) Link to comment
DakiLLa Posted February 27, 2016 Share Posted February 27, 2016 Yea, try this one (you forgot to put an extra 'end'): addCommandHandler('anim', function(command, lib, name) if not getPedOccupiedVehicle(g_Me) then server.setPedAnimation(g_Me, lib, name, true, true) end end ) 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