gokalpfirat Posted July 11, 2011 Share Posted July 11, 2011 function onResourceStart() vehicle = getPedOccupiedVehicle(g_P) x,y,z = getElementPosition(vehicle) rx,ry,rz = getVehicleRotation(vehicle) rocket = createObject(3786,x,y,z + 1.2,rx,ry,rz) attachElements(rocket,g_P,0,0,2,rx,ry,rz) end addEventHandler("onClientResourceStart", resourceRoot, onResourceStart) I create this script but my rocket dont look where car looks. Link to comment
Aibo Posted July 11, 2011 Share Posted July 11, 2011 1. use local variable for vehicle (since it can change and player can be not in a vehicle at all) 2. you may want to use some vehicle entry event, to attach a rocket to the current vehicle. 3. you dont need to know vehicle rotation or set rotation in createObject, because when you'll attach the rocket to the car it will recieve the same position and rotation as the car anyway 4. offsets should be relative to the parent element. function onResourceStart() local vehicle = getPedOccupiedVehicle(g_P) if vehicle then local x, y, z = getElementPosition(vehicle) rocket = createObject(3786, x, y, z) attachElements(rocket, vehicle, 0, 0, 2, 0, 0, 0) end end addEventHandler("onClientResourceStart", resourceRoot, onResourceStart) if the rocket is not in the right direction, you'll have to change rotation offsets in attachElements (last 3 zeros), usually by 90 or 180 degrees on some axis. Link to comment
gokalpfirat Posted July 13, 2011 Author Share Posted July 13, 2011 Aibo when map starts it creates object but i cant see others rocket objects why? Link to comment
Phat Looser Posted July 13, 2011 Share Posted July 13, 2011 Client side / Server side issue. That means you create your stuff client side. You bad. Link to comment
bandi94 Posted July 13, 2011 Share Posted July 13, 2011 attach a object need to be server side use :"onVehicleEnter" and "onVehicleExit" (if you make attach client side only you will see the attached element on the car other player wil not see that object ...) Link to comment
gokalpfirat Posted July 13, 2011 Author Share Posted July 13, 2011 I fixed it but i have got 2 problems. I use this script on my race map but when map starts object doesnt creates. The other problem is when player die object is staying where player dies. How can i fix 2 bugs. P.s: I use onMapStarting too Link to comment
bandi94 Posted July 13, 2011 Share Posted July 13, 2011 addEventHandler "onVehicleExit" and "onPlayerQuit" destroyElement ( your element ) and if you use on a map try "onResourceStart" 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