Maxaxle Posted July 14, 2010 Share Posted July 14, 2010 I was just wondering how I would go about making a car option menu for turning on/off the lights and engine, putting an alarm on it (possibly), and locking/unlocking the car (to others). Perhaps if I started with key binds, it would make things easier. In the meantime, I guess I'll setup the folder and meta.xml for the whole thing... If this gets anywhere, I might add a specific-part-repairer, such as repairing only the windshield, or only the front bumper, etc. EDIT: I got a basic script set up, but the script editor persists in telling me it has errors. What's wrong with it? bindkey ( player, "[", "setVehicleEngineState ( theVehicle, true )" ) bindkey ( player, "]", "setVehicleEngineState ( theVehicle, false )" ) end keyturn function lights bindkey ( player, ";", "setVehicleOverrideLights ( theVehicle, true)" ) bindkey ( player, "'", "setVehicleOverrideLights ( theVehicle, false)" ) end lights Link to comment
Callum Posted July 14, 2010 Share Posted July 14, 2010 1. any function requires a () after it's name. 2. End's do not require the function name after them. 3. Bind key has 4 args, look at the wiki page. If you want a menu, look into GUI or DX (I'd go with GUI). Link to comment
dzek (varez) Posted July 14, 2010 Share Posted July 14, 2010 your script is just random words.. i know in real life, on your exams for example, you can talk around the problem/topic, but in programming your have to be precise. read other's scripts, read this: https://wiki.multitheftauto.com/wiki/Scripting_Introduction then re-try making your script. warning! you will have to spend at least 2hours on it. you cant learn scripting in 5 minutes.. ps. afaik - there is script like that in community - you can find it, and see how its done Link to comment
Maxaxle Posted July 14, 2010 Author Share Posted July 14, 2010 your script is just random words..i know in real life, on your exams for example, you can talk around the problem/topic, but in programming your have to be precise. read other's scripts, read this: https://wiki.multitheftauto.com/wiki/Scripting_Introduction then re-try making your script. warning! you will have to spend at least 2hours on it. you cant learn scripting in 5 minutes.. ps. afaik - there is script like that in community - you can find it, and see how its done 1. I saw the intro earlier, it's not that useful (to me). 2. Do you know where the similar script is? 3. You have to realize I have no clue what I'm doing. Link to comment
dzek (varez) Posted July 14, 2010 Share Posted July 14, 2010 1. I saw the intro earlier, it's not that useful (to me).2. Do you know where the similar script is? 3. You have to realize I have no clue what I'm doing. 1. if this was not useful - you didnt read it carefully, slowly, step by step.. you really need some time to learn.. its not 1-2-3 and magic happen.. 2. https://community.multitheftauto.com/ I'm almost sure that there was one like that 3. Yea, i've already noticed that (re-read my first words in my 1st reply) Link to comment
Castillo Posted July 15, 2010 Share Posted July 15, 2010 somthing like this u want? addEventHandler("onClientVehicleEnter", getRootElement(), function(thePlayer, seat) if thePlayer == getLocalPlayer() then Panel_Window = guiCreateWindow(797,171,174,123,"VEHICLE PANEL",false) guiWindowSetMovable(Panel_Window,false) guiWindowSetSizable(Panel_Window,false) Engine_Label = guiCreateLabel(0.0747,0.252,0.8046,0.2195,"Engine status: Off ",true,Panel_Window) guiLabelSetColor(Engine_Label,255,255,255) guiLabelSetVerticalAlign(Engine_Label,"top") guiLabelSetHorizontalAlign(Engine_Label,"left",false) Doors_Label = guiCreateLabel(0.069,0.6829,0.8621,0.1951,"Door Status: Locked ",true,Panel_Window) guiLabelSetColor(Doors_Label,255,255,255) guiLabelSetVerticalAlign(Doors_Label,"top") guiLabelSetHorizontalAlign(Doors_Label,"left",false) Lights_Label = guiCreateLabel(0.069,0.4715,0.8046,0.2114,"Lights Status: On ",true,Panel_Window) guiLabelSetColor(Lights_Label,255,255,255) guiLabelSetVerticalAlign(Lights_Label,"top") guiLabelSetHorizontalAlign(Lights_Label,"left",false) playervehicle = getPedOccupiedVehicle ( thePlayer ) if getVehicleOverrideLights ( playervehicle ) == 2 then guiSetText ( Lights_Label, "Lights status: On " ) else guiSetText ( Lights_Label, "Lights status: Off " ) end playervehicle = getPedOccupiedVehicle ( thePlayer ) if isVehicleLocked ( playervehicle ) then guiSetText ( Doors_Label, "Door status: Locked " ) else guiSetText ( Doors_Label, "Door status: Unlocked " ) end playervehicle = getPedOccupiedVehicle ( thePlayer ) local engine1 = getVehicleEngineState ( playervehicle ) if ( engine1 == false ) then guiSetText ( Engine_Label, "Engine status: Off " ) else guiSetText ( Engine_Label, "Engine status: On " ) end end end ) function enginefunc(state) local clientPlayer = getLocalPlayer() if isPedInVehicle(clientPlayer) == true then local playerVehicle = getPedOccupiedVehicle ( clientPlayer) local engine = getVehicleEngineState ( playerVehicle ) if ( engine == false ) then setVehicleEngineState( playerVehicle, true ) guiSetText ( Engine_Label, "Engine status: On " ) else setVehicleEngineState( playerVehicle, false ) guiSetText ( Engine_Label, "Engine status: Off " ) end else outputChatBox("You are not in a vehicle",255,0,0,true) end end function lightsfunc(state) local clientPlayer = getLocalPlayer() if isPedInVehicle(clientPlayer) == true then local playerVehicle = getPedOccupiedVehicle ( clientPlayer) if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then setVehicleOverrideLights ( playerVehicle, 2 ) guiSetText ( Lights_Label, "Lights status: On " ) guiLabelSetColor(lbllight,0,200,0) else setVehicleOverrideLights ( playerVehicle, 1 ) guiLabelSetColor(lbllight,200,0,0) guiSetText ( Lights_Label, "Lights status: Off " ) end else outputChatBox("You are not in a vehicle",255,0,0,true) end end function doorsfunc(state) local clientPlayer = getLocalPlayer() if isPedInVehicle(clientPlayer) == true then local playerVehicle = getPedOccupiedVehicle ( clientPlayer) if isVehicleLocked ( playerVehicle ) then setVehicleLocked ( playervehicle, false ) guiSetText ( Doors_Label, "Door status: Unlocked " ) else setVehicleLocked ( playervehicle, true ) guiSetText ( Doors_Label, "Door status: Locked " ) end else outputChatBox("You are not in a vehicle",255,0,0,true) end end function bindTheKeys() bindKey ("1", "down", enginefunc) bindKey ("2", "down", lightsfunc) bindKey ("3", "down", doorsfunc) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), bindTheKeys) addEventHandler("onClientVehicleExit", getRootElement(), function(thePlayer, seat) if thePlayer == getLocalPlayer() then destroyElement(Panel_Window) end end ) Link to comment
Lordy Posted July 15, 2010 Share Posted July 15, 2010 What is the point of posting a complete script which he can just blindly copy-paste and then ask for a new one, instead of spending some time to answer his problems so next time he wouldn't have to ask anymore. Link to comment
Castillo Posted July 15, 2010 Share Posted July 15, 2010 What is the point of posting a complete script which he can just blindly copy-paste and then ask for a new one, instead of spending some time to answer his problems so next time he wouldn't have to ask anymore. I dont know, should i remove my code? Link to comment
Maxaxle Posted July 15, 2010 Author Share Posted July 15, 2010 I just speed-read the script, it seems to be EXACTLY what I'm after, though I honestly want to learn how to script that kind of stuff. EDIT: Out of curiosity, I pasted the code into the Script Editor, and there are tons of "unexpected symbol" errors and a few " expected near end" errors. Link to comment
Castillo Posted July 16, 2010 Share Posted July 16, 2010 I just speed-read the script, it seems to be EXACTLY what I'm after, though I honestly want to learn how to script that kind of stuff.EDIT: Out of curiosity, I pasted the code into the Script Editor, and there are tons of "unexpected symbol" errors and a few " expected near end" errors. Thats impossible cause ive tested it before post it here check what u did wrong. Link to comment
Lordy Posted July 16, 2010 Share Posted July 16, 2010 I just speed-read the script, it seems to be EXACTLY what I'm after, though I honestly want to learn how to script that kind of stuff.EDIT: Out of curiosity, I pasted the code into the Script Editor, and there are tons of "unexpected symbol" errors and a few " expected near end" errors. You did switch line numbers off before copying, right? Or didn't you? @Solidsnake, it's hard to read the code with such indenting.. Link to comment
Maxaxle Posted July 17, 2010 Author Share Posted July 17, 2010 I just speed-read the script, it seems to be EXACTLY what I'm after, though I honestly want to learn how to script that kind of stuff.EDIT: Out of curiosity, I pasted the code into the Script Editor, and there are tons of "unexpected symbol" errors and a few " expected near end" errors. You did switch line numbers off before copying, right? Or didn't you? @Solidsnake, it's hard to read the code with such indenting.. The text stayed exactly the same between editor and post, line numbers and all. Link to comment
AeroXbird Posted July 20, 2010 Share Posted July 20, 2010 probably an end too much, or too few and probably forgot to put " " where needed. 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