Jump to content

Server sided nos color with markers


Slim

Recommended Posts

I'm trying to get this script to work
It works if I remove the key binding portion, but it's an example.
This is non functioning but I tried :/
Does anyone know why it won't detect the key press?
Also could someone provide me the element code or whatever to make the markers visible to everyone instead of client sided?|
Please and thank you

bindKey("w","up",
function resource_starts ()
destroyElement(arrowMarker1) 
destroyElement(arrowMarker2)
destroyElement(arrowMarker3) 
destroyElement(arrowMarker4) 
destroyElement(arrowMarker5) 
destroyElement(arrowMarker6) 
end
end
addEventHandler ( "onClientResourceStart", getRootElement(), resource_starts )

bindKey("w","down",
function explodeNitrousVehicle()
if isPedInVehicle(localPlayer) then -- Check if the player is in a vehicle
local pVehicle = getPedOccupiedVehicle(localPlayer)
if pVehicle and getVehicleUpgradeOnSlot(pVehicle,  then -- Check if the vehicle has nitrous added in it
if isVehicleNitroActivated(pVehicle) then -- Check if the nitro is activated and the vehicle is not moving
arrowMarker1 = createMarker ( 0, 0, 0, "corona", 0.3, 255, 0, 0) -- Create the markers
arrowMarker2 = createMarker ( 0, 0, 0, "corona", 0.3, 255, 0, 0)
arrowMarker3 = createMarker ( 0, 0, 0, "corona", 0.3, 255, 0, 0) -- Create the markers
arrowMarker4 = createMarker ( 0, 0, 0, "corona", 0.3, 255, 0, 0)
arrowMarker5 = createMarker ( 0, 0, 0, "corona", 0.2, 255, 0, 0) -- Create the markers
arrowMarker6 = createMarker ( 0, 0, 0, "corona", 0.2, 255, 0, 0)               
attachElements ( arrowMarker1, localPlayer, 0.2, -2.8, -0.2 ) -- Attach the marker to the player    
attachElements ( arrowMarker2, localPlayer, 0.8, -2.8, -0.2 )
attachElements ( arrowMarker3, localPlayer, 0.2, -2.9, -0.2 ) -- Attach the marker to the player
attachElements ( arrowMarker4, localPlayer, 0.8, -2.9, -0.2 )
attachElements ( arrowMarker5, localPlayer, 0.2, -3, -0.2 ) -- Attach the marker to the player
attachElements ( arrowMarker6, localPlayer, 0.8, -3, -0.2 )
end
end
end
end
end
addEventHandler("onClientRender", root, explodeNitrousVehicle)

https://ibb.co/g0hxY5
https://ibb.co/ms8FLk

Edited by Justin|X5|
Link to comment
function myFunction()
  	outputChatBox("Function")
end

bindKey("w", "up", myFunction)
  
  
OR
 
bindKey("w", "up", function()
	outputChatBox("Function")  
end)
  
WRONG
  
bindKey("w", "up", function myFunction()
	outputChatBox("Function")    
end)

When binding a key (or using anything else that takes functions), you either give it an already declared function name or an anonymous function without any names. An anonymous function cannot be called again, that is the whole purpose of it. So, if you want to bind a key to a function that could be called different ways as well, eg. on events, command, you will need to declare a function outside the bindKey.

Edited by pa3ck
  • Like 1
Link to comment

Thanks bro.

Anyone know how to make it fade in and out?

 

function myFunction1()
if isPedInVehicle(localPlayer) then -- Check if the player is in a vehicle
local pVehicle = getPedOccupiedVehicle(localPlayer)
if pVehicle and getVehicleUpgradeOnSlot(pVehicle, 8) then -- Check if the vehicle has nitrous added in it
local fVelX, fVelY, fVelZ = getElementVelocity(pVehicle)
if isVehicleNitroActivated(pVehicle) and fVelX ~= 0 and fVelY ~= 0 and fVelZ ~= 0 then -- Check if the nitro is activated and the vehicle is not moving
destroyElement(arrowMarker1) 
destroyElement(arrowMarker2)
destroyElement(arrowMarker3) 
destroyElement(arrowMarker4) 
destroyElement(arrowMarker5) 
destroyElement(arrowMarker6) 
end
end
end
end
addEventHandler("onClientRender", getRootElement(), myFunction1)
bindKey("w", "up", myFunction1)
function myFunction2()
if isPedInVehicle(localPlayer) then -- Check if the player is in a vehicle
local pVehicle = getPedOccupiedVehicle(localPlayer)
if pVehicle and getVehicleUpgradeOnSlot(pVehicle, 8) then -- Check if the vehicle has nitrous added in it
local fVelX, fVelY, fVelZ = getElementVelocity(pVehicle)
if isVehicleNitroActivated(pVehicle) and fVelX ~= 0 and fVelY ~= 0 and fVelZ ~= 0 then -- Check if the nitro is activated and the vehicle is not moving
arrowMarker1 = createMarker ( 0, 0, 0, "corona", 0.3, 255, 0, 0) -- Create the markers
arrowMarker2 = createMarker ( 0, 0, 0, "corona", 0.3, 255, 0, 0)
arrowMarker3 = createMarker ( 0, 0, 0, "corona", 0.3, 255, 0, 0) -- Create the markers
arrowMarker4 = createMarker ( 0, 0, 0, "corona", 0.3, 255, 0, 0)
arrowMarker5 = createMarker ( 0, 0, 0, "corona", 0.2, 255, 0, 0) -- Create the markers
arrowMarker6 = createMarker ( 0, 0, 0, "corona", 0.2, 255, 0, 0)	           
attachElements ( arrowMarker1, localPlayer, 0.2, -2.8, -0.2 ) -- Attach the marker to the player	
attachElements ( arrowMarker2, localPlayer, 0.8, -2.8, -0.2 )
attachElements ( arrowMarker3, localPlayer, 0.2, -2.9, -0.2 ) -- Attach the marker to the player
attachElements ( arrowMarker4, localPlayer, 0.8, -2.9, -0.2 )
attachElements ( arrowMarker5, localPlayer, 0.2, -3, -0.2 ) -- Attach the marker to the player
attachElements ( arrowMarker6, localPlayer, 0.8, -3, -0.2 )
end
end
end
end
addEventHandler("onClientRender", getRootElement(), myFunction2)
bindKey("w", "down", myFunction2)

 

Link to comment
  • 1 month later...
  • Scripting Moderators

You cannot do this. I have tested something with marker about 1 year ago. The marker will delay to render after created or set its size.Obj + shader is better than using marker.

Edited by thisdp
  • Like 1
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...