Little help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Little help (
/showthread.php?tid=355388)
Little help -
ixesas - 29.06.2012
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 (e == false)
{
e = true;
for(new i; i < MAX_PLAYERS; i++) {
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(playerid, 0xFFFFFFFF, "{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.
Re: Little help -
[A]ndrei - 29.06.2012
then do this both at the same time (i think)
Re: Little help -
BaubaS - 29.06.2012
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
Re: Little help -
AndreT - 29.06.2012
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
}
}