Greenie0101 Posted June 15, 2012 Share Posted June 15, 2012 Hey there, sorry that im making a new topic for pretty much the same thing but I really need help here! Ive made this code: meta.xml <meta> <script src="racer1.lua" type="server"></script> <script src="racer1_cl.lua" type="server"></script> </meta> racer1.lua function makeracer( source, key, keyState ) local gunner = createPed ( 0, 1990, 2620, 11) bindKey(source, "mouse1", "down", shoot) car = createVehicle (402, 1990, 2620,12) gun1 = createObject ( 362, 1990, 2620, 11) shoot1 = createVehicle (464, 1990, 2620, 11) attachElements (gun1, car, 0, 1.5, 0.5, 0, 30, 90) attachElements (shoot1, car, 0, 2, 0.2) setVehicleDamageProof(shoot1, true) setElementAlpha ( shoot1, 0) setElementCollisionsEnabled(shoot1, false) setVehicleLocked ( shoot1, true ) setVehicleEngineState ( shoot1, false ) warpPedIntoVehicle ( gunner, shoot1) setElementAlpha ( gunner, 0) end addCommandHandler("car", makeracer) function shoot() triggerClientEvent ("shootgun", gunner) end racer1_cl.lua function shootgun() setPedControlState ( gunner, "vehicle_fire", true) end addEvent("shootgun", true) addCommandHandler("car", makeracer) Ive only started scripting in the last month so its probs a dumb error. I want the invisible ped (gunner) who is in the invisible RC baron (shoot1) attached to the buffalo (car) to shoot the RC barons gun when the player (driving the buffalo) presses LMB. Whats wrong with what ive got? Link to comment
50p Posted June 15, 2012 Share Posted June 15, 2012 1. Your racer1_cl.lua is set as server-side script. 2. You haven't added any handler to "shootgun" event. 3. If racer1_cl.lua will be client-side then there is no gunner defined anywhere. 4. Making it client-side isn't ideal. Not sure if everyone will be able to see it shooting. Link to comment
Greenie0101 Posted June 15, 2012 Author Share Posted June 15, 2012 Well i want it to be server side but setPedControlState is client side and its thr only way i can make the ped shoot. Is there any other way to make the ped shoot? Link to comment
50p Posted June 16, 2012 Share Posted June 16, 2012 Try to fix the script first (my post above, 1-3) and ignore my last point for the time being. Once you get it shooting, test it with somebody to see it it's synced. It might be synced. Link to comment
DiSaMe Posted June 16, 2012 Share Posted June 16, 2012 I'd advise you to use element data. It's synced automatically by default, so you can set it on one client and all other clients will be able to see the changes and react to them. setElementData getElementData onClientElementDataChange When the key is pressed or released, use setElementData to change the data, such as: setElementData(ped, "shooting", keyState) And when element data of ped changes, set control state to whatever getElementData returns: local ctrlstate = getElementData(source, "shooting") 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