kevincouto6 Posted January 10, 2020 Share Posted January 10, 2020 (edited) Primeiro esse é um script de PVP porem um PVP com times, quero mover o jogador por um momento apenas até ele morrer, quando ele morrer deve voltar ao team antigo, só que não esta funcionando e quando funciona, salva-se um team por cima do outro, isso faz com que os players não voltem a seu team antigo e sim para o time do ultimo player que usou o comando. OBS: não tem nada no lado "Client" OBS: Não demonstra nenhum erro no debugscript 3 Esse é o lado "Server" zonapvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 ) event_iniciado = 1 verificarOne = 0 local spawns = { { 5460.70264, -1825.30945, 10.97057 }, { 5454.74805, -1884.13953, 10.29621 }, { 5537.57373, -1887.13306, 11.04092 }, { 5545.14746, -1829.44873, 10.29401 }, { 5501.95557, -1861.66174, 10.29621 } } function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado +1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end else outputChatBox("The event is already activated", player, 255, 0, 0) end end addCommandHandler ( "eventStart", start_admin_event ) function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working One" ) redirecionar_team (thePlayer ) end end addEventHandler("onColShapeHit", zonapvp, entrar_na_zona) function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working Two" ) retirar_team (thePlayer ) end end addEventHandler("onColShapeLeave", zonapvp, sair_da_zona) function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) if getElementData(player,"SavedTeam") then setElementData(player,"inPVP",true) --outputDebugString (" inPVP ativado ") else --outputDebugString ("Esse playe foi pro pvp mas não tem team") verificarOne = verificarOne +1 end setElementPosition(player, unpack ( spawns [ teles ] )) end end function redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end end end function retirar_team (player) if getElementData(player,"SavedTeam") then local t = getElementData ( player, "SavedTeam" ) outputDebugString ("tem timer") setPlayerTeam ( player, getTeamFromName ( t ) ) setElementData(player,"SavedTeam",false) --outputDebugString ("tem time") end end addCommandHandler("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team (v) end end for i, team in ipairs(getElementsByType("team")) do destroyElement(team) end removeCommandHandler ( "pvp" ) event_iniciado = 1 else outputChatBox("Unable to stop because it was not started", player, 255, 0, 0) end end end) Edited January 10, 2020 by kevincouto6 Link to comment
Other Languages Moderators Lord Henry Posted January 10, 2020 Other Languages Moderators Share Posted January 10, 2020 (edited) Você deveria comentar cada linha do seu código para saber o que está fazendo em cada uma. Algumas partes parecem estar com falha na lógica. Sobre o jogador voltar ao time antigo, vc precisa salvar um elementData nele quando ele usa o comando pra ir pro PVP, salvando o time antigo nessa data e depois setando o jogador de volta no time salvo na data dele. Um salve pro Tommy, que está digitando logo abaixo. \/ Edited January 10, 2020 by Lord Henry 1 1 Link to comment
Tommy. Posted January 10, 2020 Share Posted January 10, 2020 (edited) Tem uns elementData que eu não entendi o motivo de sua existência, então deixei eles ai, kk. As linhas que acrescentei/ editei eu comentei com --/// explicando ela napvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 ) event_iniciado = 1 verificarOne = 0 local spawns = { { 5460.70264, -1825.30945, 10.97057 }, { 5454.74805, -1884.13953, 10.29621 }, { 5537.57373, -1887.13306, 11.04092 }, { 5545.14746, -1829.44873, 10.29401 }, { 5501.95557, -1861.66174, 10.29621 } } oldTeam = {} -- Tabela para salvar o Team antigo. function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado +1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end else outputChatBox("The event is already activated", player, 255, 0, 0) end end addCommandHandler ( "eventStart", start_admin_event ) function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working One" ) redirecionar_team (thePlayer ) end end addEventHandler("onColShapeHit", zonapvp, entrar_na_zona) function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working Two" ) retirar_team (thePlayer ) end end addEventHandler("onColShapeLeave", zonapvp, sair_da_zona) function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) if getElementData(player,"SavedTeam") then setElementData(player,"inPVP",true) else --outputDebugString ("Esse playe foi pro pvp mas não tem team") verificarOne = verificarOne +1 end setElementPosition(player, unpack ( spawns [ teles ] )) end end function redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then --/// Verifica se o player já estava em um Team oldTeam[thePlayer] = getTeamName(playerTeam) --/// Salva o Team na tabela oldTeam end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end end end function retirar_team (player) if getElementData(player,"SavedTeam") then if getTeamFromName(oldTeam[playerTeam]) then --/// Verifica se o Team antigo ainda existe setPlayerTeam(player, getTeamFromName(oldTeam[playerTeam])) --/// Seta o player no Team que está na tabela oldTeam end local t = getElementData ( player, "SavedTeam" ) setElementData(player,"SavedTeam",false) end end addCommandHandler("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team (v) end end for i, team in ipairs(getElementsByType("team")) do destroyElement(team) end removeCommandHandler ( "pvp" ) event_iniciado = 1 else outputChatBox("Unable to stop because it was not started", player, 255, 0, 0) end end end) EDIT: Não testei. Edited January 10, 2020 by Tommy. 1 1 Link to comment
kevincouto6 Posted January 11, 2020 Author Share Posted January 11, 2020 On 10/01/2020 at 10:51, Tommy. said: Tem uns elementData que eu não entendi o motivo de sua existência, então deixei eles ai, kk. As linhas que acrescentei/ editei eu comentei com --/// explicando ela napvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 ) event_iniciado = 1 verificarOne = 0 local spawns = { { 5460.70264, -1825.30945, 10.97057 }, { 5454.74805, -1884.13953, 10.29621 }, { 5537.57373, -1887.13306, 11.04092 }, { 5545.14746, -1829.44873, 10.29401 }, { 5501.95557, -1861.66174, 10.29621 } } oldTeam = {} -- Tabela para salvar o Team antigo. function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado +1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end else outputChatBox("The event is already activated", player, 255, 0, 0) end end addCommandHandler ( "eventStart", start_admin_event ) function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working One" ) redirecionar_team (thePlayer ) end end addEventHandler("onColShapeHit", zonapvp, entrar_na_zona) function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working Two" ) retirar_team (thePlayer ) end end addEventHandler("onColShapeLeave", zonapvp, sair_da_zona) function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) if getElementData(player,"SavedTeam") then setElementData(player,"inPVP",true) else --outputDebugString ("Esse playe foi pro pvp mas não tem team") verificarOne = verificarOne +1 end setElementPosition(player, unpack ( spawns [ teles ] )) end end function redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then --/// Verifica se o player já estava em um Team oldTeam[thePlayer] = getTeamName(playerTeam) --/// Salva o Team na tabela oldTeam end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end end end function retirar_team (player) if getElementData(player,"SavedTeam") then if getTeamFromName(oldTeam[playerTeam]) then --/// Verifica se o Team antigo ainda existe setPlayerTeam(player, getTeamFromName(oldTeam[playerTeam])) --/// Seta o player no Team que está na tabela oldTeam end local t = getElementData ( player, "SavedTeam" ) setElementData(player,"SavedTeam",false) end end addCommandHandler("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team (v) end end for i, team in ipairs(getElementsByType("team")) do destroyElement(team) end removeCommandHandler ( "pvp" ) event_iniciado = 1 else outputChatBox("Unable to stop because it was not started", player, 255, 0, 0) end end end) EDIT: Não testei. Line : 91 ( Bad Argument @ 'getTeamFromName' [expected string at argument 1, got nil] ) Quando fui testar apareceu esse erro tentei resolver mas não consegui "playerTeam = getPlayerTeam( thePlayer )" acho que o erro esta nesta parte onde salva o team do player Link to comment
Tommy. Posted January 11, 2020 Share Posted January 11, 2020 17 minutes ago, kevincouto6 said: Line : 91 ( Bad Argument @ 'getTeamFromName' [expected string at argument 1, got nil] ) Quando fui testar apareceu esse erro tentei resolver mas não consegui "playerTeam = getPlayerTeam( thePlayer )" acho que o erro esta nesta parte onde salva o team do player napvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 ) event_iniciado = 1 verificarOne = 0 local spawns = { { 5460.70264, -1825.30945, 10.97057 }, { 5454.74805, -1884.13953, 10.29621 }, { 5537.57373, -1887.13306, 11.04092 }, { 5545.14746, -1829.44873, 10.29401 }, { 5501.95557, -1861.66174, 10.29621 } } oldTeam = {} -- Tabela para salvar o Team antigo. function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado +1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end else outputChatBox("The event is already activated", player, 255, 0, 0) end end addCommandHandler ( "eventStart", start_admin_event ) function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working One" ) redirecionar_team (thePlayer ) end end addEventHandler("onColShapeHit", zonapvp, entrar_na_zona) function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working Two" ) retirar_team (thePlayer ) end end addEventHandler("onColShapeLeave", zonapvp, sair_da_zona) function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) if getElementData(player,"SavedTeam") then setElementData(player,"inPVP",true) else --outputDebugString ("Esse playe foi pro pvp mas não tem team") verificarOne = verificarOne +1 end setElementPosition(player, unpack ( spawns [ teles ] )) end end function redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then --/// Verifica se o player já estava em um Team oldTeam[thePlayer] = getTeamName(playerTeam) --/// Salva o Team na tabela oldTeam end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end end end function retirar_team (player) if getElementData(player,"SavedTeam") then if getTeamFromName(oldTeam[player]) then --/// Verifica se o Team antigo ainda existe setPlayerTeam(player, getTeamFromName(oldTeam[player])) --/// Seta o player no Team que está na tabela oldTeam end local t = getElementData ( player, "SavedTeam" ) setElementData(player,"SavedTeam",false) end end addCommandHandler("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team (v) end end for i, team in ipairs(getElementsByType("team")) do destroyElement(team) end removeCommandHandler ( "pvp" ) event_iniciado = 1 else outputChatBox("Unable to stop because it was not started", player, 255, 0, 0) end end end) Tenta isso. EDIT: Não testei. 1 Link to comment
Jonas^ Posted January 11, 2020 Share Posted January 11, 2020 Cara sempre procure deixar o código organizado e e indentado de forma correta, assim fica mais facil de você entender oque você esta fazendo, tem muitas coisas nesse código seu que daria pra fazer de uma forma bem melhor, código devidamente indentado: oldTeam = {} -- Tabela para salvar o Team antigo. napvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 ) event_iniciado = 1 verificarOne = 0 local spawns = { { 5460.70264, -1825.30945, 10.97057 }, { 5454.74805, -1884.13953, 10.29621 }, { 5537.57373, -1887.13306, 11.04092 }, { 5545.14746, -1829.44873, 10.29401 }, { 5501.95557, -1861.66174, 10.29621 } } function start_admin_event (player) if (event_iniciado == 1) then local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado +1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end else outputChatBox("The event is already activated", player, 255, 0, 0) end end addCommandHandler ( "eventStart", start_admin_event ) function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working One" ) redirecionar_team (thePlayer ) end end addEventHandler("onColShapeHit", zonapvp, entrar_na_zona) function sair_da_zona ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working Two" ) retirar_team (thePlayer ) end end addEventHandler("onColShapeLeave", zonapvp, sair_da_zona) function tele (player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) if getElementData(player,"SavedTeam") then setElementData(player,"inPVP",true) else --outputDebugString ("Esse playe foi pro pvp mas não tem team") verificarOne = verificarOne +1 end setElementPosition(player, unpack ( spawns [ teles ] )) end end function redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then --/// Verifica se o player já estava em um Team oldTeam[thePlayer] = getTeamName(playerTeam) --/// Salva o Team na tabela oldTeam end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end end end function retirar_team (player) if getElementData(player,"SavedTeam") then if getTeamFromName(oldTeam[player]) then --/// Verifica se o Team antigo ainda existe setPlayerTeam(player, getTeamFromName(oldTeam[player])) --/// Seta o player no Team que está na tabela oldTeam end local t = getElementData ( player, "SavedTeam" ) setElementData(player,"SavedTeam",false) end end addCommandHandler ("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team (v) end end for i, team in ipairs(getElementsByType("team")) do destroyElement(team) end removeCommandHandler ( "pvp" ) event_iniciado = 1 else outputChatBox("Unable to stop because it was not started", player, 255, 0, 0) end end end) 1 Link to comment
Tommy. Posted January 12, 2020 Share Posted January 12, 2020 (edited) @kevincouto6 Eu testei aqui e está funcionando só achei dois probleminha, vou enviar a correção logo a baixo, eu tirei algumas linhas desnecessárias. 1 hour ago, Jonas^ said: Cara sempre procure deixar o código organizado e e indentado de forma correta, assim fica mais facil de você entender oque você esta fazendo, tem muitas coisas nesse código seu que daria pra fazer de uma forma bem melhor, código devidamente indentado: oldTeam = {} -- Tabela para salvar o Team antigo.napvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 )event_iniciado = 1verificarOne = 0local spawns = { { 5460.70264, -1825.30945, 10.97057 }, { 5454.74805, -1884.13953, 10.29621 }, { 5537.57373, -1887.13306, 11.04092 }, { 5545.14746, -1829.44873, 10.29401 }, { 5501.95557, -1861.66174, 10.29621 }}function start_admin_event (player) if (event_iniciado == 1) then local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado +1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end else outputChatBox("The event is already activated", player, 255, 0, 0) end endaddCommandHandler ( "eventStart", start_admin_event )function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working One" ) redirecionar_team (thePlayer ) endendaddEventHandler("onColShapeHit", zonapvp, entrar_na_zona)function sair_da_zona ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then --outputChatBox( "Working Two" ) retirar_team (thePlayer ) endendaddEventHandler("onColShapeLeave", zonapvp, sair_da_zona)function tele (player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) if getElementData(player,"SavedTeam") then setElementData(player,"inPVP",true) else --outputDebugString ("Esse playe foi pro pvp mas não tem team") verificarOne = verificarOne +1 end setElementPosition(player, unpack ( spawns [ teles ] )) end endfunction redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then --/// Verifica se o player já estava em um Team oldTeam[thePlayer] = getTeamName(playerTeam) --/// Salva o Team na tabela oldTeam end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end endend function retirar_team (player) if getElementData(player,"SavedTeam") then if getTeamFromName(oldTeam[player]) then --/// Verifica se o Team antigo ainda existe setPlayerTeam(player, getTeamFromName(oldTeam[player])) --/// Seta o player no Team que está na tabela oldTeam end local t = getElementData ( player, "SavedTeam" ) setElementData(player,"SavedTeam",false) endendaddCommandHandler ("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team (v) end end for i, team in ipairs(getElementsByType("team")) do destroyElement(team) end removeCommandHandler ( "pvp" ) event_iniciado = 1 else outputChatBox("Unable to stop because it was not started", player, 255, 0, 0) end endend) @Jonas^ Eu não sei muito o motivo de quando eu colo o script do vscode aqui no forum a indentação fica toda zoada, ksks CORREÇÃO zonapvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 ) event_iniciado = 1 verificarOne = 0 local spawns = { {5460.70264, -1825.30945, 10.97057}, {5454.74805, -1884.13953, 10.29621}, {5537.57373, -1887.13306, 11.04092}, {5545.14746, -1829.44873, 10.29401}, {5501.95557, -1861.66174, 10.29621} } oldTeam = {} -- Tabela para salvar o Team antigo. function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user."..accName, aclGetGroup("Owner")) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado + 1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end end end addCommandHandler ( "eventStart", start_admin_event ) function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then redirecionar_team (thePlayer ) end end addEventHandler("onColShapeHit", zonapvp, entrar_na_zona) function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then retirar_team (thePlayer ) end end addEventHandler("onColShapeLeave", zonapvp, sair_da_zona) function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) verificarOne = verificarOne +1 setElementData(player,"inPVP",true) redirecionar_team(player) setElementPosition(player, unpack ( spawns [ teles ] )) end end function redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then --/// Verifica se o player já estava em um Team oldTeam[thePlayer] = getTeamName(playerTeam) --/// Salva o Team na tabela oldTeam end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end end end function retirar_team (player) if getTeamFromName(oldTeam[player]) then --/// Verifica se o Team antigo ainda existe setPlayerTeam(player, getTeamFromName(oldTeam[player])) --/// Seta o player no Team que está na tabela oldTeam end end addCommandHandler("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team(v) end end destroyElement(pvp_1) destroyElement(pvp_2) destroyElement(pvp_3) destroyElement(pvp_4) removeCommandHandler("pvp") event_iniciado = 1 end end end) EDIT: Testado. Edited January 12, 2020 by Tommy. 1 Link to comment
Jonas^ Posted January 12, 2020 Share Posted January 12, 2020 Aqui também acontece isso @Tommy., já tentei resolver mexendo em todas configurações mas nada resolveu, mas só com vscode, dai pra indentar uso o notepad++ 1 Link to comment
kevincouto6 Posted January 13, 2020 Author Share Posted January 13, 2020 On 11/01/2020 at 22:45, Tommy. said: @kevincouto6 Eu testei aqui e está funcionando só achei dois probleminha, vou enviar a correção logo a baixo, eu tirei algumas linhas desnecessárias. @Jonas^ Eu não sei muito o motivo de quando eu colo o script do vscode aqui no forum a indentação fica toda zoada, ksks CORREÇÃO zonapvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 )event_iniciado = 1verificarOne = 0local spawns = { {5460.70264, -1825.30945, 10.97057}, {5454.74805, -1884.13953, 10.29621}, {5537.57373, -1887.13306, 11.04092}, {5545.14746, -1829.44873, 10.29401}, {5501.95557, -1861.66174, 10.29621}}oldTeam = {} -- Tabela para salvar o Team antigo.function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user."..accName, aclGetGroup("Owner")) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado + 1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end end endaddCommandHandler ( "eventStart", start_admin_event )function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then redirecionar_team (thePlayer ) endendaddEventHandler("onColShapeHit", zonapvp, entrar_na_zona)function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then retirar_team (thePlayer ) endendaddEventHandler("onColShapeLeave", zonapvp, sair_da_zona)function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) verificarOne = verificarOne +1 setElementData(player,"inPVP",true) redirecionar_team(player) setElementPosition(player, unpack ( spawns [ teles ] )) end endfunction redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then --/// Verifica se o player já estava em um Team oldTeam[thePlayer] = getTeamName(playerTeam) --/// Salva o Team na tabela oldTeam end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end endend function retirar_team (player) if getTeamFromName(oldTeam[player]) then --/// Verifica se o Team antigo ainda existe setPlayerTeam(player, getTeamFromName(oldTeam[player])) --/// Seta o player no Team que está na tabela oldTeam endendaddCommandHandler("stop123",function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team(v) end end destroyElement(pvp_1) destroyElement(pvp_2) destroyElement(pvp_3) destroyElement(pvp_4) removeCommandHandler("pvp") event_iniciado = 1 end endend) EDIT: Testado. Eai parece estar funcionando tds funções mas não retorna o player ao team antigo, exemplo Kevin " team = Dragons" usei o commando /pvp agora estou no team "pvp_1" porem quando morro não retorno ao team Dragons Link to comment
Tommy. Posted January 13, 2020 Share Posted January 13, 2020 1 minute ago, kevincouto6 said: Eai parece estar funcionando tds funções mas não retorna o player ao team antigo, exemplo Kevin " team = Dragons" usei o commando /pvp agora estou no team "pvp_1" porem quando morro não retorno ao team Dragons os ColShape estão criado no lugar certo? quando o player morrer o onColShapeLeave será acionado e irá voltar pro team antigo. (Se por algum motivo o Team antigo foi deletado, ele não conseguirá voltar.) 1 Link to comment
Angelo Pereira Posted January 13, 2020 Share Posted January 13, 2020 (edited) O que ocorre ai, é o seguinte, está fazendo 2 salvamentos de team. 1ª É quando o jogador se teleporta, onde faz o primeiro salvamento correto se o player tiver in team. 2º Salvamento é quando o jogador depois de teleporta é o evento "onColShapeHit", onde faz o salvamento da team de PVP, ou seja, substituindo a já salva pelo teleporte /pvp. Espero que entenderam a minha explicação, por isso ele não retorna para a team antiga. Edited January 13, 2020 by Angelo Pereira 1 Link to comment
Angelo Pereira Posted January 13, 2020 Share Posted January 13, 2020 (edited) zonapvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 ) event_iniciado = 1 verificarOne = 0 oldTeam = {} -- Tabela para salvar o Team antigo. local spawns = { {5460.70264, -1825.30945, 10.97057}, {5454.74805, -1884.13953, 10.29621}, {5537.57373, -1887.13306, 11.04092}, {5545.14746, -1829.44873, 10.29401}, {5501.95557, -1861.66174, 10.29621} } function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user."..accName, aclGetGroup("Owner")) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado + 1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end end end addCommandHandler ( "eventStart", start_admin_event ) function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then redirecionar_team (thePlayer ) end end addEventHandler("onColShapeHit", zonapvp, entrar_na_zona) function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then retirar_team (thePlayer ) end end addEventHandler("onColShapeLeave", zonapvp, sair_da_zona) function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) verificarOne = verificarOne +1 setElementData(player,"inPVP",true) redirecionar_team(player) setElementPosition(player, unpack ( spawns [ teles ] )) end end function redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then if not oldTeam[thePlayer] then -- Adicionado oldTeam[thePlayer] = getTeamName(playerTeam) end -- Adicionado else -- Adicionado oldTeam[thePlayer] = true -- Adicionado end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end end end function retirar_team (player) if oldTeam[player] then if oldTeam[player] == true then setPlayerTeam(player, nil) oldTeam[player] = nil return end -- Adicionado local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end end end addCommandHandler("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team(v) end end destroyElement(pvp_1) destroyElement(pvp_2) destroyElement(pvp_3) destroyElement(pvp_4) removeCommandHandler("pvp") event_iniciado = 1 end end end) Edited January 13, 2020 by Angelo Pereira 1 Link to comment
Other Languages Moderators Lord Henry Posted January 13, 2020 Other Languages Moderators Share Posted January 13, 2020 (edited) @Tommy. @Jonas^ Sobre o problema com indentação zoada: Só configurar pra indentar com espaços em vez de tabulações. function name () -- TAB end function name () -- 4 spaces end Edited January 13, 2020 by Lord Henry 1 1 Link to comment
Tommy. Posted January 13, 2020 Share Posted January 13, 2020 1 hour ago, Angelo Pereira said: O que ocorre ai, é o seguinte, está fazendo 2 salvamentos de team. 1ª É quando o jogador se teleporta, onde faz o primeiro salvamento correto se o player tiver in team. 2º Salvamento é quando o jogador depois de teleporta é o evento "onColShapeHit", onde faz o salvamento da team de PVP, ou seja, substituindo a já salva pelo teleporte /pvp. Espero que entenderam a minha explicação, por isso ele não retorna para a team antiga. se for isso, retire toda a função "entrar_na_zona" e da uma testada. Link to comment
Angelo Pereira Posted January 13, 2020 Share Posted January 13, 2020 (edited) -- Adicionado (O que eu acrescentei nas linhas). 2 hours ago, Angelo Pereira said: zonapvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 )event_iniciado = 1verificarOne = 0oldTeam = {} -- Tabela para salvar o Team antigo.local spawns = { {5460.70264, -1825.30945, 10.97057}, {5454.74805, -1884.13953, 10.29621}, {5537.57373, -1887.13306, 11.04092}, {5545.14746, -1829.44873, 10.29401}, {5501.95557, -1861.66174, 10.29621}}function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user."..accName, aclGetGroup("Owner")) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado + 1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end end endaddCommandHandler ( "eventStart", start_admin_event )function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then redirecionar_team (thePlayer ) endendaddEventHandler("onColShapeHit", zonapvp, entrar_na_zona)function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then retirar_team (thePlayer ) endendaddEventHandler("onColShapeLeave", zonapvp, sair_da_zona)function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) verificarOne = verificarOne +1 setElementData(player,"inPVP",true) redirecionar_team(player) setElementPosition(player, unpack ( spawns [ teles ] )) end endfunction redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then if not oldTeam[thePlayer] then -- Adicionado oldTeam[thePlayer] = getTeamName(playerTeam) end -- Adicionado else -- Adicionado oldTeam[thePlayer] = true -- Adicionado end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end endend function retirar_team (player) if oldTeam[player] then if oldTeam[player] == true then setPlayerTeam(player, nil) oldTeam[player] = nil return end -- Adicionado local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end endendaddCommandHandler("stop123",function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team(v) end end destroyElement(pvp_1) destroyElement(pvp_2) destroyElement(pvp_3) destroyElement(pvp_4) removeCommandHandler("pvp") event_iniciado = 1 end endend) Aqui, eu fiz algumas alterações : (Particularmente, o kevin deverá coloca um tempo para cada player da teleporte a este local), enfim, as alterações foram : Linha 69. if playerTeam then if not oldTeam[thePlayer] then -- Adicionado oldTeam[thePlayer] = getTeamName(playerTeam) end -- Adicionado else -- Adicionado oldTeam[thePlayer] = true -- Adicionado end - Verificar se o player está na team(É o que você colocou), então vai verificar se o player já está na tabela, caso não, ira cria-lá, e caso o player não tenha team, vai seta-lo uma tabela como true. Linha 91. function retirar_team (player) if oldTeam[player] then if oldTeam[player] == true then setPlayerTeam(player, nil) oldTeam[player] = nil return end -- Adicionado local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end end end - Verificar se o player está na tabela, verifica se o player está como true (onde o jogador não tem team), caso for true, então remove da team e da tabela, caso o player tiver com team, verificará se essa team ainda existe, caso existir, então setara-lo a team e removerá da tabela. Observação[1]: Daria de fazer de uma forma diferente onde a questão relacionada na linha 73 (Remove-lá), e fazer o seguinte : function retirar_team (player) if oldTeam[player] then local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end else setPlayerTeam(player, nil) -- Adicionado end end Edited January 13, 2020 by Angelo Pereira Link to comment
kevincouto6 Posted January 13, 2020 Author Share Posted January 13, 2020 2 hours ago, Angelo Pereira said: -- Adicionado (O que eu acrescentei nas linhas). Aqui, eu fiz algumas alterações : (Particularmente, o kevin deverá coloca um tempo para cada player da teleporte a este local), enfim, as alterações foram : Linha 69. if playerTeam then if not oldTeam[thePlayer] then -- Adicionado oldTeam[thePlayer] = getTeamName(playerTeam) end -- Adicionadoelse -- AdicionadooldTeam[thePlayer] = true -- Adicionado end - Verificar se o player está na team(É o que você colocou), então vai verificar se o player já está na tabela, caso não, ira cria-lá, e caso o player não tenha team, vai seta-lo uma tabela como true. Linha 91. function retirar_team (player) if oldTeam[player] then if oldTeam[player] == true then setPlayerTeam(player, nil) oldTeam[player] = nil return end -- Adicionado local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end endend - Verificar se o player está na tabela, verifica se o player está como true (onde o jogador não tem team), caso for true, então remove da team e da tabela, caso o player tiver com team, verificará se essa team ainda existe, caso existir, então setara-lo a team e removerá da tabela. Observação[1]: Daria de fazer de uma forma diferente onde a questão relacionada na linha 73 (Remove-lá), e fazer o seguinte : ?">function retirar_team (player) if oldTeam[player] then local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end else setPlayerTeam(player, nil) -- Adicionado endend Eai esta funcionando normalmente só da esse erro quando o player não tem nenhum time , 88:Bad argument @'getTeamFromName' "Expected string at argument 1, got boolean" Acho que tem que criar uma verificação para que se o player não tiver um time remova o do time pvp, Pelo que entedi você fez o aki porem até os player sem time estão sendo add na tabela, assim ele é verificado da msm forma. function retirar_team (player) if oldTeam[player] then local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end else setPlayerTeam(player, nil) -- Adicionado end end Link to comment
Angelo Pereira Posted January 13, 2020 Share Posted January 13, 2020 (edited) 30 minutes ago, kevincouto6 said: Eai esta funcionando normalmente só da esse erro quando o player não tem nenhum time , 88:Bad argument @'getTeamFromName' "Expected string at argument 1, got boolean" Acho que tem que criar uma verificação para que se o player não tiver um time remova o do time pvp, Pelo que entedi você fez o aki porem até os player sem time estão sendo add na tabela, assim ele é verificado da msm forma. function retirar_team (player) if oldTeam[player] then local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end else setPlayerTeam(player, nil) -- Adicionado endend Na observação[1] eu falei, ou você remove, ou você comenta (--) a linha 73 : caso usar a 2º opção. 72. --else -- Adicionado 73. --oldTeam[thePlayer] = true -- Adicionado Sacou? Edited January 13, 2020 by Angelo Pereira Link to comment
kevincouto6 Posted January 13, 2020 Author Share Posted January 13, 2020 1 hour ago, Angelo Pereira said: Na observação[1] eu falei, ou você remove, ou você comenta (--) a linha 73 : caso usar a 2º opção. 72. --else -- Adicionado 73. --oldTeam[thePlayer] = true -- Adicionado Sacou? desculpe não consegui compreender oque devo complementar ? OBS: sou meio lerdo Link to comment
Angelo Pereira Posted January 13, 2020 Share Posted January 13, 2020 3 minutes ago, kevincouto6 said: desculpe não consegui compreender oque devo complementar ? OBS: sou meio lerdo Mostra como você fez, e suas alterações... 1 Link to comment
kevincouto6 Posted January 13, 2020 Author Share Posted January 13, 2020 Just now, Angelo Pereira said: Mostra como você fez, e suas alterações... zonapvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 ) event_iniciado = 1 verificarOne = 0 oldTeam = {} -- Tabela para salvar o Team antigo. local spawns = { {5460.70264, -1825.30945, 10.97057}, {5454.74805, -1884.13953, 10.29621}, {5537.57373, -1887.13306, 11.04092}, {5545.14746, -1829.44873, 10.29401}, {5501.95557, -1861.66174, 10.29621} } function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user."..accName, aclGetGroup("Owner")) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado + 1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end end end addCommandHandler ( "eventStart", start_admin_event ) function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then redirecionar_team (thePlayer ) end end addEventHandler("onColShapeHit", zonapvp, entrar_na_zona) function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then retirar_team (thePlayer ) end end addEventHandler("onColShapeLeave", zonapvp, sair_da_zona) function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) verificarOne = verificarOne +1 setElementData(player,"inPVP",true) redirecionar_team(player) setElementPosition(player, unpack ( spawns [ teles ] )) end end function redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then if not oldTeam[thePlayer] then -- Adicionado oldTeam[thePlayer] = getTeamName(playerTeam) end -- Adicionado else -- Adicionado oldTeam[thePlayer] = true -- Adicionado end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end end end function retirar_team (player) if oldTeam[player] == true then local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end else setPlayerTeam(player, nil) -- Adicionado end end addCommandHandler("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team(v) end end destroyElement(pvp_1) destroyElement(pvp_2) destroyElement(pvp_3) destroyElement(pvp_4) removeCommandHandler("pvp") event_iniciado = 1 end end end) Não esta mais funcionando para nenhum team ele não os retorna da esse erro para players que n tem time "" 88:Bad argument @'getTeamFromName' "Expected string at argument 1, got boolean" para players que tem time : não aparece erro mas tmb não o retorna para o time antigo Link to comment
Tommy. Posted January 13, 2020 Share Posted January 13, 2020 Você está errando em algo, eu testei o código e estava funcionando. 1 Link to comment
Angelo Pereira Posted January 13, 2020 Share Posted January 13, 2020 zonapvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 ) event_iniciado = 1 verificarOne = 0 oldTeam = {} -- Tabela para salvar o Team antigo. local spawns = { {5460.70264, -1825.30945, 10.97057}, {5454.74805, -1884.13953, 10.29621}, {5537.57373, -1887.13306, 11.04092}, {5545.14746, -1829.44873, 10.29401}, {5501.95557, -1861.66174, 10.29621} } function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user."..accName, aclGetGroup("Owner")) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado + 1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end end end addCommandHandler ( "eventStart", start_admin_event ) function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then redirecionar_team (thePlayer ) end end addEventHandler("onColShapeHit", zonapvp, entrar_na_zona) function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then retirar_team (thePlayer ) end end addEventHandler("onColShapeLeave", zonapvp, sair_da_zona) function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) verificarOne = verificarOne +1 setElementData(player,"inPVP",true) redirecionar_team(player) setElementPosition(player, unpack ( spawns [ teles ] )) end end function redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then if not oldTeam[thePlayer] then -- Adicionado oldTeam[thePlayer] = getTeamName(playerTeam) end -- Adicionado --else -- Adicionado -- oldTeam[thePlayer] = true -- Adicionado end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end end end function retirar_team (player) if oldTeam[player] then local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end else setPlayerTeam(player, nil) -- Adicionado end end addCommandHandler("stop123", function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team(v) end end destroyElement(pvp_1) destroyElement(pvp_2) destroyElement(pvp_3) destroyElement(pvp_4) removeCommandHandler("pvp") event_iniciado = 1 end end end) Você fez alterações no código, em vez, de remover a linha que eu tinha mencionado, teste isso 1 Link to comment
kevincouto6 Posted January 13, 2020 Author Share Posted January 13, 2020 (edited) 11 minutes ago, Angelo Pereira said: zonapvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 )event_iniciado = 1verificarOne = 0oldTeam = {} -- Tabela para salvar o Team antigo.local spawns = { {5460.70264, -1825.30945, 10.97057}, {5454.74805, -1884.13953, 10.29621}, {5537.57373, -1887.13306, 11.04092}, {5545.14746, -1829.44873, 10.29401}, {5501.95557, -1861.66174, 10.29621}}function start_admin_event (player) if event_iniciado == 1 then local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user."..accName, aclGetGroup("Owner")) then outputDebugString ("Evento Iniciado") event_iniciado = event_iniciado + 1 i = 0 pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0) pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0) pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255) pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0) addCommandHandler ( "pvp", tele ) end end endaddCommandHandler ( "eventStart", start_admin_event )function entrar_na_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then redirecionar_team (thePlayer ) endendaddEventHandler("onColShapeHit", zonapvp, entrar_na_zona)function sair_da_zona( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then retirar_team (thePlayer ) endendaddEventHandler("onColShapeLeave", zonapvp, sair_da_zona)function tele(player) local teles = math.random ( #spawns ) if ( teles ) then local isTeamPlayer = getPlayerTeam ( player ) verificarOne = verificarOne +1 setElementData(player,"inPVP",true) redirecionar_team(player) setElementPosition(player, unpack ( spawns [ teles ] )) end endfunction redirecionar_team (thePlayer) playerTeam = getPlayerTeam(thePlayer) i = i + 1 if i > 4 then i = 1 end if pvp_1 and pvp_2 and pvp_3 and pvp_4 then if playerTeam then if not oldTeam[thePlayer] then -- Adicionado oldTeam[thePlayer] = getTeamName(playerTeam) end -- Adicionado --else -- Adicionado -- oldTeam[thePlayer] = true -- Adicionado end if i == 1 then setPlayerTeam ( thePlayer, pvp_1 ) end if i == 2 then setPlayerTeam ( thePlayer, pvp_2 ) end if i == 3 then setPlayerTeam ( thePlayer, pvp_3 ) end if i == 4 then setPlayerTeam ( thePlayer, pvp_4 ) end endendfunction retirar_team (player) if oldTeam[player] then local team = getTeamFromName(oldTeam[player]) or false -- Adicionado if team then -- Adicionado setPlayerTeam(player, getTeamFromName(oldTeam[player])) oldTeam[player] = nil -- Adicionado end else setPlayerTeam(player, nil) -- Adicionado endendaddCommandHandler("stop123",function (player) local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then if event_iniciado >= 2 then for k , v in ipairs(getElementsByType("player")) do if getElementData(v,"inPVP") then retirar_team(v) end end destroyElement(pvp_1) destroyElement(pvp_2) destroyElement(pvp_3) destroyElement(pvp_4) removeCommandHandler("pvp") event_iniciado = 1 end endend) Você fez alterações no código, em vez, de remover a linha que eu tinha mencionado, teste isso Agora esta porem esta enviando todos para o time PVP - RED, os players que não tem team estão indo para PVP RED, quando morrem Edited January 13, 2020 by kevincouto6 Link to comment
Angelo Pereira Posted January 14, 2020 Share Posted January 14, 2020 (edited) Use a primeira opção que eu deixei, e depois aprimore, apenas adicionei linhas para não buga a team após dado o teleporte. Edited January 14, 2020 by Angelo Pereira 1 Link to comment
kevincouto6 Posted January 14, 2020 Author Share Posted January 14, 2020 Quero agradecer a todos pela ajuda, com ajuda de todos consegue finalizar o script e sobre o Thanks termino o resto amanha, ja deu meu limite hoje, obrigado mais uma vez .... Link to comment
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