Server freeze.
#1

HI all..

I have my server with 70-80 players on, and i send this command, and server got FREEZE.


This is command:

Код:
CMD:respawncars(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_WHITE, "{5CAD5C}Error: Your admin/helper level isn't high enough to use this command.");
	for(new i = 1; i < CAR_AMOUNT; i++)
	{
		SetVehicleToRespawn(i);
	}
	new string[60];
	format(string, sizeof(string), "%s (%d) Respawncars %s %s", PlayerInfo[playerid][pName], playerid, GetDMY(1), GetHMS());
	AdminLog(string);
	return 1;
}
This is CAR_AMOUNT

Код:
#define CAR_AMOUNT				900
Reply
#2

Код:
for(new i=0; i < MAX_VEHICLES ;i++)
{
    SetVehicleToRespawn(i);
}
if server still freezes, then remove AdminLog and try again.
also if u want to only respawn un-occupied vehicles, use this
Код:
stock IsVehicleOccupied(vehicleid)
{
    for(new i =0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInVehicle(i,vehicleid))
        {
            return 1;
        }
    }
    return 0;
}

for(new i=0; i < MAX_VEHICLES ;i++)
{
    if(!IsVehicleOccupied(i)) SetVehicleToRespawn(i);
}
Reply
#3

How is correct?

Код HTML:
for(new i = 1; i < CAR_AMOUNT; i++)
or
Код HTML:
for (new i = 0; i < CAR_AMOUNT; i++)
Reply
#4

PHP код:
for(new car 1car <= CAR_AMOUNTcar++) 
Reply
#5

Quote:
Originally Posted by Belengher
Посмотреть сообщение
How is correct?

Код HTML:
for(new i = 1; i < CAR_AMOUNT; i++)
or
Код HTML:
for (new i = 0; i < CAR_AMOUNT; i++)
Why would that freeze the server? 0 and 1 stands for the id where to start the loop at...

Any option it could be caused by AdminLog(string);?
Are u using it anywhere else in your script?
If not, post it please

also please post
GetDMY() and GetHMS()
Reply
#6

Код HTML:
public AdminLog(string[])
{
	new query[300];
	query[0] = (EOS);
	new result2[300];
	mysql_real_escape_string(string, result2);
	mysql_format(g_Sql, query, sizeof(query), "INSERT INTO log_admin (`log`) VALUES ('%s')",result2);
	mysql_query(g_Sql,query);
	return 1;
}
Код HTML:
stock GetDMY(info)
{
	new string[20];
	if(info) format(string, sizeof(string), "%02d/%02d/%d", gday, gmonth, gyear);
	else
	{
		getdate(gyear, gmonth, gday);
		gday += SetDay;
		gmonth += SetMonth;
		if(IsMonth31(gmonth))
		{
			if(gday > 31)
			{
				gmonth += 1;
				if(gmonth > 12)
				{
					gmonth = 1;
					gyear += 1;
					while(gday > 31) gday -= 31;
				}
				else while(gday > 31) gday -= 31;
			}
		}
		else if(!IsMonth31(gmonth) && gmonth != 2)
		{
			if(gday > 30)
			{
				gmonth += 1;
				if(gmonth > 12)
				{
					gmonth = 1;
					gyear += 1;
					while(gday > 30) gday -= 30;
				}
				else while(gday > 30) gday -= 30;
			}
		}
		else if(!IsMonth31(gmonth) && IsMonth29(gyear) && gmonth == 2)
		{
			if(gday > 29)
			{
				gmonth += 1;
				if(gmonth > 12)
				{
					gmonth = 1;
					gyear += 1;
					while(gday > 29) gday -= 29;
				}
				else while(gday > 29) gday -= 29;
			}
		}
		else if(!IsMonth31(gmonth) && !IsMonth29(gyear) && gmonth == 2)
		{
			if(gday > 28)
			{
				gmonth += 1;
				if(gmonth > 12)
				{
					gmonth = 1;
					gyear += 1;
					while(gday > 28) gday -= 28;
				}
				else while(gday > 28) gday -= 28;
			}
		}
		format(string, sizeof(string), "%02d/%02d/%d", gday, gmonth, gyear);
	}
	return string;
}
stock GetDMYH(info)
{
	new hour, minute, second, string[40];
	gettime(hour, minute, second);
	FixTime(hour, minute);
	if(info) format(string, sizeof(string), "%02d/%02d/%d, %02d:%02d:%02d", gday, gmonth, gyear, hour, minute, second);
	else
	{
		getdate(gyear, gmonth, gday);
		gday += SetDay;
		gmonth += SetMonth;
		if(IsMonth31(gmonth))
		{
			if(gday > 31)
			{
				gmonth += 1;
				if(gmonth > 12)
				{
					gmonth = 1;
					gyear += 1;
					while(gday > 31) gday -= 31;
				}
				else while(gday > 31) gday -= 31;
			}
		}
		else if(!IsMonth31(gmonth) && gmonth != 2)
		{
			if(gday > 30)
			{
				gmonth += 1;
				if(gmonth > 12)
				{
					gmonth = 1;
					gyear += 1;
					while(gday > 30) gday -= 30;
				}
				else while(gday > 30) gday -= 30;
			}
		}
		else if(!IsMonth31(gmonth) && IsMonth29(gyear) && gmonth == 2)
		{
			if(gday > 29)
			{
				gmonth += 1;
				if(gmonth > 12)
				{
					gmonth = 1;
					gyear += 1;
					while(gday > 29) gday -= 29;
				}
				else while(gday > 29) gday -= 29;
			}
		}
		else if(!IsMonth31(gmonth) && !IsMonth29(gyear) && gmonth == 2)
		{
			if(gday > 28)
			{
				gmonth += 1;
				if(gmonth > 12)
				{
					gmonth = 1;
					gyear += 1;
					while(gday > 28) gday -= 28;
				}
				else while(gday > 28) gday -= 28;
			}
		}
		format(string, sizeof(string), "%02d/%02d/%d, %02d:%02d:%02d", gday, gmonth, gyear, hour, minute, second);
	}
	return string;
}
Reply
#7

And my server is crashed with for(new = 1
Reply
#8

BUMPPPPPPPPP?
Reply
#9

put in the loop

PHP код:
printf("%d respawned"i); 
check that it's actually starting the loop at all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)