Mahlzeit zusammen. Ich will das sich diese Schranken dann öffnen, wenn man in dem dementsprechenden ColShape steht und auf das dem entsprechnende Touchpad klickt.
Jedoch funktioniert das nicht so wie ich das will. Wenn ich auf ein x beliebiges touchpad klicke öffnet sich immer nur die selbe schranke...
Lua
local TouchpadSchranke2 = createObject ( 2886, -2055.8000488281, 312.89999389648, 35.700000762939, 0, 0, 270 )
local NoobspawnSchranke1 = createObject ( 968, -2055.3999023438, 310.29998779297, 35, 0, 90, 180 )
local NoobspawnSchranke1_status = false
local NoobspawnSchranke1_moving = false
local NoobspawnSchranke1Col = createColSphere ( -2058.8999023438, 313.79998779297, 34.200000762939, 6 )
local NoobspawnSchranke1zutimer = nil
local TouchpadSchranke1 = createObject ( 2886, -2045.5999755859, 307.60000610352, 35.700000762939, 0, 0, 90 )
local NoobspawnSchranke2 = createObject ( 968, -2046.099609375, 310.2998046875, 35, 0, 90, 0 )
local NoobspawnSchranke2_status = false
local NoobspawnSchranke2_moving = false
local NoobspawnSchranke2Col = createColSphere ( -2042.4000244141, 307.39999389648, 34.200000762939, 6 )
local NoobspawnSchranke2zutimer = nil
local function lassSchranke1AutomatischZuGehen ( )
if #getElementsWithinColShape ( schranke2Col, "player" ) == 0 then
moveObject ( NoobspawnSchranke1, 2000, -2055.3999023438, 310.29998779297, 35, 0, 90, 0 )
outputChatBox ( "rein - zu", player )
setTimer ( function () NoobspawnSchranke1_moving = false end, 2000, 1 )
NoobspawnSchranke1_status = false
NoobspawnSchranke1_moving = true
else
NoobspawnSchranke1zutimer = setTimer ( lassSchranke1AutomatischZuGehen, 5000, 1 )
end
end
function NoobspawnSchranke1_func(player) -- rein
--if dim then
--local player = getElementType ( player ) == "player" and player or getElementType ( player ) == "vehicle" and getVehicleController ( player ) or false
--if player then
if not NoobspawnSchranke1_status and not NoobspawnSchranke1_moving then
moveObject ( NoobspawnSchranke1, 2000, -2055.3999023438, 310.29998779297, 35, 0, -90, 0 )
outputChatBox ( "rein - auf", player )
NoobspawnSchranke1_status = true
NoobspawnSchranke1_moving = true
setTimer ( function () NoobspawnSchranke1_moving = false end, 2000, 1 )
NoobspawnSchranke1zutimer = setTimer ( lassSchranke1AutomatischZuGehen, 5000, 1 )
elseif isTimer ( NoobspawnSchranke1zutimer ) then
killTimer ( NoobspawnSchranke1zutimer )
NoobspawnSchranke1zutimer = setTimer ( lassSchranke1AutomatischZuGehen, 5000, 1 )
end
--end
--end
end
addEvent ( "activate_Schranke1", true )
addEventHandler ( "activate_Schranke1", getRootElement(), NoobspawnSchranke1_func )
local function lassSchranke2AutomatischZuGehen ( )
if #getElementsWithinColShape ( schranke2Col, "player" ) == 0 then
moveObject ( NoobspawnSchranke2, 2000, -2055.3999023438, 310.29998779297, 35, 0, 90, 0 )
outputChatBox ( "raus - zu", player )
setTimer ( function () NoobspawnSchranke2_moving = false end, 2000, 1 )
NoobspawnSchranke2_status = false
NoobspawnSchranke2_moving = true
else
NoobspawnSchranke2zutimer = setTimer ( lassSchranke2AutomatischZuGehen, 5000, 1 )
end
end
function NoobspawnSchranke2_func(player) -- raus
--if dim then
--local player = getElementType ( player ) == "player" and player or getElementType ( player ) == "vehicle" and getVehicleController ( player ) or false
--if player then
if not NoobspawnSchranke2_status and not NoobspawnSchranke2_moving then
moveObject ( NoobspawnSchranke2, 2000, -2055.3999023438, 310.29998779297, 35, 0, -90, 0 )
outputChatBox ( "raus - auf", player )
NoobspawnSchranke2_status = true
NoobspawnSchranke2_moving = true
setTimer ( function () NoobspawnSchranke2_moving = false end, 2000, 1 )
NoobspawnSchranke2zutimer = setTimer ( lassSchranke2AutomatischZuGehen, 5000, 1 )
elseif isTimer ( NoobspawnSchranke2zutimer ) then
killTimer ( NoobspawnSchranke2zutimer )
NoobspawnSchranke2zutimer = setTimer ( lassSchranke2AutomatischZuGehen, 5000, 1 )
end
--end
--end
end
addEvent ( "activate_Schranke2", true )
addEventHandler ( "activate_Schranke2", getRootElement(), NoobspawnSchranke1_func )
addEventHandler ( "onColShapeHit", NoobspawnSchranke1Col, function ( player, dim )
if dim then
local player = getElementType ( player ) == "player" and player or getElementType ( player ) == "vehicle" and getVehicleController ( player ) or false
if player then
outputChatBox ( "Klicke auf die Schaltflaeche, um ein Parkticket zu ziehen! (200$)", player, 125, 125, 0 )
--triggerClientEvent ( player, "Schranke_gui", getRootElement() )
end
end
end )
addEventHandler ( "onColShapeHit", NoobspawnSchranke2Col, function ( player, dim )
if dim then
local player = getElementType ( player ) == "player" and player or getElementType ( player ) == "vehicle" and getVehicleController ( player ) or false
if player then
--if parkticketentwertet then
outputChatBox ( "Klicke auf die Schaltflaeche, um dein Parkticket abzugeben!", player, 125, 125, 0 )
--triggerClientEvent ( player, "infobox_start", getRootElement(), "Auf\nWiedersehen", 5000, 0, 125, 0 )
--else
--triggerClientEvent ( player, "infobox_start", getRootElement(), "Parkticket\nist nicht\nentwertet", 5000, 125, 0, 0 )
--end
end
end
end )
function elementClicked( mouseButton, buttonState, clickedElement, x, y, z )
if mouseButton == "left" and buttonState == "down" then
local model = getElementModel( clickedElement )
--local Schranke1 = getElementType( clickedElement )
--local Schranke2 = getElementType( clickedElement )
if model == 2886 then
if Schranke1 then
if getElementData ( player, "money" ) >= 200 then
NoobspawnSchranke1_func()
setElementData ( player, "money", ( getElementData ( player, "money" ) -200 ))
else
triggerClientEvent ( player, "infobox_start", getRootElement(), "Du hast nicht\ngenug Geld", 5000, 125, 0, 0 )
end
elseif Schranke2 then
--if getElementData ( player, "money" ) >= 200 then
NoobspawnSchranke2_func()
--setElementData ( player, "money", ( getElementData ( player, "money" ) -200 ))
--else
--triggerClientEvent ( player, "infobox_start", getRootElement(), "Du hast nicht\ngenug Geld", 5000, 125, 0, 0 )
--end
end
end
end
addEventHandler( "onPlayerClick", getRootElement(), elementClicked )
Alles anzeigen