Da ich erst Angefangen habe zu Scripten hab ich ein paar dinge zum Testen aus dem Wiki entnommen doch es erschein folgende Fehler
Zitatattempt to call global 'areTrafficLightsLocked' (a nil value)
attempt to call global 'createColCube' (nil value)
Script:
Lua
function toggleTrafficLights()
if areTrafficLightsLocked() then
setTrafficLightsLocked(false)
outputChatBox("Traffic Lights unlocked",source)
else
setTrafficLightsLocked(true)
outputChatBox("Traffic Lights locked",source)
end
end
addCommandHandler("toggletrafficlights",toggleTrafficLights)
------------------------------------ GARAGES ------------------------------
GARAGE_ID = 19
-- create a collision shape and attach event handlers to it when the resource starts
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),
function (resource)
local garageCube = createColCube(1337, 194, 28, 6, 10, 4)
addEventHandler("onColShapeHit", garageCube, onGarageCubeHit)
addEventHandler("onColShapeLeave", garageCube, onGarageCubeLeave)
end)
-- open the door when someone enters the garage's collision shape
function onGarageCubeHit(hitElement, matchingDimension)
if (getElementType(hitElement) == "player") then
-- check to make sure the door is closed
if (not isGarageOpen(GARAGE_ID)) then
-- open the door
setGarageOpen(GARAGE_ID, true)
end
end
end
-- close the door when someone leaves the garage's collision shape
function onGarageCubeLeave(leaveElement, matchingDimension)
if (getElementType(leaveElement) == "player") then
-- check to make sure the door is open
if (isGarageOpen(GARAGE_ID)) then
-- close the door
setGarageOpen(GARAGE_ID, false)
end
end
end
Alles anzeigen
Wäre sehr nett wenn mir jemand helfen könnte
EDIT:
Jetzt bekomm ich auch hier ein Fehler:
attempt to call global 'getTrafficLightState' (a nil value)
Lua
function handleTrafficLightsOutOfOrder()
-- See if the lights are currently off
local lightsOff = getTrafficLightState() == 9
if lightsOff then
-- If they're off, turn them on
setTrafficLightState(6)
else
-- If they're on, turn them off
setTrafficLightState(9)
end
end
-- Repeat it every half a second
setTimer(handleTrafficLightsOutOfOrder,500,0)
Alles anzeigen