Raised This Month: $ Target: $400
 0% 

Solved Player bool


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
warps013
Junior Member
Join Date: May 2018
Old 07-04-2018 , 12:39   Re: Player bool
Reply With Quote #8

So far, this is how code looks like
PHP Code:
#include <amxmodx> 
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <prokreedz>

new Float:timer[32

new 
bool:timer_started[32
new 
bool:race_creator [33]
new 
bool:race_player [33]
new 
bool:race_winner false
new bool:race_status false

new race_players 0


public plugin_init() { 
 
register_plugin("TEMP.kz""0.3""warps");
 
set_task(0.1,"timer_task",20000,"",0,"ab") ;
 
register_clcmd("go","startcmd"); 
 
register_clcmd("zz","stopcmd"); 
 
register_clcmd"say /run""cmdMenu" );
 
RegisterHam(Ham_Use"func_button""hamUse");
 
register_clcmd("say /carrera""racecmd")
 
register_clcmd("say /ingresar""joincmd")
 
register_clcmd("say /info""infocmd")
 
register_clcmd("ganadorcmd""winnercmd")
}
//NATIVES

//TAIMER TASK 
public timer_task() { 
 for(new 
i=1;i<=get_maxplayers();i++) { 
     if(
is_user_alive(i) && timer_started[i-1]) { 
         new 
Float:sec get_gametime() - timer[i-1], min 
         
if((sec 60.0) >= 1) { 
             
min floatround(sec 60.0,floatround_floor
             
sec -= min 60 
         

         
client_print(iprint_center "%d : %f",min ,sec)              
     } 



public 
startcmd(id) {
timer[id-1] = 0.0
 timer_started
[id-1] = true 
 timer
[id-1] = get_gametime() 

public 
stopcmd(id

    if(
race_status == true,timer_started[id-1])
    {
        new  
min 
        
new Float:sec get_gametime() - timer[id-1
        if((
sec 60.0) >= 1
        { 
            
min floatround(sec 60.0,floatround_floor
            
sec -= min 60 
        

        
client_print(idprint_center"Tiempo Total: %02d:%02d",min ,sec)
        
timer_started[id-1] = false
    
}
}
//BOTON STOP
public hamUse(entid) {
    if(!(
<= id <= get_maxplayers())) return HAM_IGNORED;
    
    new 
szTarget[32];
    
pev(entpev_targetszTarget31);
    
        if(
equal(szTarget"counter_off") || equal(szTarget"clockstopbutton") || equal(szTarget"clockstop") || equal(szTarget"stop_counter")) { 
        
stopcmd(id)
        }
        
timer_started[id] = false;
        return 
HAM_IGNORED;
    }
//MENU
public cmdMenu(id)
{
    new 
gMenu menu_create("\rRun Menu""handlerMenu")
    
menu_additem(gMenu"\wStart""1")                                           
    
menu_display(idgMenu0)
   }

public 
handlerMenu(idmenuitem)        
{
    if ( 
item == MENU_EXIT )   
    {
        
menu_destroy(menu)       
        return 
PLUGIN_HANDLED;    
    }
    switch(
item)    
    {
        case 
0:        
{
    if(
race_status == truerace_creator[id] == truerace_players >= 2){
        
startcmd(id)
    }
    else{
        
client_print(id,print_chat,"No es posible empezar la carrera en este momento")
    }
}
}
}
//CARRERA
public racecmd(id){
    if(
race_status == false){
        
race_status true
        race_creator
[id] = true
        race_winner 
false
        client_print
(id,print_chat,"Has creado una carrera")
    }
    else{
        
client_print(id,print_chat,"Una carrera ya ha sido creada")
        
race_creator [id] = false
    
}
}
//INFORMACION CREADOR Y JUGADORES
public infocmd(id){
    
client_print(id,print_chat,"Corredores inscriptos %d"race_players)
    if(
race_creator[id] == true){
        
client_print(id,print_chat,"Eres el creador de la carrera")
    }
    else{
        
client_print(id,print_chat,"No eres creador de la carrera")
    }
}
//CORREDORES
public joincmd(id){
    if(
race_status == true){
        
race_player[id] = true
        client_print
(id,print_chat,"Has ingresado a la carrarera")
        
race_players ++
    }
    else{
        
race_player[id] = false
        client_print
(id,print_chat,"No hay ninguna carrera activa")
    }
}
//GANADOR
public winnercmd(id){
}
//DESCONEXION
public client_disconnect(id){
    if(
race_player[id] == true){
        
race_player[id] = false
        race_players 
race_players 1
    
}
    else if(
race_creator[id] == true){
        
race_creator[id] = false
        race_status 
false
        client_print
(id,print_chat,"La carrera se ha disuelto")
    }

I'm going to take a nap now, later will work on race_winner and add a chatcolor module
warps013 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode