Little help
#1

Okay, so i creating count system now, and need a little question/help.
Now i created a variables, which will hide counting for player who disabled count with command.

Command:
PHP код:
    if(strcmp(cmdtext,"/count",true) == 0)
    {
       if(
count[playerid] == 1)
       if (
== false)
       {
       
true;
       for(new 
iMAX_PLAYERSi++) {
       
GameTextForPlayer(i"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~b~-~g~ 3 ~b~-",1000,3);
       
GetPlayerPos(i,X,Y,Z);
       }
       
SetTimer("count2",1000,0);
       
SetTimer("count1",2000,0);
       
SetTimer("countgo",3000,0);
       
SetTimer("stop",6000,0);
    }
       else 
SendClientMessage(playerid0xFFFFFFFF"{FF0000}KLAIDA{FFFFFF}: Skaiиiavimas jau pradлtas");
       if(
count[playerid] == 0)
       {
    }
       return 
1;
     } 
The count invisible for player who disabled the counting, but when other players start count the texdraws appears again..

The variable of disable is
PHP код:
if(count[playerid] == 1
1 = Disabled counting
0 = Enabled counting.
Reply
#2

then do this both at the same time (i think)
pawn Код:
if(count[playerid] == 1)
pawn Код:
if(count[playerid] == 0)
Reply
#3

pawn Код:
new
    CountTimer,
    CountState;

if (strcmp(cmdtext, "/count", true) == 0)
{
    if (CountState != 0)
    {
        return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}KLAIDA{FFFFFF}: Skaiиiavimas jau pradлtas");
    }
    CountTimer = SetTimer("StartCD", 1000, true);
    CountState = 3;
    return true;
}

forward StartCD();
public  StartCD()
{
    for (new i; i < MAX_PLAYERS; i++)
    {
        if (!IsPlayerConnected(i)) continue;
        if (count[i]) continue;
        if (CountState > 0)
        {
            new szResult[40];
            format(szResult, 40, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~%d", CountState - 1);
            GameTextForAll(szResult, 1000, 5);
            PlayerPlaySound(i, 1056, 0, 0, 0);
            -- CountState;
        }
        else
        {
            GameTextForAll("~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~~g~PIRMYN!", 1000, 5);
            PlayerPlaySound(i, 1057, 0, 0, 0);
            KillTimer(CountTimer);
        }
    }
    return true;
}
ant greito parasiau, gali but klaidu =] jei ka rasyk
Reply
#4

I have a small tip about making that loop, which would eliminate the need for an IsPlayerConnected function call.

Make sure that the count variable is 1 for all disconnected players (weird that you use 1 for not displaying and 0 for displaying, though).
pawn Код:
new count[MAX_PLAYERS] = {1, ...};
// ...
public OnPlayerDisconnect(playerid)
{
    count[playerid] = 1; // Counting disabled
}
Then you can do:
pawn Код:
forward StartCD();
public StartCD()
{
    for(new i; i != MAX_PLAYERS; i++)
    {
        if(count[i]) continue;
        // Rest of BaubaS' code
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)