Quote:
Originally Posted by clarencecuzz
The EASIEST way to do it is with foreach. You need to download the 'foreach' include first and add #include <foreach> in your script.
Then...
With foreach include:
pawn Код:
#include <foreach> public OnFilterScriptInit() //Or OnGameModeInit() { SetTimer("ScoreTimer", 1000, true); return 1; }
forward ScoreTimer(); public ScoreTimer() { foreach(Player, i) //If you're using foreach include. (RECOMMENDED) { if(PlayerInfo[i][LoggedIn] == 1) //Check if player is logged in. Remember use 'i' not 'playerid' { seconds[i]++; if(seconds[i] >= 60) { SetPlayerScore(i, GetPlayerScore(i) + 1); seconds[i] = 0; } } } return 1; }
Without foreach include:
pawn Код:
public OnFilterScriptInit() //Or OnGameModeInit() { SetTimer("ScoreTimer", 1000, true); return 1; }
forward ScoreTimer(); public ScoreTimer() { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(PlayerInfo[i][LoggedIn] == 1) { seconds[i]++; if(seconds[i] >= 60) { SetPlayerScore(i, GetPlayerScore(i) + 1); seconds[i] = 0; } } } } return 1; }
|
I use foreach. And changed the PlayerInfo to AccInfo. Now my last warning is seconds[i]++;
Код:
(8541) : error 017: undefined symbol "seconds"
(8541) : warning 215: expression has no effect
(8541) : error 001: expected token: ";", but found "]"
(8541) : error 029: invalid expression, assumed zero
(8541) : fatal error 107: too many error messages on one line
pawn Код:
forward ScoreTimer();
public ScoreTimer()
{
foreach(Player, i) //If you're using foreach include. (RECOMMENDED)
{
if(AccInfo[i][LoggedIn] == 1) //Check if player is logged in. Remember use 'i' not 'playerid'
{
seconds[i]++;
if(seconds[i] >= 60)
{
SetPlayerScore(i, GetPlayerScore(i) + 1);
seconds[i] = 0;
}
}
}
return 1;
}
Thanks for the time making script for me. Appreciate every effort you made!