Big Smoker Posted August 2, 2020 Posted August 2, 2020 Boa Noite, Como faço pra bloquear que 2 player nao entre no mesmo marker? Eu criei um maker na qual abre um painel quando esta dentro dele e quero que ele abra apenas para 1 pessoa. Se caso mais uma pessoa dente entrar no marker ele nao aparece o painel. Qual função devo colocar para que nao deixe que a 2 pessoa abra o painel ao mesmo tempo que a outra? OSB: O PAINEL APARECE QUANDO O JOGADOR ESTA DENTRO DE ALGUM VEICULO. garageCarCube = createMarker (-1903.9000244141,283.5,39.5, "cylinder", 4, 127, 127, 127, 100 ) addEventHandler ( "onClientMarkerHit", garageCarCube, function ( hitPlayer, matchingDimension ) if (hitPlayer == getLocalPlayer()) then local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then guiGridListClear(gridcor) guiSetVisible ( painelBlip, true ) showCursor ( true ) refreshColors() end end end)
Blaack Posted August 3, 2020 Posted August 3, 2020 4 hours ago, felipebaidoloko said: Boa Noite, Como faço pra bloquear que 2 player nao entre no mesmo marker? Eu criei um maker na qual abre um painel quando esta dentro dele e quero que ele abra apenas para 1 pessoa. Se caso mais uma pessoa dente entrar no marker ele nao aparece o painel. Qual função devo colocar para que nao deixe que a 2 pessoa abra o painel ao mesmo tempo que a outra? OSB: O PAINEL APARECE QUANDO O JOGADOR ESTA DENTRO DE ALGUM VEICULO. garageCarCube = createMarker (-1903.9000244141,283.5,39.5, "cylinder", 4, 127, 127, 127, 100 ) addEventHandler ( "onClientMarkerHit", garageCarCube, function ( hitPlayer, matchingDimension ) if (hitPlayer == getLocalPlayer()) then local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then guiGridListClear(gridcor) guiSetVisible ( painelBlip, true ) showCursor ( true ) refreshColors() end end end) Não sei se irá funcionar, but teste: garageCarCube = createMarker (-1903.9000244141,283.5,39.5, "cylinder", 4, 127, 127, 127, 100 ) usingPanel = false addEventHandler ( "onClientMarkerHit", garageCarCube, function ( hitPlayer, matchingDimension ) if (hitPlayer == getLocalPlayer()) then if usingPanel == true then return end local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then usingPanel = true -- Na função de fechar, não esqueca de setar como false !!! guiGridListClear(gridcor) guiSetVisible ( painelBlip, true ) showCursor ( true ) refreshColors() end end end)
Big Smoker Posted August 3, 2020 Author Posted August 3, 2020 9 hours ago, ~#BlackSCR said: Não sei se irá funcionar, but teste: garageCarCube = createMarker (-1903.9000244141,283.5,39.5, "cylinder", 4, 127, 127, 127, 100 ) usingPanel = false addEventHandler ( "onClientMarkerHit", garageCarCube, function ( hitPlayer, matchingDimension ) if (hitPlayer == getLocalPlayer()) then if usingPanel == true then return end local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then usingPanel = true -- Na função de fechar, não esqueca de setar como false !!! guiGridListClear(gridcor) guiSetVisible ( painelBlip, true ) showCursor ( true ) refreshColors() end end end) nao deu certo
Other Languages Moderators Lord Henry Posted August 3, 2020 Other Languages Moderators Posted August 3, 2020 (edited) Faça o marker server-side. Quando alguém entrar nele, verifique quantos elementos do tipo player estão dentro do marker usando a função útil GetElementsWithinMarker. Se existirem mais do que 1, nada acontece. Se existir só 1, abre o painel pra esse jogador usando um triggerClientEvent. Edited August 3, 2020 by Lord Henry
ber Posted August 4, 2020 Posted August 4, 2020 Uma outra alternativa também é usando o destroyElement. E quando o player fechar o painel você cria o marker novamente.
Other Languages Moderators Lord Henry Posted August 4, 2020 Other Languages Moderators Posted August 4, 2020 51 minutes ago, ber said: Uma outra alternativa também é usando o destroyElement. E quando o player fechar o painel você cria o marker novamente. É uma boa ideia, só tem que tomar cuidado pra verificar também caso o player saia do servidor sem fechar o painel.
DNL291 Posted August 4, 2020 Posted August 4, 2020 Como já mencionado, deve ser no lado server. Outra coisa a se fazer é não apenas verificar quantos estão na colshape da marker, em vez disso verificar se alguém está com a janela aberta. Isso pode ser feito com setElementData na marker. E terá que ser atualizado quando jogador fechar o painel ou sair. Resetar essa elementData no onResourceStop também evitaria possíveis bugs.
[M]ister Posted August 5, 2020 Posted August 5, 2020 Deve funcionar: -- SERVER local garageCarCube = createMarker ( -1903.9000244141, 283.5, 39.5, "cylinder", 4, 127, 127, 127, 100 ) addEventHandler ( "onMarkerHit", garageCarCube, function ( hitElement, matchingDimension ) if ( matchingDimension and getElementType ( hitElement ) == "player" ) then local theVehicle = getPedOccupiedVehicle ( hitElement ) if ( theVehicle ) then if ( hitElement == getVehicleController ( theVehicle ) ) then for _, vehicle in ipairs ( getElementsWithinColShape ( getElementColShape ( source ), "vehicle" ) ) do if ( vehicle ~= theVehicle and getVehicleController ( vehicle ) ) then return end end triggerClientEvent ( hitElement, "onGarageEnter", resourceRoot ) end end end end ) -- CLIENTE addEvent ( "onGarageEnter", true ) addEventHandler ( "onGarageEnter", resourceRoot, function () if ( not guiGetVisible( painelBlip ) ) then guiGridListClear ( gridcor ) guiSetVisible ( painelBlip, true ) showCursor ( true ) refreshColors () end end )
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now