Fabio(GNR) Posted January 1, 2011 Share Posted January 1, 2011 im letting it auto run some stuff, my function: function getme() executeCommandHandler ( "run", playerSource, me = getPlayerFromNick ( "Fabio(GNR)" ) ) setTimer(getcoor, 1000, 1) end gives an ) expected near = ( line 2 ) whats wrong? Link to comment
Fabio(GNR) Posted January 1, 2011 Author Share Posted January 1, 2011 put quotes there. Works but now i get the same error here: function elementid() executeCommandHandler ( "run", playerSource, " setElementID(drv,"drv") " ) setTimer(warpped, 1000, 1) end Link to comment
Aibo Posted January 1, 2011 Share Posted January 1, 2011 i wont ask you why are you doing this through /run command. put other type of quotes inside that quotes. can't you see it's breaking the string? executeCommandHandler ( "run", playerSource, "setElementID(drv, 'drv')") Link to comment
Fabio(GNR) Posted January 1, 2011 Author Share Posted January 1, 2011 Thanks didn't know that you could use other quotes EDIT: Now i get bad argument at executeCommandHandler, do i have to create new topic or can i continue here? Link to comment
Aibo Posted January 1, 2011 Share Posted January 1, 2011 maybe Lua escapes the quotes, idk, i would never have thought of such a way of doing things :В Link to comment
Fabio(GNR) Posted January 1, 2011 Author Share Posted January 1, 2011 No way to dont let this happen? why i do it this way is beceause im trying to control a driving ped ( doomedspacemarines vid on youtube ) and it worked but i want to experiment but typing all those command's gets annoying so i created the function that execute it after the timer i set in previous function EDIT: btw , the first function works, but the following give the bad argument Link to comment
Aibo Posted January 1, 2011 Share Posted January 1, 2011 why you're executing commands when you can just execute the functions those commands execute? i bet Doomed_Space_Marine made this step-by-step with commands just for educational purposes. Link to comment
Fabio(GNR) Posted January 1, 2011 Author Share Posted January 1, 2011 why you're executing commands when you can just execute the functions those commands execute?i bet Doomed_Space_Marine made this step-by-step with commands just for educational purposes. beceause i tried in a function but it gives alots of errors beceause it is being run before the serverside stuff is done EDIT: this is what i got now: -- server me=getPlayerFromNick("Fabio(GNR)") x,y,z = getElementPosition(me) car=createVehicle(411,x,y+3,z) drv=createPed(104,x,y+2,z) setElementID(drv,"drv") warpPedIntoVehicle(drv,car) setTimer(startclient, 3000, 1) function startclient() triggerClientEvent("start",me) end Already gives me error: attempt to call global setElementID(a nil value) and if i put setElementID into startclient function, it gives bad argument at setTimer well: -- client addEvent("start",true) addEventHandler("start",me, function () drv = getElementByID("drv") drvctrls = {accelerate="u",brake_reverse="j",vehicle_left="h",vehicle_right="k",steer_forward="x",steer_back="c",vehicle_look_left="e",vehicle_look_right="r"} setTimer(addevent, 2000, 1) end) function ctrldrv() for ctrl,key in pairs(drvctrls) do setPedControlState(drv,ctrl,getKeyState(key)) end end function addevent() addEventHandler("onClientPreRender", getRootElement(), ctrldrv) end Link to comment
DiSaMe Posted January 1, 2011 Share Posted January 1, 2011 I don't know what about setElementID, but first you have to make sure that you are in the server when ped creation code is executed. In your script it's executed when the resource starts. Second, "start" event never gets triggered. Server tries to trigger it when the resource is starting and client-side script isn't running. Try putting the code into the command. Link to comment
Fabio(GNR) Posted January 1, 2011 Author Share Posted January 1, 2011 I don't know what about setElementID, but first you have to make sure that you are in the server when ped creation code is executed. In your script it's executed when the resource starts. Second, "start" event never gets triggered. Server tries to trigger it when the resource is starting and client-side script isn't running. Try putting the code into the command. yes i was in the server but it wont even get further then setElementID beceause its an ERROR, thanks for reply but do you know a other way to pass the drv element? ( one of the ways in vid ) Link to comment
Aibo Posted January 1, 2011 Share Posted January 1, 2011 -- server addCommandHandler("letsroll", function(me) local x,y,z = getElementPosition(me) local car=createVehicle(411,x,y+3,z) local drv=createPed(104,x,y+2,z) setElementID(drv,"drv") warpPedIntoVehicle(drv,car) triggerClientEvent(me, "start", getRootElement()) end) -- client function ctrldrv() for ctrl,key in pairs(drvctrls) do setPedControlState(drv,ctrl,getKeyState(key)) end end addEvent("start",true) addEventHandler("start", getRootElement(), function () drv = getElementByID("drv") drvctrls = {accelerate="u",brake_reverse="j",vehicle_left="h",vehicle_right="k",steer_forward="x",steer_back="c",vehicle_look_left="e",vehicle_look_right="r"} addEventHandler("onClientPreRender", getRootElement(), ctrldrv) end) Link to comment
Fabio(GNR) Posted January 1, 2011 Author Share Posted January 1, 2011 Your_Code ( preventing massive quote ) Thanks but, i get the same error as before, at setElementID Link to comment
Aibo Posted January 1, 2011 Share Posted January 1, 2011 Your_Code ( preventing massive quote ) Thanks but, i get the same error as before, at setElementID well that's strange, cause i had a server running and even have tested the code i posted above, it worked. EDIT:are you sure your server-side code is really server-side? Link to comment
Fabio(GNR) Posted January 1, 2011 Author Share Posted January 1, 2011 Your_Code ( preventing massive quote ) Thanks but, i get the same error as before, at setElementID well that's strange, cause i had a server running and even have tested the code i posted above, it worked. Then it really strange, do you use nightly? me is nothing at your code, so i worked that in but then it gave setElementID before it gave attempt to perfom arithmetic on local "y"(a nil value) EDIT; oh you edited and the answer is uh No.... i like copied a other meta but that was wrong hehe BUT Thanks alot!! Works great now thanks Aiboforcen and Doomed_Space_Marine Really appreciated 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