if(strcmp(cmdtext, "/sniper", true) == 0)
{
SetPlayerPos(playerid,-1396.3701,1247.2380,1042.2610);
return 1;
}
if(IsPlayerConnected(i))
forward Users();
public Users()
{
new strings[20];
format(strings, 20, "/sniper: %d ",Connectingpeople());
TextDrawSetString(Usuarios, strings);
TextDrawShowForAll(Usuarios);
return 1;
}
stock Connectingpeople()
{
new OnLine;
for(new i, g = GetMaxPlayers(); i < g; i++)
OnLine++;
return OnLine;
}
// globales
new sniper;
new en_sniper[MAX_PLAYERS];
if(strcmp(cmdtext, "/sniper", true) == 0)
{
if(!en_sniper[playerid])
sniper++,
en_sniper[playerid] = 1,
SetPlayerPos(playerid,-1396.3701,1247.2380,1042.2610),
SendClientMessage(playerid,-1,"Llegaste a sniper");
else
SendClientMessage(playerid,-1,"Ya estas dentro de sniper");
return 1;
}
forward Users();
public Users()
{
new strings[20];
format(strings, 20, "/sniper: %d ",sniper);
TextDrawSetString(Usuarios, strings);
TextDrawShowForAll(Usuarios);
return 1;
}
Para quй dos variables? no digo que haga la diferencia tener una mбs pero una podrнa ser innecesaria en tu cуdigo jotajeta. Nada mбs dos mйtodos:
Por un bucle Crear una funciуn que obtenga los jugadores conectados que tengan en positivo por ejemplo la variable "Sniper". Por variable que constantemente crezca y merme Esta tendrнa una probabilidad de decir un dato incorrecto, tendrнas que tener mбs control de las formas que tiene un jugador de salir de tal modo de juego, al entrar la variable crecerнa pero al salir el jugador de йl mermarнa la variable, el problema podrнa venir cuando el jugador se desconecte y no decrezca la variable o por algъn otro medio salga, la primera opciуn es mбs viable pero quizб mбs lenta (pero en tйrminos pitusos literalmente). |
// global
new en_sniper[MAX_PLAYERS];
if(strcmp(cmdtext, "/sniper", true) == 0)
{
if(!en_sniper[playerid])
en_sniper[playerid] = 1,
SetPlayerPos(playerid,-1396.3701,1247.2380,1042.2610),
SendClientMessage(playerid,-1,"Llegaste a sniper");
else
SendClientMessage(playerid,-1,"Ya estas dentro de sniper");
return 1;
}
stock Cantidad_Sniper()
{
new c,cantidad;
while(c < MAX_PLAYERS)
{
if(en_sniper[c]) cantidad++;
c++;
}
return cantidad;
}
forward Users();
public Users()
{
new strings[20];
format(strings, 20, "/sniper: %d ",Cantidad_Sniper());
TextDrawSetString(Usuarios, strings);
TextDrawShowForAll(Usuarios);
return 1;
}