Car system spawns X cars (bug) - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Car system spawns X cars (bug) (
/showthread.php?tid=212672)
Car system spawns X cars (bug) -
Ice-cup - 17.01.2011
No errors or w/e are shown when compiling.
When I add a car IG it will use the following snippet.
At first it will spawn 1 vehicle but when I check my carspawn.cfg before even gmxing the game I notice X (didn't count them!) amount of variables and there should be only 2 "strings" or "rows" of variables.
So basicly when I restart the server it extracts ALL those variables out of the .cfg and spawns them :X.
Код:
if(IsValidCar(vehid))
{
CreateVehicle(vehid, x+1,y,z,angle,c1,c2, 320000);
for(new i = 0; i < sizeof(DynamicCars); i++)
{
GetVehiclePos(i, vehx, vehy, vehz);
if(PlayerToPoint(5.0, playerid, vehx, vehy, vehz))
{
new vehicle;
vehicle = GetPlayerVehicleID(playerid);
DynamicCars[i][CarModel] = vehid;
DynamicCars[i][CarX] = x;
DynamicCars[i][CarY] = y;
DynamicCars[i][CarZ] = z;
DynamicCars[i][CarID] = vehicle;
DynamicCars[i][Price] = price;
DynamicCars[i][CarType] = type;
DynamicCars[i][CarColor1] = c1;
DynamicCars[i][CarColor2] = c2;
DynamicCars[i][CarAngle] = GetPlayerFacingAngle(playerid, angle);
DynamicCars[i][FactionCar] = 255;
DynamicCars[i][Owned] = 0;
Fuel[i] = GasMax;
EngineStatus[i] = 0;
VehicleLocked[i] = 0;
SaveDynamicCars();
}
}
}
The savedynamiccars public is pretty basic:
Код:
public SaveDynamicCars()
{
new idx;
new File: file2;
while (idx < sizeof(DynamicCars))
{
new coordsstring[512];
format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d|%d|%d|%s|%d|%d|%d\n",
DynamicCars[idx][CarModel],
DynamicCars[idx][CarX],
DynamicCars[idx][CarY],
DynamicCars[idx][CarZ],
DynamicCars[idx][CarAngle],
DynamicCars[idx][CarColor1],
DynamicCars[idx][CarColor2],
DynamicCars[idx][FactionCar],
DynamicCars[idx][CarType],
DynamicCars[idx][Owner],
DynamicCars[idx][CarID],
DynamicCars[idx][Owned],
DynamicCars[idx][Price]);
if(idx == 0)
{
file2 = fopen("EG_Scriptfiles/Cars/carspawns.cfg", io_write);
}
else
{
file2 = fopen("EG_Scriptfiles/Cars/carspawns.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
Re: Car system spawns X cars (bug) -
Ice-cup - 20.01.2011
Still the same problem, tried a lot of things.
But I noticed; my .cfg is empty but there is a carspawns.txt which is full of variables (see 1th post).