PDA

View Full Version : Server freeze.


Belengher
30/01/2018, 07:29 PM
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

Mugala
31/01/2018, 07:53 AM
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 thisstock 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);
}

Belengher
04/02/2018, 04:26 PM
How is correct?


for(new i = 1; i < CAR_AMOUNT; i++)


or

for (new i = 0; i < CAR_AMOUNT; i++)

PepsiCola23
04/02/2018, 04:51 PM
for(new car = 1; car <= CAR_AMOUNT; car++)

jasperschellekens
04/02/2018, 04:52 PM
How is correct?


for(new i = 1; i < CAR_AMOUNT; i++)


or

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()

Belengher
04/02/2018, 04:56 PM
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;
}


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;
}

Belengher
04/02/2018, 05:00 PM
And my server is crashed with for(new = 1

Belengher
05/02/2018, 05:12 PM
BUMPPPPPPPPP?

Sew_Sumi
05/02/2018, 06:06 PM
put in the loop

printf("%d respawned", i);

check that it's actually starting the loop at all.