Contador De Tiempo
#1
Estrella 
TIEMPO JUGADO


Hola este es un mini aporte por que no he visto yo ninguno y andaba buscando para ponerlo y lo hice no se mucho pero esto anda perfecto hasta donde yo se

* Contador De Segundos
* Contador De Minutos
* Contador De Horas
* Contador De Dias
* Contador De Meses
* Contador De Años
* Guardado De Datos

Esto se puede meter en todos los modos.
Cualquier bug y o error diganme


Archivos adjuntos
.sma   Descargar AMXX / tiempo.sma (Tamaño: 3.28 KB / Descargas: 274)
“Quien te quiere en su vida, volverá a buscarte”
Qué frase más estúpida
Porque quien te quiere en su vida, jamás se iría.
Responder
#2
Buen aporte c:
Responder
#3
No se si sea la mejor manera, deberías agregar un identificador a los task
NO RESPONDO MP POR SOPORTE
Responder
#4
:ohgodwhy buen aporte

PD: situación sentimental: Sin internetOh god why

Sigue así Proud
* Ing. Informático * Mapper * Venezolano
Responder
#5
Muy bueno, Anque es un poco simple

PD: Buen aporte
Responder
#6
Podrías poner una variable (true / false) mediante un comando en say o consola para activar/desactivar la muestra del hud

Código PHP:
if (g_tiempo[id][3] == 30

no todos los meses tienen 30 días y va a terminar contando mal los meses/años


(28/07/2015, 09:32 PM)FloresMagon escribió: No se si sea la mejor manera, deberías agregar un identificador a los task

para qué identificador a los task?

No usa remove_task y si lo usara estaría bien que eliminara los 2 tasks que existen (que tienen el mismo id) en el plugin
Responder
#7
(28/07/2015, 10:21 PM)ErikMav94 escribió:
Código PHP:
if (g_tiempo[id][3] == 30

no todos los meses tienen 30 días y va a terminar contando mal los meses/años


(28/07/2015, 09:32 PM)FloresMagon escribió: No se si sea la mejor manera, deberías agregar un identificador a los task

para qué identificador a los task?

No usa remove_task y si lo usara estaría bien que eliminara los 2 tasks que existen (que tienen el mismo id) en el plugin
Ahora lo arreglo
“Quien te quiere en su vida, volverá a buscarte”
Qué frase más estúpida
Porque quien te quiere en su vida, jamás se iría.
Responder
#8
Prueba así...
Código PHP:
#include <amxmodx>
#include <adv_vault>

#define PLUGIN "Tiempo"
#define VERSION "1.0"
#define AUTHOR "HK-416"

#define TASK_CONTEO 6633

#define ID_CONTEO ( taskid - TASK_CONTEO )

#define TASK_HUD 6533

#define ID_HUD ( taskid - TASK_HUD )

new g_tiempo[33][6]
new 
g_vault

enum 
{
    
CAMPO_SEGUNDOS,
    
CAMPO_MINUTOS,
    
CAMPO_HORAS,
    
CAMPO_DIAS,
    
CAMPO_MESES,
    
CAMPO_ANIOS,
    
CAMPO_MAX
}
new 
g_campos[CAMPO_MAX]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
g_vault adv_vault_open("Tiempo"false)
    
g_campos[CAMPO_SEGUNDOS] = adv_vault_register_field(g_vault"SEGUNDOS")
    
g_campos[CAMPO_MINUTOS] = adv_vault_register_field(g_vault"MINUTOS")
    
g_campos[CAMPO_HORAS] = adv_vault_register_field(g_vault"HORAS")
    
g_campos[CAMPO_DIAS] = adv_vault_register_field(g_vault"DIAS")
    
g_campos[CAMPO_MESES] = adv_vault_register_field(g_vault"MESES")
    
g_campos[CAMPO_ANIOS] = adv_vault_register_field(g_vault"ANIOS")
    
adv_vault_init(g_vault)
}

public 
client_putinserver(id)
{
    
Tiempo(id)
    
set_task(0.1"Cuanto"id+TASK_HUD,_,_,"b")
    
Cargar(id)
}

public 
client_disconnect(id)
{
    
Guardar(id)
    
    
remove_task(id+ID_HUD);
    
remove_task(id+ID_CONTEO);
}
public 
Tiempo(taskid)
{
    
g_tiempo[ID_CONTEO][0]++
    
    if (
g_tiempo[ID_CONTEO][0] == 60)
    {
        
g_tiempo[ID_CONTEO][0] = 0
        g_tiempo
[ID_CONTEO][1]++
    }
    if (
g_tiempo[ID_CONTEO][1] == 60)
    {
        
g_tiempo[ID_CONTEO][0] = 0
        g_tiempo
[ID_CONTEO][1] = 0
        g_tiempo
[ID_CONTEO][2]++
    }
    if (
g_tiempo[ID_CONTEO][2] == 24)
    {
        
g_tiempo[ID_CONTEO][0] = 0
        g_tiempo
[ID_CONTEO][1] = 0
        g_tiempo
[ID_CONTEO][2] = 0
        g_tiempo
[ID_CONTEO][3]++
    }
    if (
g_tiempo[id][3] == 30)
    {
        
g_tiempo[ID_CONTEO][0] = 0
        g_tiempo
[ID_CONTEO][1] = 0
        g_tiempo
[ID_CONTEO][2] = 0
        g_tiempo
[ID_CONTEO][3] = 0
        g_tiempo
[ID_CONTEO][4]++
    }
    if (
g_tiempo[id][4] == 12)
    {
        
g_tiempo[ID_CONTEO][0] = 0
        g_tiempo
[ID_CONTEO][1] = 0
        g_tiempo
[ID_CONTEO][2] = 0
        g_tiempo
[ID_CONTEO][3] = 0
        g_tiempo
[ID_CONTEO][4] = 0
        g_tiempo
[ID_CONTEO][5]++
    }
    
set_task(1,0"Tiempo"id+ID_CONTEO)
}

public 
Cuanto(taskid)
{
    
set_hudmessage(25500, -1.00.01)
    
show_hudmessage(ID_HUD"Años : %d^nMeses : %d^nDias : %d^nHoras : %d^nMinutos : %d^nSegundos : %d"g_tiempo[ID_HUD][5], g_tiempo[ID_HUD][4], g_tiempo[ID_HUD][3], g_tiempo[ID_HUD][2], g_tiempo[ID_HUD][1], g_tiempo[ID_HUD][0])
}

public 
Guardar(id
{
    static 
name[32]
    
get_user_name(idnamesizeof name 1)
    
adv_vault_set_start(g_vault)
    
    
adv_vault_set_field(g_vaultg_campos[CAMPO_SEGUNDOS], g_tiempo[id][0])
    
adv_vault_set_field(g_vaultg_campos[CAMPO_MINUTOS], g_tiempo[id][1])
    
adv_vault_set_field(g_vaultg_campos[CAMPO_HORAS], g_tiempo[id][2])
    
adv_vault_set_field(g_vaultg_campos[CAMPO_DIAS], g_tiempo[id][3])
    
adv_vault_set_field(g_vaultg_campos[CAMPO_MESES], g_tiempo[id][4])
    
adv_vault_set_field(g_vaultg_campos[CAMPO_ANIOS], g_tiempo[id][5])
    
adv_vault_set_end(g_vault0name[id])
}

public 
Cargar(id
{
    static 
name[32]
    
get_user_name(idnamesizeof name 1)
    if(!
adv_vault_get_prepare(g_vault_name[id]))    return;
    
    
g_tiempo[id][0] = adv_vault_get_field(g_vaultg_campos[CAMPO_SEGUNDOS])
    
g_tiempo[id][1] = adv_vault_get_field(g_vaultg_campos[CAMPO_MINUTOS])
    
g_tiempo[id][2] = adv_vault_get_field(g_vaultg_campos[CAMPO_HORAS])
    
g_tiempo[id][3] = adv_vault_get_field(g_vaultg_campos[CAMPO_DIAS])
    
g_tiempo[id][4] = adv_vault_get_field(g_vaultg_campos[CAMPO_MESES])
    
g_tiempo[id][5] = adv_vault_get_field(g_vaultg_campos[CAMPO_ANIOS])

[Imagen: b_350_20_323957_202743_f19a15_111111.png]

Estudia siempre; el tiempo es oro, lo material se puede recuperar pero el tiempo no se puede recuperar.
(02/10/2016, 05:05 PM)meTaLiCroSS escribió: Siempre me gusta ayudar cuando alguien esta interesado realmente en ver que esta programando.
(08/08/2019, 05:32 PM)meTaLiCroSS escribió: grax x el dato cr4ck


Mis aportes

PLUGINS
MAPAS
Menú LANG [SF] Sistema de Frags
Say System (Admin Prefix)
Responder
#9
Una pregunta totopizza por que le pusiste todo eso?
Si anda perfecto.
No me compilo
“Quien te quiere en su vida, volverá a buscarte”
Qué frase más estúpida
Porque quien te quiere en su vida, jamás se iría.
Responder
#10
por nombre? really?

ponelo por STEAM ID
Hi Milashkasiya CrabCrab

Soy un #Panda.. Soy solo un tipo que parece #común pero soy todo lo contrario; alguien #atípico en esta sociedad actual

[Imagen: xl0jvd-5.png]
Link
Responder
#11
(29/07/2015, 12:50 AM)[R]ak escribió: por nombre? really?

ponelo por STEAM ID
Osea Que Guarde Los Datos Por Steam ID
“Quien te quiere en su vida, volverá a buscarte”
Qué frase más estúpida
Porque quien te quiere en su vida, jamás se iría.
Responder
#12
En vez de guardar tanto dato innecesario, es mejor guardar simplemente los segundos, y a partir de los segundos obtener el resto.

Toma esta libreria para que te guies mejor

https://forums.alliedmods.net/showthread.php?t=91915
Responder
#13
tambien puedes hacer algo como
Código PHP:
#include <amxmodx>

#define PLUGIN "Nuevo Plugin"
#define VERSION "1.0"
#define AUTHOR "Sugisaki"

#define NONE ""
#define SZPL "s"

new iTPlayed[33], iSConnected[33], bool:connected[33]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /check""fw_tiempo")
}
stock calculate_time(id)
{
    return 
floatround(get_gametime()) - iSConnected[id]
}
public 
fw_tiempo(id)
{
    new 
itime = ( iTPlayed[id] + calculate_time(id) )
    
    new 
segminuteshoursdays
    
    seg 
itime 60
    minutes 
=  itime 60
    hours 
minutes 60
    days 
hours 24
    
    
if(days)
    {
        
client_print(idprint_chat"Llevas %i dia%s, %i hora%s, %i minuto%s, %i segundo%s online"daysdays == NONE "s"hours 24,  hours ==NONE SZPLminutes %60minutes ==NONE SZPLsegseg ==NONE SZPL )
        return
    }
    else if (
hours)
    {
        
client_print(idprint_chat"Llevas %i hora%s, %i minuto%s, %i segundo%s online"hours 60,  hours ==NONE SZPLminutes %60minutes ==NONE SZPLsegseg ==NONE SZPL )
        return
    }
    else if (
minutes)
    {
        
client_print(idprint_chat"Llevas %i minuto%s, %i segundo%s online"minutes %60minutes ==NONE SZPLsegseg ==NONE SZPL )
        return
    }
    else if (
seg)
    {
        
client_print(idprint_chat"Llevas %i segundo%s online"segseg ==NONE SZPL )
        return
    }
    
    
}
public 
client_putinserver(id)
{
    
connected[id] = true
    iSConnected
[id] = floatround(get_gametime())
}
public 
client_disconnect(id)
{
    if(!
connected[id]) return
    
    
iTPlayed[id] += calculate_time(id)
    
    
connected[id] = false


en vez de un task y guardar todo eso, solo guardas el uptime del jugador ( como dijo metal ) y con una formula matematica ( bueno eso la dan en fisica ) determinas los dias, horas, minutos y segundos

Es un ejemplo, aunque funciona
Competitive/Face it Pick Up Game (PUG) servidor de prueba: 45.77.94.109:27016 Click para Entrar
[Imagen: b_350_20_5A6C3E_383F2D_D2E1B5_2E3226.png]

(14/08/2015, 10:15 PM)Sugisaki escribió: "El mundo es caotico, irracional e injusto. No tiene ningun significado"
Palabras que desde hace mucho tiempo he buscado para describir, ¿Que es el mundo?
Crab

Código PHP:
if(ayuda && free)
{
    exit();

Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)