Server Freeze after send command - 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: Server Freeze after send command (
/showthread.php?tid=528459)
Server Freeze after send command -
FullCircle - 28.07.2014
This is the command:
pawn Код:
CMD:comprarpatente(playerid, params[])
{
if(Logueado[playerid] == 0) return SendClientMessage(playerid, -1, "{47D751}« ! » {FFFFFF}No estas logueado");
if(PlayerVCantidad[playerid] == 0) return SendClientMessage(playerid, -1, "{47D751}« ! » {FFFFFF}No tienes vehiculos");
new string[28], pv = 1;
while(pv < MAX_PLAYER_VEHICLES)
{
if(validcar[PlayerVehicle[playerid][pv]])
{
format(string, sizeof(string), "Numero: %d || Vehicleid: %d", pv, PlayerVehicle[playerid][pv]);
SendClientMessage(playerid, -1, string);
pv ++;
}
}
return 1;
}
Any idea? Thanks
Re: Server Freeze after send command -
Pulsefire - 28.07.2014
I'm pretty sure this line is causing problems: if(validcar[PlayerVehicle[playerid][pv]])
Quick fix
if(validcar(PlayerVehicle[playerid][pv]))
Edit also set bigger string array
Re: Server Freeze after send command -
BroZeus - 28.07.2014
use this
pawn Код:
while(pv < MAX_PLAYER_VEHICLES)
{
if(validcar(PlayerVehicle[playerid][pv]))
{
format(string, sizeof(string), "Numero: %d || Vehicleid: %d", pv, PlayerVehicle[playerid][pv]);
SendClientMessage(playerid, -1, string);
}
pv++;//outside the "if" not inside
}
the 1st problem is told in the above reply
but the 2nd problem is that pv++ should be out side "if" statement because if one of the car id is not valid then it would result in an infinite loop which would cause the server freeze
Respuesta: Re: Server Freeze after send command -
FullCircle - 28.07.2014
Quote:
Originally Posted by BroZeus
use this
pawn Код:
while(pv < MAX_PLAYER_VEHICLES) { if(validcar(PlayerVehicle[playerid][pv])) { format(string, sizeof(string), "Numero: %d || Vehicleid: %d", pv, PlayerVehicle[playerid][pv]); SendClientMessage(playerid, -1, string); } pv++;//outside the "if" not inside }
the 1st problem is told in the above reply
but the 2nd problem is that pv++ should be out side "if" statement because if one of the car id is not valid then it would result in an infinite loop which would cause the server freeze
|
I have this loops and work fine:
pawn Код:
new pv = 0;
for(new v = 1; v < MAX_VEHICLES; v ++)
{
if(validcar[v])
{
if(cInformacion[v][cVenta] == 0)
{
if(strcmp(NombreJ(playerid), cInformacion[v][cOwner]) == 0)
{
pv ++;
PlayerVehicle[playerid][pv] = v;
PlayerVCantidad[playerid] ++;
}
}
}
}
return 1;
pawn Код:
CMD:checkvehicles(playerid, params[])
{
if(Logueado[playerid] == 0) return SendClientMessage(playerid, -1, "{47D751}« ! » {FFFFFF}No estas logueado");
if(PlayerVCantidad[playerid] == 0) return SendClientMessage(playerid, -1, "{47D751}« ! » {FFFFFF}No tienes vehiculos");
new string[6], pv = 1;
while(pv < MAX_PLAYER_VEHICLES)
{
if(validcar[PlayerVehicle[playerid][pv]])
{
format(string, sizeof(string), "%d: %d", pv, PlayerVehicle[playerid][pv]);
SendClientMessage(playerid, -1, string);
print(string);
pv ++;
}
}
return 1;
}
I'll try anyway
Respuesta: Re: Server Freeze after send command -
FullCircle - 28.07.2014
Quote:
Originally Posted by FullCircle
I have this loops and work fine:
pawn Код:
new pv = 0; for(new v = 1; v < MAX_VEHICLES; v ++) { if(validcar[v]) { if(cInformacion[v][cVenta] == 0) { if(strcmp(NombreJ(playerid), cInformacion[v][cOwner]) == 0) { pv ++; PlayerVehicle[playerid][pv] = v; PlayerVCantidad[playerid] ++; } } } } return 1;
pawn Код:
CMD:checkvehicles(playerid, params[]) { if(Logueado[playerid] == 0) return SendClientMessage(playerid, -1, "{47D751}« ! » {FFFFFF}No estas logueado"); if(PlayerVCantidad[playerid] == 0) return SendClientMessage(playerid, -1, "{47D751}« ! » {FFFFFF}No tienes vehiculos"); new string[6], pv = 1; while(pv < MAX_PLAYER_VEHICLES) { if(validcar[PlayerVehicle[playerid][pv]]) { format(string, sizeof(string), "%d: %d", pv, PlayerVehicle[playerid][pv]); SendClientMessage(playerid, -1, string); print(string); pv ++; } } return 1; }
I'll try anyway
|
It's work, thanks