Hey guys,
I am really new to the whole scripting thing, but really would like to use it.
I got this script where the car in racemode would be undamageable.
It works fine when I use the onClientMarkerHit handler, but i don't want that.
function resource_starts ()
local vehicles = getElementsByType ( "vehicle" ) -- get a table of all the Vehicles in the server
for theKey,theVehicle in ipairs(vehicles) do -- use a generic for loop to step through each vehicle
if ( isVehicleOnGround ( theVehicle ) ) then -- if the vehicle is on the ground, announce it
outputChatBox ( getVehicleName ( theVehicle ) .. " is on the ground and made GOD-like" )
setVehicleDamageProof ( theVehicle, true )
else -- if the vehicle isn't on the ground, announce that it is in the air
outputChatBox ( getVehicleName ( theVehicle ) .. " is in the air and made GOD-like" )
setVehicleDamageProof ( theVehicle, true )
end
end
end
addEventHandler ( "onClientMarkerHit", getRootElement(), resource_starts )
(sorry for the whole outputchatbox thingy, but just want to be sure the script is working)
I would like to have it working at the start of the race.
And so it seems cause the outputchatbox thing works, only the setVehicleDamageproof don't.
function resource_starts ()
local vehicles = getElementsByType ( "vehicle" ) -- get a table of all the Vehicles in the server
for theKey,theVehicle in ipairs(vehicles) do -- use a generic for loop to step through each vehicle
if ( isVehicleOnGround ( theVehicle ) ) then -- if the vehicle is on the ground, announce it
outputChatBox ( getVehicleName ( theVehicle ) .. " is on the ground and made GOD-like" )
setVehicleDamageProof ( theVehicle, true )
else -- if the vehicle isn't on the ground, announce that it is in the air
outputChatBox ( getVehicleName ( theVehicle ) .. " is in the air and made GOD-like" )
setVehicleDamageProof ( theVehicle, true )
end
end
end
addEventHandler ( "onClientResourceStart", getRootElement(), resource_starts )
and..
addEventHandler('onClientResourceStart', resourceRoot,
function()
local vehicles = getElementsByType ( "vehicle" ) -- get a table of all the Vehicles in the server
for theKey,theVehicle in ipairs(vehicles) do -- use a generic for loop to step through each vehicle
if ( isVehicleOnGround ( theVehicle ) ) then -- if the vehicle is on the ground, announce it
outputChatBox ( getVehicleName ( theVehicle ) .. " is on the ground and made GOD-like" )
setVehicleDamageProof ( theVehicle, true )
else -- if the vehicle isn't on the ground, announce that it is in the air
outputChatBox ( getVehicleName ( theVehicle ) .. " is in the air and made GOD-like" )
setVehicleDamageProof ( theVehicle, true )
end
end
end
)
Any ideas what i am doing wrong? Many thanks in advance.