TheSmart Posted March 18, 2015 Share Posted March 18, 2015 Hello guys! i'm learning scripting today i make simple ped animation script but it not working here is my code. function Ped() ped1 = createPed(107, 2490.5, -1651.5, 13.5) setPedRotation(ped1, 90.0041198) setPedAnimation( ped1, "ped", "M_smklean_loop") end addEventHandler("onResourceStart", getRootElement(), makPed) or i want to give him gun or if player attack him, ped will shoot him with his gun please tell me how i can do it. Link to comment
JR10 Posted March 18, 2015 Share Posted March 18, 2015 Your function's name is Ped but you're passing makPed which is undefined. Rename your function to makPed. Link to comment
TheSmart Posted March 18, 2015 Author Share Posted March 18, 2015 function makePed() ped1 = createPed(107, 2490.5, -1651.5, 13.5) setPedRotation(ped1, 90.0041198) setPedAnimation( ped1, "ped", "M_smklean_loop") end addEventHandler("onResourceStart", getRootElement(), makePed) thnx but it not moving no error in debugscript Link to comment
TAPL Posted March 18, 2015 Share Posted March 18, 2015 Attach the event to resourceRoot instead of root element. And make sure you have the script server side in the meta. The block of M_smklean_loop isn't ped. https://wiki.multitheftauto.com/wiki/Animations Link to comment
TheSmart Posted March 18, 2015 Author Share Posted March 18, 2015 function makePed() ped1 = createPed(107, 2490.5, -1651.5, 13.5) setPedRotation(ped1, 90.0041198) setPedAnimation( ped1, "SMOKING", "M_smklean_loop") end addEventHandler("onResourceStart", resourceRoot, makePed) like that? but it not working ped won't do anything and it on server side Link to comment
TAPL Posted March 18, 2015 Share Posted March 18, 2015 Try with a timer. function makePed() ped1 = createPed(107, 2490.5, -1651.5, 13.5) setTimer(function() setPedRotation(ped1, 90.0041198) setPedAnimation(ped1, "SMOKING", "M_smklean_loop") end, 100, 1) end addEventHandler("onResourceStart", resourceRoot, makePed) Link to comment
TheSmart Posted March 18, 2015 Author Share Posted March 18, 2015 Try with a timer. function makePed() ped1 = createPed(107, 2490.5, -1651.5, 13.5) setTimer(function() setPedRotation(ped1, 90.0041198) setPedAnimation(ped1, "SMOKING", "M_smklean_loop") end, 100, 1) end addEventHandler("onResourceStart", resourceRoot, makePed) Thank you man its working now but i want more thing tell me how i can make it that i want to give him gun or if player attack him, ped will shoot him with his gun please tell me how i can do it. Link to comment
TAPL Posted March 18, 2015 Share Posted March 18, 2015 giveWeapon triggerClientEvent triggerServerEvent getElementPosition setPedAimTarget setPedControlState 'onClientPedDamage' Link to comment
TheSmart Posted March 18, 2015 Author Share Posted March 18, 2015 thank you very much Link to comment
Ryancit2 Posted March 29, 2015 Share Posted March 29, 2015 Well in that case, it's a bit hard due to wired desync happens sometimes randomly because of ped not handling functions attached to it completely. But you can try these functions: setPedLookAt or setPedAimTarget And build up a function to fire the aimed target, manually. 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