XeroXipher Posted October 3, 2022 Share Posted October 3, 2022 Hello MTA... Sorry for asking rookie questions so frequently. So, I am trying to make NPC's on the map walk around. I know I will have to give them a path to walk (Which I don't know how to do, but I'll get there). Right now I am finding it hard to get my NPC to even move. This is the very basic coding I have so far. Pedestrians.lua function pedLoad() local thePed = createPed ( 106, 2492, -1673, 13.25, 200) setPedAnimation(thePed, "ped", "walk_gang1", -1, true, true, false, true) outputChatBox("This command did something", player, 100, 255, 100) end addEventHandler ( "onResourceStart", getResourceRootElement(), pedLoad ) Now this works properly: local thePed = createPed ( 106, 2492, -1673, 13.25, 200) It creates my NPC and rotates him 200 degrees... But the rest of the coding doesn't do anything. I have tried setControlState: function pedLoad() local thePed = createPed ( 106, 2492, -1673, 13.25, 200) setControlState(thePed, "walk", true) setControlState(thePed, "forwards", true) outputChatBox("This command did something", player, 100, 255, 100) end addEventHandler ( "onResourceStart", getResourceRootElement(), pedLoad ) And nothing happened... I know with setControlState I also have to change his camera to move in different directions but I can't get him to move at all... So, if someone could help me I would appreciate it. Thank You. Link to comment
Addlibs Posted October 4, 2022 Share Posted October 4, 2022 The wiki's arguments list suggests setControlState only works on players, not any ped. Have you tried setPedControlState client-side? You can trigger it by firing off an event from the server that's handled on the client side. This may need a lot of synchronisation code though, as a client won't receive this event when connecting after the resource was started, nor if the resource starts and triggers onResourceStart before the client side is ready. Link to comment
XeroXipher Posted October 4, 2022 Author Share Posted October 4, 2022 Honestly, I am still learning and up until now I have only worked with server sided scripts but I'll try it out as a client script. Thanks for the advice. 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