VPlayers = GetPlayersOnServer()/2+1;
if(GetPlayersOnServer() <= 2)
return SendClientMessage(playerid,GREY,"The minimum players required for this command to work are 3.");
VPlayers = GetPlayersOnServer()/2+1;
if(GetPlayersOnServer() <=2)
return SendClientMessage(playerid,GREY,"The minimum players required for this command to work are 3.");
GetPlayersOnServer()
{
new count;
for(new x=0; x< MAX_PLAYERS; x++)
{
if(IsPlayerConnected(x))
{
count++;
}
}
return count;
}
dcmd_votecash(playerid,params[])
{
new id,n[24],on[24],str2[128],string[3];
new tmp[256], tmp2[256], Index,str[128];
VPlayers = GetPlayersOnServer()/2+1;
if(GetPlayersOnServer() <= 2)
return SendClientMessage(playerid,GREY,"The minimum players required for this command to work are 3.");
tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp);
if(IsPlayerAdmin(id)) return SendClientMessage(playerid,0xFF0000FF,"You cannot try to Votecash an admin! -_-");
if(VoteActive == 1) return SendClientMessage(playerid,0xFF0000FF,"There is already a Vote for something in proccess, please wait until it has finished.");
GetPlayerName(playerid,n,24),GetPlayerName(id,on,24);
Voted[playerid] = 1;
SlapName = on;
PlayerName = n;
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /Votecash [ID] [Reason]");
if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID.");
Votes = 1;
VoteActive = 1;
format(str2,sizeof(str2),"~r~Votecash on ~w~%s. ~r~%d/%d",PlayerName,Votes,VPlayers);
Votecash = TextDrawCreate(50.0,300.0,str2);
TextDrawLetterSize(Votecash,0.5,2.5);
TextDrawShowForAll(Votecash);
thingy = SetTimer("VoteFail",21000,false);
Timer = SetTimerEx("CountDownTimer",1000,true,"i",playerid);
format(str,sizeof(str),"%s has started a Votecash on %s. Reason: %s. To vote - /votec",n,on,params[2]);
SendClientMessageToAll(0xFF0000FF,str);
format(string,sizeof(string),"%d",Count);
TCountDown = TextDrawCreate(300.0,300.0,string);
Count = 21;
return 1;
VPlayers = GetPlayersOnServer();
// Then
if(VPlayers == 3)
{
}
GetPlayersOnServer()
{
new count;
for(new x=0; x< MAX_PLAYERS; x++)
{
if(IsPlayerConnected(x))
{
count++;
}
}
return count;
}
new count = 0;
pawn Код:
count = count+1 (count++), but count doesn't have any value, it contains junk. Just assign a value to count while defining it: pawn Код:
|
It will still work... Initialising the variable is common practice but not a necessity in PAWN.
|