[Ajuda] Sistema de Guerra ( Tempo )
#1

eu tenho um sistema de guerra, e tem uma semana eu tentando criar um tempo ( tipo relogio )..
Funciona assim, o kra digita /guerra, ai cria uma guerra: setando 120 minutos ( 2 hrs ) de guerra, entao eu peguei de um sistema de tempo de up, e modifiquei ele.. ta contando 120 certinho, e tem um comando de /finalizarguerra que o admin pode finalizar a guerra so que quando digita o tempo para ( trava ) ( coloquei um KillTimer ) ai quando digita /guerra o tempo continua a contar de onde parou.., queria saber como "Reseta" o tempo para 120 quando digitar /finalizarguerra.. Ajudem ai pfvv, desde jб agradeзo.
Reply
#2

Chama a funзгo de encerramento de guerra e zera a variбvel de tempo.
Reply
#3

Envia seu /guerra.
Reply
#4

Mostre o code!
Reply
#5

new RelogioGuerraG;

forward RelogioGuerra();
public RelogioGuerra()
{

if(TendoGuerra >= 1)
{
contagemsegundos++;
segundosrelogio--;
new string[50];
if(contagemsegundos >= 59)
{
contagemsegundos = 0;
contagemminutos ++;
segundosrelogio = 59;
}
format(string, 50,"~p~~h~TEMPO = %d~w~:~p~~h~%d",TEMPO_GUERRA-contagemminutos , segundosrelogio);
TextDrawSetString(ReloginhoGuerra,string);
TextDrawShowForAll(ReloginhoGuerra);
if(TEMPO_GUERRA+1 - contagemminutos == 0)
{
contagemminutos = 1;
}
}
return 1;
}

if(strcmp(cmd, "/guerra", true) == 0)
{
if(PlayerInfo[playerid][pJailed] != 0)
{
SendClientMessage(playerid,CINZA," Vocк nгo pode criar guerra na cadeia!");
return true;
}
if(TendoGuerra >= 1)
{
SendClientMessage(playerid, CINZA, " Jб estб tendo uma guerra!");
return true;
}
new Float,Float:y,Float:z;
if(PlayerInfo[playerid][pMembro] == 3 || PlayerInfo[playerid][pLider] == 3)// EXE
{
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s e o Exйrcito iniciaram uma Guerra. Evitem a бrea Verde!",playername);
SendClientMessageToAll(COLOR_EXE, string);
GetPlayerPos(playerid,x,y,z);
Territorio[MinX] = x-250;
Territorio[MinY] = y-250;
Territorio[MaxX] = x+250;
Territorio[MaxY] = y+250;
Territorio[exemortos] = 0;
Territorio[talmortos] = 0;
Territorio[almortos] = 0;
Territorio[GImortos] = 0;
GuerraMinX = x-250;
GuerraMinY = y-250;
GuerraMaxX = x+250;
GuerraMaxY = y+250;
GZGuerra = GangZoneCreate(x-250,y-250,x+250,y+250);
GangZoneShowForAll(GZGuerra,COLORGZ_EXE);
BPEInfo[playerid][InicioGuerra] = 1;
TendoGuerra = 1;
TempoGuerra = SetTimerEx("GuerraTerrorista", 7200000, 0, "i", playerid);
RelogioGuerraG = SetTimer("RelogioGuerra", 1000, 1); // << TEMPO
return true;
}
}
}

Nao ta completo o /guerra mas da pa entender, Ajuda ai pfv, se der pa passa o code agradeco muito
Reply
#6

pawn Код:
public RelogioGuerra()
{
    if(TendoGuerra >= 1)
    {
        contagemsegundos++;
        segundosrelogio--;
        new string[50];
        if(contagemsegundos >= 59)
        {
            contagemsegundos = 0;
            contagemminutos ++;
            segundosrelogio = 59;
        }
        format(string, 50,"~p~~h~TEMPO = %d~w~:~p~~h~%d",TEMPO_GUERRA-contagemminutos , segundosrelogio);
        TextDrawSetString(ReloginhoGuerra,string);
        TextDrawShowForAll(ReloginhoGuerra);
        if(TEMPO_GUERRA+1 - contagemminutos == 0)
        {
            contagemminutos = 1;
        }
        if(contagemminutos == 0 && segundosrelogio == 0)
        {
            // Funзгo pra encerrar guerra
        }
    }
    return 1;
}
Vк se funciona.
Reply
#7

Quote:

forward RelogioGuerra();
public RelogioGuerra()
{

if(TendoGuerra >= 1)
{
contagemsegundos++;
segundosrelogio--;
new string[50];
if(contagemsegundos >= 59)
{
contagemsegundos = 0;
contagemminutos ++;
segundosrelogio = 59;
}
format(string, 50,"~p~~h~TEMPO = %d~w~:~p~~h~%d",TEMPO_GUERRA-contagemminutos , segundosrelogio);
TextDrawSetString(ReloginhoGuerra,string);
TextDrawShowForAll(ReloginhoGuerra);
if(TEMPO_GUERRA+1 - contagemminutos == 0)
{
contagemminutos = 1;
}
if(contagemminutos == 0 && segundosrelogio == 0)
{
KillTimer(RelogioGuerraG);// Funзгo pra encerrar guerra
}
}
return 1;
}

Funciono nгo.. continua repetindo
Reply
#8

Quote:
Originally Posted by LosLipe
Посмотреть сообщение
Funciono nгo.. continua repetindo
Pode mostrar o comando /finalizarguerra?
Reply
#9

Quote:

if(strcmp(cmd, "/finalizarguerra", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(admtrampando[playerid] < 1 && PlayerInfo[playerid][pAdmin] != DONO)
{
SendClientMessage(playerid, COLOR_GRAD1, " Vocк nгo estб em modo Admin USE: /jogar");
return true;
}
if(TendoGuerra == 0)
{
SendClientMessage(playerid, COLOR_GRAD1, " Nгo estб tendo nenhuma Guerra para Finalizar!");
return true;
}
if(PlayerInfo[playerid][pAdmin] > 133
{
for(new i=0; i<MAX_PLAYERS; i++)
{
KillTimer(TempoGuerra);
KillTimer(RelogioGuerraG);
BPEInfo[playerid][InicioGuerra] = 0;
TendoGuerra = 0;
format(string, sizeof(string), "{191970}[GUERRA] {ffffff}A Guerra foi finalizada por um Admin!");
SendClientMessageToAll(COR_WHITE, string);
GangZoneHideForAll(GZGuerra);
GangZoneDestroy(GZGuerra);
TextDrawHideForPlayer(i, GuerraG[i]);
TextShow[i] = false;
return true;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Vocк nгo estб autorizado a usar este comando!");
return true;
}
}
return 1;
}

Ai.. ele estб parando o relogio normalmente, mas queria que zera-se o relogio porque quando digita /guerra ele continua de onde parou
Reply
#10

Tenta ae!

PHP код:
new RelogioGuerraG;
forward RelogioGuerra();
public 
RelogioGuerra()
{
    if(
TendoGuerra >= 1)
    {
        
contagemsegundos++;
        
segundosrelogio--;
        new 
string[50];
        if(
contagemsegundos >= 59)
        {
            
contagemsegundos 0;
            
contagemminutos ++;
            
segundosrelogio 59;
        }
        
format(string50,"~p~~h~TEMPO = %d~w~:~p~~h~%d",TEMPO_GUERRA-contagemminutos segundosrelogio);
        
TextDrawSetString(ReloginhoGuerra,string);
        
TextDrawShowForAll(ReloginhoGuerra);
        if(
TEMPO_GUERRA+contagemminutos == 0)
        {
            
contagemminutos 1;
        }
    }
    return 
1;
}
if(
strcmp(cmd"/guerra"true) == 0)
{
    if(
PlayerInfo[playerid][pJailed] != 0)
    {
        
SendClientMessage(playerid,CINZA," Vocк nгo pode criar guerra na cadeia!");
        return 
true;
    }
    if(
TendoGuerra >= 1)
    {
        
SendClientMessage(playeridCINZA" Jб estб tendo uma guerra!");
        return 
true;
    }
    new 
Float,Float:y,Float:z;
    if(
PlayerInfo[playerid][pMembro] == || PlayerInfo[playerid][pLider] == 3)// EXE
    
{
        
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);
        
format(stringsizeof(string), "%s e o Exйrcito iniciaram uma Guerra. Evitem a бrea Verde!",playername);
        
SendClientMessageToAll(COLOR_EXEstring);
        
GetPlayerPos(playerid,x,y,z);
        
Territorio[MinX] = x-250;
        
Territorio[MinY] = y-250;
        
Territorio[MaxX] = x+250;
        
Territorio[MaxY] = y+250;
        
Territorio[exemortos] = 0;
        
Territorio[talmortos] = 0;
        
Territorio[almortos] = 0;
        
Territorio[GImortos] = 0;
        
GuerraMinX x-250;
        
GuerraMinY y-250;
        
GuerraMaxX x+250;
        
GuerraMaxY y+250;
        
GZGuerra GangZoneCreate(x-250,y-250,x+250,y+250);
        
GangZoneShowForAll(GZGuerra,COLORGZ_EXE);
        
BPEInfo[playerid][InicioGuerra] = 1;
        
TendoGuerra 1;
        
TempoGuerra SetTimerEx("GuerraTerrorista"72000000"i"playerid);
        
RelogioGuerraG SetTimer("RelogioGuerra"10001); // << TEMPO
        
return 1;
    }
}
if(
strcmp(cmd"/finalizarguerra"true) == 0)
{
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playeridCOLOR_GRAD1" Vocк nгo Conectado!");
    if(
admtrampando[playerid] < && PlayerInfo[playerid][pAdmin] != DONO)
    {
        
SendClientMessage(playeridCOLOR_GRAD1" Vocк nгo estб em modo Admin USE: /jogar");
        return 
true;
    }
    if(
TendoGuerra == 0)
    {
        
SendClientMessage(playeridCOLOR_GRAD1" Nгo estб tendo nenhuma Guerra para Finalizar!");
        return 
1;
    }
    if(
PlayerInfo[playerid][pAdmin] > 133
    
{
        for (new 
iMAX_PLAYERSi++)
        {
            
KillTimer(TempoGuerra);
            
KillTimer(RelogioGuerraG);
            
BPEInfo[playerid][InicioGuerra] = 0;
            
TendoGuerra 0;
            
GangZoneHideForAll(GZGuerra);
            
GangZoneDestroy(GZGuerra);
            
TextDrawHideForPlayer(iGuerraG[i]);
            
TextShow[i] = false;
            
format(stringsizeof(string), "{191970}[GUERRA] {ffffff}A Guerra foi finalizada por um Admin!");
            
SendClientMessageToAll(COR_WHITEstring);
            return 
1;
        }
    }
    else
        
SendClientMessage(playeridCOLOR_GRAD1" Vocк nгo estб autorizado a usar este comando!");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)