Choosing a random player bug
#1

Hey, I registered an account as I browse this forum a lot. So, let's get to the point. This is my code:
PHP код:
    for(new 0MAX_PLAYERSi++)
{
    if(
IsPlayerConnected(i))
    {
        if(
pInEvent[i] == 1)
        {
        new 
president random(i);
        if(
president == playerid)
                {
                
SetPlayerSkin(playerid228);
                
GivePlayerWeapon(playerid2499999);
                }
                else if(
president != playerid)
                {
                
SetPlayerSkin(playerid165);
                
GivePlayerWeapon(playerid2399999);
                } 
Basically this should choose a random player as the president and the rest of the people as the agents. I already made the event commands etc but this block of code is my problem.
Any fix?
Reply
#2

What is the problem?
And your code has no logic.
Reply
#3

PHP код:
CheckPlayers(status)
{
    new 
players;
    for(new 
pGetPlayerPoolSize(); <= op++)
    {
        if(
IsPlayerConnected(p))
        {
            switch(
status)
            {
                case 
0:
                {
                    
players ++;
                }
                case 
1:
                {
                    if(
pInEvent[p])
                    {
                        
players ++;
                    }
                }
            }
        }
    }
    return 
players;
}
//
// at the top right after the includes, there where the variables belong...
new president = -1;
/* C O D E */
    
for(new iGetPlayerPoolSize(); <= li++) // loop
    
{
        if(
IsPlayerConnected(i)) // checks for connected
        
{
            if(
pInEvent[i])
            {
                if(
president == -1)
                {
                    
president CheckPlayers(1);
                }
                if(
president == playerid)
                {
                    
SetPlayerSkin(playerid228);
                    
GivePlayerWeapon(playerid2499999);
                }
                else if(
president != playerid)
                {
                    
SetPlayerSkin(playerid165);
                    
GivePlayerWeapon(playerid2399999);
                }
            }
        }
    }
/* C O D E */ 
Here you go.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)