OrbTanT Posted December 6, 2016 Share Posted December 6, 2016 Personal, script is working well, only problem is when the two gangs meet in the same territory, it is repeated several times as a message because of the timer, already trying in several ways to run only once. Repeat this several times because of the timer: if ( isOwnerInTurf and isGangInTurf ) then exports.GWgang:outputGangMessage ( "O ataque no territorio "..turfLocs[id].name.." está pausado enquanto as duas gangs estiverem no territorio! Elimine a gang inimiga!", turfLocs[id].attackers, 255, 255, 0) exports.GWgang:outputGangMessage ( "O ataque no territorio "..turfLocs[id].name.." está pausado enquanto as duas gangs estiverem no territorio! Elimine a gang inimiga!", turfLocs[id].owner, 255, 255, 0) setTimer ( function ( ) for id, data in pairs ( turfLocs ) do if ( data.attackers ) then local players = { attackers = { }, owners = { } } local isGangInTurf = false local isOwnerInTurf = false for i, v in pairs ( getElementsWithinColShape ( data.col, "player" ) ) do local g = exports.GWgang:getPlayerGang ( v ) if ( g == data.attackers ) then isGangInTurf = true table.insert ( players.attackers, v ) elseif ( g == data.owner ) then isOwnerInTurf = true table.insert ( players.owners, v ) end end if ( isOwnerInTurf and isGangInTurf ) then exports.GWgang:outputGangMessage ( "O ataque no territorio "..turfLocs[id].name.." está pausado enquanto as duas gangs estiverem no territorio! Elimine a gang inimiga!", turfLocs[id].attackers, 255, 255, 0) exports.GWgang:outputGangMessage ( "O ataque no territorio "..turfLocs[id].name.." está pausado enquanto as duas gangs estiverem no territorio! Elimine a gang inimiga!", turfLocs[id].owner, 255, 255, 0) else -- ADICONAR PONTOS NO ATAQUE if ( isGangInTurf ) then -- PREPARAR A GUERRA if ( turfLocs[id].attackProg == 0 ) then turfLocs[id].prepProg = data.prepProg + 2 if ( turfLocs[id].prepProg >= 100 ) then turfLocs[id].prepProg = 0 turfLocs[id].attackProg = 1 beginTurfWarOnTurf ( id ) end -- ATAQUE GUERRA else turfLocs[id].attackProg = turfLocs[id].attackProg + 1 if ( turfLocs[id].attackProg == 100 ) then exports.GWgang:outputGangMessage ( "Sua gang dominou o territorio "..turfLocs[id].name.." da gang "..turfLocs[id].owner.."!", turfLocs[id].attackers, 0, 255, 0) exports.GWgang:outputGangMessage ( "Sua gang perdeu o territorio "..turfLocs[id].name.." para a gang "..turfLocs[id].attackers.."!.", turfLocs[id].owner, 255, 0, 0) outputChatBox("[TERRITORIOS] A gang "..turfLocs[id].attackers.." dominou o territorio "..turfLocs[id].name.." da gang "..turfLocs[id].owner.."!", root, 255, 100, 100 ) setTurfOwner ( id, turfLocs[id].attackers ) end end -- TIRAR PONTOS DA GANG ATACANTE else -- PREPARANDO ATAQUE if ( turfLocs[id].attackProg == 0 ) then turfLocs[id].prepProg = data.prepProg - 2 if ( turfLocs[id].prepProg <= 0 ) then exports.GWgang:outputGangMessage ( "Sua gang falhou em atacar o territorio "..turfLocs[id].name.." da gang "..turfLocs[id].owner.."!", turfLocs[id].attackers, 255, 0, 0 ) exports.GWgang:outputGangMessage ( "Sua gang defendeu o territorio "..turfLocs[id].name.."!", turfLocs[id].owner..", da gang "..turfLocs[id].attackers..", quando está quase iniciando o ataque", 0, 255, 0 ) setTurfOwner ( id, turfLocs[id].owner ) end -- ATACANDO GUERRA else turfLocs[id].attackProg = data.attackProg - 1 if ( turfLocs[id].attackProg <= 0 ) then exports.GWgang:outputGangMessage ( "Sua gang falhou em dominar o territorio "..turfLocs[id].name.." da gang "..turfLocs[id].owner.."!", turfLocs[id].attackers, 255, 0, 0 ) exports.GWgang:outputGangMessage ( "Sua gang defendeu o territorio "..turfLocs[id].name.." da gang "..turfLocs[id].attackers.."!", turfLocs[id].owner, 0, 255, 0 ) outputChatBox("[TERRITORIOS] A gang "..turfLocs[id].owner.." defendeu o territorio "..turfLocs[id].name.." da gang "..turfLocs[id].attackers.."!", root, 255, 100, 100 ) setTurfOwner ( id, turfLocs[id].owner ) end end end end for i, v in pairs ( players ) do for k, p in pairs ( v ) do triggerClientEvent ( p, "SAGWTurfs:upadateClientInfo", p, turfLocs [ id ] ) end end end end end, 800, 0 ) addEvent ( "SAGWTurfs:onTurfProgressChange", true ) Link to comment
ViRuZGamiing Posted December 7, 2016 Share Posted December 7, 2016 give the timer a name and kill it, killTimer() Link to comment
OrbTanT Posted December 7, 2016 Author Share Posted December 7, 2016 I can not use a killTimer, because it uses the timer to check if the players are in the territory or not. Link to comment
ViRuZGamiing Posted December 7, 2016 Share Posted December 7, 2016 2 hours ago, Shinigami said: I can not use a killTimer, because it uses the timer to check if the players are in the territory or not. how about giving it a name and checking isTimer() before creating? local timer if not isTimer(timer) then timer = setTimer(...) end 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