Buffer overflow? Help... - 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: Buffer overflow? Help... (
/showthread.php?tid=281603)
Buffer overflow? Help... -
ccconfy - 06.09.2011
pawn Код:
public LoadCar()
{
new arrCoords[27][64];
new strFromFile2[256];
new File: file = fopen("LARP/Vehicles/cars.cfg", io_read);
if (file)
{
new idx = 184;
while (idx < sizeof(CarInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
CarInfo[idx][cModel] = strval(arrCoords[0]);
CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
CarInfo[idx][cColorOne] = strval(arrCoords[5]);
CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
CarInfo[idx][cOwned] = strval(arrCoords[8]);
CarInfo[idx][cLock] = strval(arrCoords[9]);
CarInfo[idx][cPaintjob] = strval(arrCoords[10]);
CarInfo[idx][cVirWorld] = strval(arrCoords[11]);
CarInfo[idx][cComponent0] = strval(arrCoords[12]);
CarInfo[idx][cComponent1] = strval(arrCoords[13]);
CarInfo[idx][cComponent2] = strval(arrCoords[14]);
CarInfo[idx][cComponent3] = strval(arrCoords[15]);
CarInfo[idx][cComponent4] = strval(arrCoords[16]);
CarInfo[idx][cComponent5] = strval(arrCoords[17]);
CarInfo[idx][cComponent6] = strval(arrCoords[18]);
CarInfo[idx][cComponent7] = strval(arrCoords[19]);
CarInfo[idx][cComponent8] = strval(arrCoords[20]);
CarInfo[idx][cComponent9] = strval(arrCoords[21]);
CarInfo[idx][cComponent10] = strval(arrCoords[22]);
CarInfo[idx][cComponent11] = strval(arrCoords[23]);
CarInfo[idx][cComponent12] = strval(arrCoords[24]);
CarInfo[idx][cComponent12] = strval(arrCoords[25]);
CarInfo[idx][cComponent13] = strval(arrCoords[26]);
idx++;
}
printf("[SCRIPT]: Loaded %d Cars", idx);
}
return 1;
}
So this is how I basically load the cars in my server. The problem is when alot of players buy cars, at some moment, everything with the cars is not working. You cannot buy, Your car ID changes, and then everything else... Does anybody know how to fix that and increase the buffer?
Re: Buffer overflow? Help... -
StuffBoy - 06.09.2011
Are you sure that the order of the enum matches with the order of your car loading ? I don't see other any possible cause...
Re: Buffer overflow? Help... -
ccconfy - 06.09.2011
cars.cfg ->
http://pastebin.com/Y8E7VLEz
Re: Buffer overflow? Help... -
StuffBoy - 06.09.2011
I mean your script not the cars saved in a file
Re: Buffer overflow? Help... -
DRIFT_HUNTER - 07.09.2011
The part of code you gave us is a LOAD part witch is called at server start to read from file and store to variables.
That is not the part of code that is bugged.I guess its a buy car command or create or something like that
Re: Buffer overflow? Help... -
ccconfy - 07.09.2011
Yeah, but when this happen, ive got a backup of cars.cfg and when I load it, everything is fine. So im thinking that this must be probably wrong way to load cars.cfg. Im not sure ;(
Re: Buffer overflow? Help... -
[H]ead - 07.09.2011
The file have 686
lines
Try:
Put 700 on sizeof CarInfo
- [H]ead