Jump to content

setPedAnimation function


Recommended Posts

Posted

Hello i have a problem i want add bots to my server and give them simple anim i use this code

  
function pedLoad () 
  
ped1 = createPed(247, 2242.598, 2151.254, 10.67) 
setPedRotation(ped1, 115)  
giveWeapon(ped1, 34, 1, true) 
setPedAnimation ( ped1, "BAR", "Barcustom_loop", 1, true, true, true) 
  
end 
  
addEventHandler ( "onResourceStart", getRootElement(), pedLoad ) 

meta

  
<meta> 
    <info type="script" author="test" version="1.0" /> 
     
    <script type="server" src="client.lua" /> 
     
     
</meta> 

But this code not working aswell i mean bot spawn and rotation works good but anims and give weapon not working.Bot just stand and dont do nothing.Can somebody told me whats wrong ?

Posted

First welcome to the mta forum :) .

Second you're posting on the wrong section :roll: !

Scripting Section Here

And you're problem is you are set the meta.xml file to client and the script should be server and change get root element to get resource root element get this resource > resourceRoot .

Posted
First welcome to the mta forum .

Thanks nice to meet you.

Second you're posting on the wrong section !

Sorry when i saw this

HELP! HELP! Need help? Post here. 

On subfroum i thought that was good section.Anyway i dont want make other topic so can moderator move it to right section?

And you're problem is you are set the meta.xml file to client and the script should be server and change get root element to get resource root element get this resource > resourceRoot .

The file type is set to server but file name is a client.lua.Ok so i change getRootElement to resourceRoot but now script say this:

attempt to call global 'resourceRoot'

Im new in lua scripting only what i want to do is only put ped with aim :|

Posted

Yes, I've reported the topic and I think the mta moderators will soon move the topic to the right section .

-- # Server Side 
function pedLoad () 
        ped1 = createPed( 247, 2242.598, 2151.254, 10.67,115 ) 
        setTimer( 
            function (  ) 
            setPedAnimation ( ped1, "BAR", "Barcustom_loop", 1, true, true, true ) 
            giveWeapon ( ped1,34,1,true ) 
        end,50,1 
    ) 
end 
addEventHandler ( "onResourceStart",resourceRoot, pedLoad ) 
Posted

Thanks it's working :) But there is bug if i start script and im far away from ped when i get closer to him he dont do animation .But when i start script near ped then its work fine.Is there any solution for that or it is a game bug or something like that ?

Posted

Your little patch does not help.But i realy appreciate that you try help me. :wink: But maybe there is a way to solve this .I dont know lua language but i know is powerfull thing.Is that possible to script get auto load if player is in some area near ped ?

Posted

If player join in some area then will be send a message to server and as call back ped will be spawn or something like that.Because like i said before when somebody join to server or is far away from ped when he come close to him he dont see animations and holding weapon only standing ped.I think about making a big marker (cylinder for example) and the ped will spawn if player be in marker.

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