Jump to content

help please.. - setVehicleComponentPosition- move spoiler...


nagymark686

Recommended Posts

i need help, how to make this work. Please...

-- Bind keys
function bindsetVehicleComponentPosition()
    bindKey(source, "p", "down", "setVehicleComponentPosition")
end
addEventHandler("onPlayerJoin", root, bindTurnIndicators)

-- Bind on resource start
for k,v in pairs(getElementsByType("players")) do
    bindKey(v, "p", "down", "resetVehicleComponentPosition")
    outputServerLog("player: "..getPlayerName(v))
end

-- Toggling Spoiler
function setVehicleComponentPosition( veh )
    if thePlayer press "p"
        setVehicleComponentPosition (theVeh, "movspoiler_25.0_3000", -0,003, -1,99, 0,48, 0)
                        end

 

I also wanted to know how to work this:

 

Link to post

1. You created binds on commands that don't exist.

2. this part of code won't work because 1 end missing.

function setVehicleComponentPosition( veh )
    if thePlayer press "p"
        setVehicleComponentPosition (theVeh, "movspoiler_25.0_3000", -0,003, -1,99, 0,48, 0)
                        end

3. Name of this function is setVehicleComponentPosition so you can't manage vehicle components

4. This function will instantly change position of component. You need setTimer function on onClientRender event

5. Your vehicle must have part called movspoiler_25.0_3000 (use zmodeller or other software to find/create it)

@nagymark686

  • Thanks 1
Link to post
11 hours ago, JeViCo said:

1. You created binds on commands that don't exist.

2. this part of code won't work because 1 end missing.


function setVehicleComponentPosition( veh )
    if thePlayer press "p"
        setVehicleComponentPosition (theVeh, "movspoiler_25.0_3000", -0,003, -1,99, 0,48, 0)
                        end

3. Name of this function is setVehicleComponentPosition so you can't manage vehicle components

4. This function will instantly change position of component. You need setTimer function on onClientRender event

5. Your vehicle must have part called movspoiler_25.0_3000 (use zmodeller or other software to find/create it)

@nagymark686

6. theVeh isn't identified

7. this code will cause alot of lag and consume server's cpu because of the function name that will cause an infinite loop

8. there's a missing ( then ) at line 15 

so . 

-- SERVER SIDE
addEventHandler("onPlayerJoin", root,
	function()
		bindKey(source, "p", "down", "change_Spoiler_Position")
	end
)

for _,v in pairs(getElementsByType("players")) do
    bindKey(v, "p", "down", "change_Spoiler_Position")
    outputServerLog("player: "..getPlayerName(v))
end


function spoiler(player)
	if isPedInVehicle(player) then
		local vehicle = getPedOccupiedVehicle(player)
		triggerClientEvent("CSP", player, vehicle)
	end
end
addCommandHandler("change_Spoiler_Position", spoiler)

-- Client SIDE 
addEvent("CSP", true)
addEventHandler("CSP", root,
	function(vehicle)
		if vehicle and isElement(vehicle) then
			if getKeyState("p") then
				setVehicleComponentPosition(vehicle, "movspoiler_25.0_3000", -0,003, -1,99, 0,48, 0)
			end
		end
	end
)

 

  • Thanks 1
Link to post

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