Chlorek Posted March 9, 2011 Share Posted March 9, 2011 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
Castillo Posted March 9, 2011 Share Posted March 9, 2011 Is this code client side? because setPedControlState works only client side if i'm right. Link to comment
Chlorek Posted March 9, 2011 Author Share Posted March 9, 2011 Yea, it's on client side. Link to comment
Moderators Citizen Posted March 9, 2011 Moderators Share Posted March 9, 2011 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 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 Link to comment
Moderators Citizen Posted March 9, 2011 Moderators Share Posted March 9, 2011 Yea, it's on client side. so try to set the state to true and not false and don't forget the "" like this: setPedControlState(theBot, "forwards", true) Link to comment
Chlorek Posted March 9, 2011 Author Share Posted March 9, 2011 O yeah, thanks Citizen. First code: "setPedControlState(theBot, forwards, false)" doesn't work. But secound works very well. Link to comment
Wojak Posted March 9, 2011 Share Posted March 9, 2011 if you want to use the controle states- cteate ped serverside, and use the syncer client to move it https://wiki.multitheftauto.com/wiki/GetElementSyncer https://wiki.multitheftauto.com/wiki/TriggerClientEvent 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