[M]ister Posted March 28, 2013 Posted March 28, 2013 Olá pessoal, mais uma vez estou aqui para pedir a colaboração de vocês para me ajudarem neste problema. É o seguinte eu estava querendo criar um portão que se move-se quando algum jogador que esteja no team B.O.P.E se aproximasse, o script até pega, mais eu queria tirar os warnings que aparecem no console: WARNING: Base-BOPE/Gates.lua:5: Bad 'player' pointer @ 'getPlayerTeam' (1) WARNING: Base-BOPE/Gates.lua:6: Bad argument @ 'getTeamName' Obs: Aparece esta mensagem quando eu estou no team B.O.P.E e também quando eu não estou nesse team, mais o portão está se movendo como eu queria mesmo, só se move-se para quem esteja no team B.O.P.E local gate = createObject(980, 1548, -1627.3000488281, 15.10000038147, 0, 0, 90) local marker = createMarker(1547.6999511719, -1627.5, 12.10000038147, "cylinder", 8, 255, 255, 255, 0) function moveGate(source) local theTeam = getPlayerTeam(source) if getTeamName( theTeam ) == "B.O.P.E" then moveObject(gate, 2500, 1548, -1627.3000488281, 9.5) end end addEventHandler("onMarkerHit", marker, moveGate) function moveBack() moveObject(gate, 2500, 1548, -1627.3000488281, 15.10000038147) end addEventHandler("onMarkerLeave", marker, moveBack)
DNL291 Posted March 29, 2013 Posted March 29, 2013 Isso deve funcionar sem erros: local gate = createObject(980, 1548, -1627.3000488281, 15.10000038147, 0, 0, 90) local marker = createMarker(1547.6999511719, -1627.5, 12.10000038147, "cylinder", 8, 255, 255, 255, 0) function moveGate(hitPlayer) if getElementType(hitPlayer) == "player" then local theTeam = getPlayerTeam(hitPlayer) if theTeam and getTeamName(theTeam) == "B.O.P.E" then moveObject(gate, 2500, 1548, -1627.3000488281, 9.5) end end end addEventHandler("onMarkerHit", marker, moveGate) function moveBack(leavePlayer) if getElementType(leavePlayer) == "player" then local theTeam = getPlayerTeam(leavePlayer) if theTeam and getTeamName(theTeam) == "B.O.P.E" then moveObject(gate, 2500, 1548, -1627.3000488281, 15.10000038147) end end end addEventHandler("onMarkerLeave", marker, moveBack)
RaceXtreme Posted March 29, 2013 Posted March 29, 2013 local isGateOpen = false -- o portão está aberto? local gate = createObject(980, 1548, -1627.3, 15.1, 0, 0, 90) local marker = createMarker(1547.7, -1627.5, 12.1, "cylinder", 8, 255, 255, 255, 0) function moveGate(hitPlayer) if getElementType(hitPlayer) == "player" then -- Por isso devemos verificar se este elemento é o jogador, pois qualquer outro tipo de elemento causará erro nas funções relacionadas à time. local theTeam = getPlayerTeam(hitPlayer) if theTeam and getTeamName(theTeam) == "B.O.P.E" then if isGateOpen then moveObject(gate, 2500, 1548, -1627.3, 15.1) isGateOpen = false else moveObject(gate, 2500, 1548, -1627.3, 9.5) isGateOpen = true end end end end -- Quando você declara estes eventos, qualquer elemento (carro, pedestre, jogador) pode ativá-lo. addEventHandler("onMarkerHit", marker, moveGate) addEventHandler("onMarkerLeave", marker, moveGate) Neste ponto eu tentei reduzir o script excluindo uma função e adicionando uma variável.
[M]ister Posted March 29, 2013 Author Posted March 29, 2013 RaceXtreme obg, irei usar este seu código Isso deve funcionar sem erros: local gate = createObject(980, 1548, -1627.3000488281, 15.10000038147, 0, 0, 90) local marker = createMarker(1547.6999511719, -1627.5, 12.10000038147, "cylinder", 8, 255, 255, 255, 0) function moveGate(hitPlayer) if getElementType(hitPlayer) == "player" then local theTeam = getPlayerTeam(hitPlayer) if theTeam and getTeamName(theTeam) == "B.O.P.E" then moveObject(gate, 2500, 1548, -1627.3000488281, 9.5) end end end addEventHandler("onMarkerHit", marker, moveGate) function moveBack(leavePlayer) if getElementType(leavePlayer) == "player" then local theTeam = getPlayerTeam(leavePlayer) if theTeam and getTeamName(theTeam) == "B.O.P.E" then moveObject(gate, 2500, 1548, -1627.3000488281, 15.10000038147) end end end addEventHandler("onMarkerLeave", marker, moveBack) Danilo tem alguma forma de entrar em contato com você, email, skype ?
DNL291 Posted March 29, 2013 Posted March 29, 2013 Danilo tem alguma forma de entrar em contato com você, email, skype ? Skype: [EDITADO]
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