[Ajuda] Salvar o tempo ao sair do servidor
#1

Bom o meu problema й o seguinte o relogio estб funcionando certinho й tals mas acontece que quando o player sai do servidor e volta nгo salva o tempo por exemplo, ele entrou ai comeзou a contar 9:59... e ele saiu no 6:15 por exemplo ai quando ele volta o relogio volta pro 9:59 como arruma isso ?


Cуdigo:
pawn Код:
forward RelogioUP(playerid);
public RelogioUP(playerid)
{
new string[256];
if(segUP[playerid] == 0 && minUP[playerid] == 0)
{
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
format(file, sizeof(file), PASTA_CONTAS, aname);
if(PlayerInfo[playerid][pLogged] == 1)
{
if(AFK[playerid] == 0)
{
dini_IntSet(file, "Tempo", dini_Int(file, "Tempo")+1);
//====== [EXP] ======
if(dini_Int(file, "Tempo") >=1)
{
dini_IntSet(file, "EXP", dini_Int(file, "EXP")+1);
format(string, sizeof(string), "| UP | Vocк ganhou +1 de experiкncia! [ %d / 5 ]",dini_Int(file, "pExpe"));
PlayerPlaySound(playerid, 1133, 0, 0, 0);
SendClientMessage(playerid, 0x33AAFFFF, string);
dini_IntSet(file, "Tempo",0);
}
if(dini_Int(file, "EXP") >=5)
{
dini_IntSet(file, "Level", dini_Int(file, "Level")+1);
format(string, sizeof(string), "(INFO) Vocк juntou 5 de respeito, e ganhou +1 level. (%d) ",dini_Int(file, "pLevel"));
SendClientMessage(playerid, 0x75EA00AA, string);
PlayerPlaySound(playerid, 1057, 0, 0, 0);
dini_IntSet(file, "pExpe",0);
}
}
}
}
if(segUP[playerid] == 0)
{
if(minUP[playerid] == 0)
minUP[playerid] = 9;
segUP[playerid] = 59;
minUP[playerid] --;
}
format(string, sizeof(string), "UP: %02d:%02d", minUP[playerid], segUP[playerid]);
TextDrawSetString(UPRelogio[playerid], string);
segUP[playerid] --;
return 1;
}
Reply
#2

Pelo que eu entendi no seu script, as variбveis minUP[playerid] e segUP[playerid] sгo as responsбveis por armazenar, em respectiva ordem, minuto e segundo que aparecerб no relуgio. Vocк poderб usб-las para fazer seu sistema de salvamento. Assim, use dini_IntSet(file, "seg", segUP[playerid]);. Depois deverб carregar os dados salvos e aplicar para o relуgio comeзar a contar do tempo carregado nas variбveis determinadas. Eu nгo mexo com dini б muito tempo entгo nгo poderei lhe ajudar, atй porque isso й bбsico e como vocк pegou esse script de algum criador random, nгo entenderб ele, mas creio que vocк conseguirб.

Duvidas, poste.
Reply
#3

Eu coloquei e nгo salvo, e quando chega em 9:00 ele vai 9:-01 9:-02...
Reply
#4

Ajuda ? Alguem ?
Reply
#5

UP !
Reply
#6

Usa o tempo somente em segundos. 10 minutos sгo 600 segundos.

Diminua 1 segundo desse tempo total a cada 1 segundo quando o jogador estiver conectado.

Salve esses segundos no arquivo do player, e carregue sempre que precisar.

Se quiser mostrar o tempo em minutos:segundos em algum texto, faзa um algoritmo de relуgio

PHP код:
stock Relogio(_segs)
{
    
// Quantos minutos cabem nesses segundos
    
new min _segs 60;
    
// Quantos segundos sobram?
    
new seg _segs 60;
    new 
STR[7];
    
format(STR,7,"%2d:%2d");
    
    return 
STR;

Basta entгo chamar Relogio(segundos) quando precisar do tempo em texto.

PHP код:
printf("305 segundos й %s",Relogio(305)); 
Output

Код:
305 segundos й 05:05
Reply
#7

Mano o ъnico problema que tem nesse sistema e que ele nгo estб salvando o tempo quando o player sai do servidor.
Reply
#8

ProKillerpa eu coloco deste jeito ?

pawn Код:
if(segUP[playerid] == 0)
{
if(minUP[playerid] == 0)
dini_IntSet(file, "min", minUP[playerid]);
dini_IntSet(file, "seg", segUP[playerid]);
}
Reply
#9

Faзa do mйtodo do arakuta, nгo tem erro.

Eu encontrei um tempinho agora e refiz seu cуdigo totalmente, teste agora e veja se obterб sucesso.
Lembrando que, eu nгo testei e faz tanto tempo que nгo uso dini, mas acredito que esteja tudo ok.

PHP код:
forward RelogioUP(playerid);
new 
e_seg[MAX_PLAYERS];
public 
OnPlayerSpawn(playerid){
     new 
_direct[100], _name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid_nameMAX_PLAYER_NAME);
    
format(_directsizeof(_direct), PASTA_CONTAS_name);
    new var = 
dini_Int(_direct"Tempo");
    
TextDrawSetString(UPRelogio[playerid], ConvertSeg(var);
    
    
SetTimerEx("RelogioUP"1000true"i"playerid);
    return 
1;
}
public 
RelogioUP(playerid){
    
    new 
_direct[100], _name[MAX_PLAYER_NAME];
    
    
GetPlayerName(playerid_nameMAX_PLAYER_NAME);
    
    
format(_directsizeof(_direct), PASTA_CONTAS_name);
    
    
e_seg[playerid]++;
    
    if(
e_seg[playerid] >= 60){
        
dini_IntSet(file"EXP"dini_Int(file"EXP")+1);
        
format(stringsizeof(string), "| UP | Vocк ganhou +1 de experiкncia! [ %d / 5 ]",dini_Int(file"pExpe"));
        
PlayerPlaySound(playerid1133000);
        
SendClientMessage(playerid0x33AAFFFFstring);
    }
    if(
dini_Int(file"EXP") >=5){
        
dini_IntSet(file"Level"dini_Int(file"Level")+1);
        
format(stringsizeof(string), "(INFO) Vocк juntou 5 de respeito, e ganhou +1 level. (%d) ",dini_Int(file"pLevel"));
        
SendClientMessage(playerid0x75EA00AAstring);
        
PlayerPlaySound(playerid1057000);
    }
    return 
1;
}
stock ConvertSeg(r_seg){
    new 
e_min r_seg 60;
    new 
seg r_seg 60;
    
    new 
_var[10];
    
    
format(_var10"%2d:%2d"e_minseg);
    return 
_var;

Reply
#10

Mano eu coloquei o cуdigo do jeito que vocк postou e coloquei assim no OnPlayerSpawn http://prntscr.com/6tzyzu
e o resto do cуdigo assim, http://prntscr.com/6tzzcr mas deu esse erro http://prntscr.com/6tzyg2

Obrigado desde jб por essa grande ajuda que vocк jб deu.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)