removing a value from a variable
#1

Hey Guys,
So ive just came across this question i cant find a answer to.

If I create a variable called players to see how meny is online so i can divide the amount of players online by the amount of players that want HappyHour to run so like a votng system

I know how to add to variable you use this

pawn Код:
PlayerInfo[playerid][Players]++;
So how do I take away from that variable

and how can i divide that varible by 2 and get half to make the happy hour variable reach half its value before the votes for Happy Hour reach the level where it starts#

Thanks in advance.
Reply
#2

Quote:
Originally Posted by SpankMe2
Посмотреть сообщение
So how do I take away from that variable
pawn Код:
PlayerInfo[playerid][Players]--
Quote:
Originally Posted by SpankMe2
Посмотреть сообщение
how can i divide that varible by 2
pawn Код:
PlayerInfo[playerid][Players]/2
Reply
#3

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
pawn Код:
PlayerInfo[playerid][Players]--


pawn Код:
PlayerInfo[playerid][Players]/2
Thanks + its that simple oh and the script was fixed last night it was one line up from where you removed that other bracket so Thanks for you help there to
Reply
#4

Like this?

pawn Код:
new
    iPlayerCounts = -1
;

public OnPlayerConnect( playerid )
{
    if ( iPlayerCounts < 0 )
        iPlayerCounts = 0;
    else
        iPlayerCounts ++; // Increase the iPlayerCounts, you could do " iPlayerCounts += 1; "

    return 1;
}

public OnPlayerDisconnect( playerid, reason )
{
    if ( iPlayerCounts > -1 )
        iPlayerCounts --; // Take away the variable, you could use " iPlayerCounts -= 1; "

    return 1;
}

stock dividePlayersByTwo( )
    return iPlayerCounts / 2; // Divides iPlayerCounts by Two.

stock startHappyHour( )
{
    if ( ( dividePlayersByTwo( ) ) < 5 ) // if ( ( iPlayerCounts /2 ) < 5 )
        return GameTextForAll( "Not enough players", 3000, 3 );

    return 1;
}
If I understand, you are asking this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)