Jump to content

Need some serious help here...


tinnetju

Recommended Posts

Heey, i got some probs with my RC Car script. I think im done with my script, except setPedControlState, it keeps saying bad argumant in mta sa. I debugged it with the 50p script editor thing and he doesnt say anything. In my script i got a couple of setPedControlState's and he says they are all bad argument...

Here are my scripts:

Meta.xml:

        "Tinne_Spoel" version="1.0" type="script" description="A RC race track with rc cars" /> 
      

script_s.lua:

rccar1=createVehicle(441, -2932.93, 485.22, 4.91, 0, 0, 180) 
rccar2=createVehicle(441, -2934.93, 485.22, 4.91, 0, 0, 180) 
rccar3=createVehicle(441, -2936.93, 485.22, 4.91, 0, 0, 180) 
rccar4=createVehicle(441, -2938.93, 485.22, 4.91, 0, 0, 180) 
  
rccarman1=createPed(180, 3500, 485.22, 4.91) 
rccarman2=createPed(180, 3500, 485.22, 4.91) 
rccarman3=createPed(180, 3500, 485.22, 4.91) 
rccarman4=createPed(180, 3500, 485.22, 4.91) 
  
setElementID(rccarman1,"rccarman1") 
setElementID(rccarman2,"rccarman2") 
setElementID(rccarman3,"rccarman3") 
setElementID(rccarman4,"rccarman4") 
  
warpPedIntoVehicle(rccarman1,rccar1) 
warpPedIntoVehicle(rccarman2,rccar2) 
warpPedIntoVehicle(rccarman3,rccar3) 
warpPedIntoVehicle(rccarman4,rccar4) 
  
setVehicleDamageProof(rccar1,true) 
setVehicleDamageProof(rccar2,true) 
setVehicleDamageProof(rccar3,true) 
setVehicleDamageProof(rccar4,true) 
  
  
function replaceModel() 
  
  txd = engineLoadTXD("rcbandit.txd", 441 ) 
  engineImportTXD(txd, 441) 
  dff = engineLoadDFF("rcbandit.dff", 441 ) 
  engineReplaceModel(dff, 441) 
  
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel) 
  
  

script_c.lua

rccarman1=getElementByID("rccarman1") 
rccarman2=getElementByID("rccarman2") 
rccarman3=getElementByID("rccarman3") 
rccarman4=getElementByID("rccarman4") 
  
rccarman1controls={accelerate="w",brake_reverse="s",vehicle_left="a",vehicle_right="d",handbrake="space"} 
rccarman2controls={accelerate="w",brake_reverse="s",vehicle_left="a",vehicle_right="d",handbrake="space"} 
rccarman3controls={accelerate="w",brake_reverse="s",vehicle_left="a",vehicle_right="d",handbrake="space"} 
rccarman4controls={accelerate="w",brake_reverse="s",vehicle_left="a",vehicle_right="d",handbrake="space"} 
  
function ctrlrccarman1() 
for ctrl,key in pairs(rccarman1controls) do setPedControlState(rccarman1,ctrl,getKeyState(key)) 
end 
end 
  
function ctrlrccarman2() 
for ctrl,key in pairs(rccarman2controls) do setPedControlState(rccarman2,ctrl,getKeyState(key)) 
end 
end 
  
function ctrlrccarman3() 
for ctrl,key in pairs(rccarman3controls) do setPedControlState(rccarman3,ctrl,getKeyState(key)) 
end 
end 
  
function ctrlrccarman4() 
for ctrl,key in pairs(rccarman4controls) do setPedControlState(rccarman4,ctrl,getKeyState(key)) 
end 
end 
  
  
addEventHandler("onClientPreRender",getRootElement(),ctrlrccarman1) 
addEventHandler("onClientPreRender",getRootElement(),ctrlrccarman2) 
addEventHandler("onClientPreRender",getRootElement(),ctrlrccarman3) 
addEventHandler("onClientPreRender",getRootElement(),ctrlrccarman4) 

I hope you guys can help me! :)

And sorry for my bad english, im just a dutch person.

Edited by Guest
Link to comment
  
function replaceModel() 
  
  txd = engineLoadTXD("rcbandit.txd", 441 ) 
  engineImportTXD(txd, 441) 
  dff = engineLoadDFF("rcbandit.dff", 441 ) 
  engineReplaceModel(dff, 441) 
  
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel) 
  

That's a clientside script, you put it in a serverside file.

Link to comment
  • 2 weeks later...

He wanted to tell you that you should debug your script.

As a good scripter, it should be like breathing for you to know how to properly debug a script.

The easiest way to locate the source of problems is to add debug messages as dzek suggested.

Follow his link and the text here explains to you that you should just add certain output lines to your script.

When the script is executed afterwards, you can see, what and how far the messages got printed.

Then you can isolate the erroneous line more and more.

To learn this stuff means to become more autonomous in scripting/programming.

Just keep learning ;)

Link to comment
He wanted to tell you that you should debug your script.

As a good scripter, it should be like breathing for you to know how to properly debug a script.

The easiest way to locate the source of problems is to add debug messages as dzek suggested.

Follow his link and the text here explains to you that you should just add certain output lines to your script.

When the script is executed afterwards, you can see, what and how far the messages got printed.

Then you can isolate the erroneous line more and more.

To learn this stuff means to become more autonomous in scripting/programming.

Just keep learning ;)

How to learn if no ones helping? Im on not smart, im on one of the lowest study thingy's on school...

Link to comment
it's possible (?) that you can't getElementByID in client when script is loaded because server haven't yet set this id, cause its also loads the script.

just my guess, i'd use events to keep things 100% synced.

Well, the guy on this vid made it work!

I got all the script thingy's from him

Link to comment

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...