|
Junior Member
|

07-03-2018
, 10:36
Player bool
|
#1
|
Hi, I'm trying to find out something like how to set a bool for a specific player. I'm goint to show you my code to have a basic idea of what I want todo, also I know code is totally wrong. So please try to solve just this question. How could I define a "race_creator" for a player an there only can be 1 "race_creator"
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <prokreedz>
new bool:timer_started[32]
new Float:timer[32]
new bool:race_status = false
const race_players = 0
new bool:race_creator = false
new bool:race_winner = false
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 /checkmenu", "cmdMenu" );
RegisterHam(Ham_Use, "func_button", "hamUse");
register_clcmd("say /carrera" , "racecmd");
register_clcmd("say /ingresar", "joincmd");
}
//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(i, print_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(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(id, print_center, "Tiempo Total: %02d:%02d",min ,sec)
timer_started[id-1] = false
}
}
//BOTON STOP
public hamUse(ent, id) {
if(!(1 <= id <= get_maxplayers())) return HAM_IGNORED;
new szTarget[32];
pev(ent, pev_target, szTarget, 31);
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_additem(gMenu, "\wRace Players", "2")
menu_additem(gMenu, "\wRace Status", "3")
menu_additem(gMenu, "\wRace Creator", "4")
menu_display(id, gMenu, 0)
}
public handlerMenu(id, menu, item)
{
if ( item == MENU_EXIT )
{
menu_destroy(menu)
return PLUGIN_HANDLED;
}
switch(item)
{
case 0:
{
if(id,race_players >= 2){
startcmd(id)
timer_started[id] = false;
}
else{
client_print(id,print_chat,"No tienes acceso a este comando")
}
}
}
switch(item)
{
case 1:
{
client_print(id,print_chat,"Race Players = %d",race_players)
}
}
switch(item)
{
case 2:
{
if(id,race_creator == true){
client_print(id,print_chat,"Race Creator = True")
}
else{
client_print(id,print_chat,"Race Creator = False")
}
}
}
switch(item)
{
case 3:
{
if(id,race_status == true){
client_print(id,print_chat,"Race Status = True")
}
else{
client_print(id,print_chat,"Race Status = False")
}
}
}
}
//CARRERA
public racecmd(id){
race_status = true;
cmdMenu(id)
race_creator = true;
if(race_creator == true, race_status == true){
client_print(id,print_chat,"Ya hay una carrera en progreso")
}
}
//CORREDORES
public joincmd(id){
if(id,race_status == true)
race_players + 1
}
//DESCONEXION
public client_disconnect(id){
race_players - 1
}
So I know I have to fix a lot the structure of the plugin, but first I want to know that. Thanks!
Last edited by warps013; 07-03-2018 at 11:36.
|
|