Perfect Posted April 25, 2012 Share Posted April 25, 2012 hi all i am making ped control script but i got problem . what is setElementID for control ped ? -- Server Side function Robot () drv = createPed(105,0,0,3) end addEventHandler("onResourceStart",getRootElement(),bot) addCommandHandler("Robot",Robot) --Client Side drvctrls = {forwards="num_8,backwards="num_5",left="num_4",right="num_6",enter_exit="num_0"} function ctrldrv () for ctrl,key in pairs(drvctrls) do setPedControlState(drv,ctrl,getKeyState(key)) end end addEventHandler("onClientPreRender",getRootElement(),ctrldrv) Link to comment
Booo Posted April 25, 2012 Share Posted April 25, 2012 try this maybe run !! function Robot () drv = createPed(105,0,0,3) end addEventHandler("onResourceStart",getRootElement(),Robot) addCommandHandler("Robot",Robot) drvctrls = { { forwards="num_8", backwards="num_5", left="num_4", right="num_6", enter_exit="num_0" } } function ctrldrv () for k,v in ipairs(drvctrls) do setPedControlState(drv,k[1],getKeyState(v[1])) setPedControlState(drv,k[2],getKeyState(v[2])) setPedControlState(drv,k[3],getKeyState(v[3])) setPedControlState(drv,k[4],getKeyState(v[4])) setPedControlState(drv,k[5],getKeyState(v[5])) end end addEventHandler("onClientPreRender",getRootElement(),ctrldrv) Link to comment
Perfect Posted August 21, 2012 Author Share Posted August 21, 2012 Sorry for too late reply that was not working Link to comment
TAPL Posted August 21, 2012 Share Posted August 21, 2012 -- Server Side -- function Robot () drv = createPed(0,2494.73828,-1669.46558,13.33595) setElementID(drv,"myPed") end addEventHandler("onResourceStart",resourceRoot,Robot) -- Client Side -- drvctrls = {forwards="num_8", backwards="num_5", left="num_4", right="num_6", enter_exit="num_0"} function ctrldrv () for ctrl,key in pairs(drvctrls) do setPedControlState(getElementByID("myPed"),ctrl,getKeyState(key)) end end addEventHandler("onClientPreRender",getRootElement(),ctrldrv) Link to comment
Perfect Posted August 21, 2012 Author Share Posted August 21, 2012 -- Server Side -- function Robot () drv = createPed(0,2494.73828,-1669.46558,13.33595) setElementID(drv,"myPed") end addEventHandler("onResourceStart",resourceRoot,Robot) [/lua] and there can i add command handler ? function Robot () drv = createPed(0,2494.73828,-1669.46558,13.33595) setElementID(drv,"myPed") end addEventHandler("onResourceStart",resourceRoot,Robot) addCommandHandler("Robot",Robot) Link to comment
TAPL Posted August 21, 2012 Share Posted August 21, 2012 By doing this, you will be able to control the ped that have just created only. Link to comment
Perfect Posted August 21, 2012 Author Share Posted August 21, 2012 By doing this, you will be able to control the ped that have just created only. I can't start resource, i always get meta pharse (something) and i checked meta more then 10 times and i also try coping other resource meta and pasting but still getting meta phase "Perfect" name="robot" description="controllable ped" version="1.0.1" type="script" /> and can you tell me what thing happend if i write /robot 2 or more times ? Link to comment
TAPL Posted August 23, 2012 Share Posted August 23, 2012 By doing this, you will be able to control the ped that have just created only. I can't start resource, i always get meta pharse (something) and i checked meta more then 10 times and i also try coping other resource meta and pasting but still getting meta phase "Perfect" name="robot" description="controllable ped" version="1.0.1" type="script" /> and can you tell me what thing happend if i write /robot 2 or more times ? your meta is fine. if you write it more than 1 times, you will not be able to control the other ped, only the first one. From Wiki: If more than one element with the same ID exists, only the first one in the order it appears in the XML tree will be returned by this function. https://wiki.multitheftauto.com/wiki/GetElementByID if you still have problem with it, upload the resource at mediafire, i'll check it. 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