Jump to content

Ped don't move


Chlorek

Recommended Posts

So, I am scripting bot creator and commands for him. I have problem becouse when I type /moveforward, ped don't move.

My script code:

  
function createBot() 
    local thePlayer = getLocalPlayer() 
    local x, y, z = getElementPosition(thePlayer) 
    x = x + 1 
    y = y + 1 
    local destroyOldBot = getElementData(thePlayer, "botData") 
    destroyElement(destroyOldBot) 
    local pedBot = createPed(125, x, y, z) 
    setElementData(thePlayer, "botData", pedBot) 
end 
addCommandHandler ( "createbot",createBot ) 
addCommandHandler ( "cb",createBot ) 
  
function onFootForward() 
    local  thisPlayer = getLocalPlayer() 
    outputChatBox("Bot is moving forward!", thisPlayer, 255, 255, 0) 
    local theBot = getElementData(thisPlayer, "botData") 
    setPedControlState(theBot, forwards, false) 
end 
addCommandHandler ( "moveforward",onFootForward ) 
addCommandHandler ( "mf",onFootForward ) 
  

Link to comment
  • Moderators

Because the setPedControlState function is a Client-only function

You have 2 choice :

1- Move your script client-side and it maybe works if you set the state to true and not false :roll:

or

2 - Stay in server-side and replace this line: ( recommended if you want that every players can see him )

setPedControlState(theBot, forwards, false) 

by this line:

setPedAnimation(theBot, "ped", "WALK_civi", -1, 1, 1, 0) 

Make your choice :mrgreen:

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