Jump to content

Small Question


Fabio(GNR)

Recommended Posts

Posted

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?

Posted
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 

Posted

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')") 

Posted

Thanks :P didn't know that you could use other quotes :P

EDIT: Now i get bad argument at executeCommandHandler, do i have to create new topic or can i continue here?

Posted

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 :S

Posted

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.

Posted
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 :S 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 
  

Posted

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.

Posted
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 )

Posted
-- 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) 

Posted
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?

Posted
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 :shock::o:shock::o:shock::oops::oops::oops::oops: 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 ;)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...