SA-MP Forums Archive
Help foreach Player - 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: Help foreach Player (/showthread.php?tid=478564)



Help foreach Player - bigtigerbeee - 30.11.2013

Код:
public globalPlayerLoop() {
	pingTick++;
	if(pingTick >= 120) {
	    if(mysql_ping() == -1) {
			mysql_reconnect(); // After 120 seconds (2 minutes), we need to ensure the connection is still alive. MySQL sometimes plays up and forces the connection to timeout.
		}
		pingTick = 0;
	}

	if(adTick >= 1)
		adTick--;

	/* --------------------- WORLD TIME --------------------- */

	gettime(gTime[0], gTime[1], gTime[2]);

	if(gTime[1] >= 59 && gTime[2] >= 59) {

		weatherVariables[1] += random(3) + 1; // Weather changes aren't regular.

		//SetWorldTime(gTime[0]); // Set the world time to keep the worldtime variable updated (and ensure it syncs instantly for connecting players).

		if(weatherVariables[1] >= MAX_WEATHER_POINTS) {
			weatherVariables[0] = validWeatherIDs[random(sizeof(validWeatherIDs))];
			foreach(Player, i) {
				if(!GetPlayerInterior(i)) {
					SetPlayerWeather(i, weatherVariables[0]);
				}
				else SetPlayerWeather(i, INTERIOR_WEATHER_ID);
			}
			weatherVariables[1] = 0;
		}
	}

	foreach(Player, x)
	{

	    PlayerInfo[x][pConnectedSeconds] += 1;

		if(gTime[2] >= 59) syncPlayerTime(x);

	    if(PlayerInfo[x][pStatus] == 1) {

			if(IsPlayerESC[x] <= 0)
			{
				IsPlayerESC[x] = 0;
				Esctime[x] += 1;
				format(szMessage, sizeof(szMessage), "*ЛВШґЄСиЗ¤ГТЗ* (%d ЗФ№Т·Х)", Esctime[x]);
				SetPlayerChatBubble(x,szMessage,0x6E6E6EFF,30.0,1500);
			}
			IsPlayerESC[x]--;
			PlayerInfo[x][pSeconds]++;

		    // Fuel
		    new vehicleid = GetPlayerVehicleID(x);
		    if(GetPlayerState(x) == PLAYER_STATE_DRIVER && Fuel[vehicleid] <= 0)
		    {
		        if(Bicycle(vehicleid)) return 1;
		    	new engine, lights, alarm, doors, bonnet, boot, objective;
				GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
				if(engine)
				{
					SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
				    format(szMessage, sizeof(szMessage), "* ѕТЛ№РўН§ %s ЛВШґЕ§а№ЧиН§ЁТЎдБиБХЎкТ«аЛЕЧНАТВг№¶С§", RPN(x));
					nearByMessage(x, COLOR_PURPLE, szMessage);
				}
		    }
Someone PlayerInfo[x][pSeconds] not increase and all
player in my sv more 60


Re: Help foreach Player - Konstantinos - 30.11.2013

It will increase pSeconds for a player only if the pStatus is 1.

By the way, update foreach. The syntax (for the new version) is:
pawn Код:
foreach(new x : Player)



Re: Help foreach Player - xVIP3Rx - 30.11.2013

Deleted


Re: Help foreach Player - bigtigerbeee - 03.12.2013

It not work some time


Re: Help foreach Player - bigtigerbeee - 07.12.2013

Help me pls