CreateVehicle returns a very big and incorrect ID - 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: CreateVehicle returns a very big and incorrect ID (
/showthread.php?tid=383939)
CreateVehicle returns a very big and incorrect ID -
Universal - 09.10.2012
Hi guys, first time I got this problem. Somewhy CreateVehicle returns an invalid ID (65535) of the vehicle created. Here is what I get in console (I use crashdetect plugin).
Код:
[19:49:33] [debug] Run time error 4: "Array index out of bounds"
[19:49:33] [debug] Accessing element at index 65535 past array upper bound 299
[19:49:33] [debug] AMX backtrace:
[19:49:33] [debug] #0 0004341c in ?? () from **.amx
[19:49:33] [debug] #1 0004de0c in public Itter_OnGameModeInit () from **.amx
[19:49:33] [debug] #2 native CallLocalFunction () [00472260] from samp-server.exe
[19:49:33] [debug] #3 00007714 in public zcmd_OnGameModeInit () from **.amx
[19:49:33] [debug] #4 native CallLocalFunction () [00472260] from samp-server.exe
[19:49:33] [debug] #5 00006d18 in public SSCANF_OnGameModeInit () from **.amx
[19:49:33] [debug] #6 native CallLocalFunction () [00472260] from samp-server.exe
[19:49:33] [debug] #7 00000ff4 in public Streamer_OnGameModeInit () from **.amx
[19:49:33] [debug] #8 native CallLocalFunction () [00472260] from samp-server.exe
[19:49:33] [debug] #9 00000560 in public OnGameModeInit () from **.amx
The pawn code is very simple...
pawn Код:
new
id = CreateVehicle(model, x, y, z, a, color1, color2, 0);
I have no idea why it is doing so and Im sure its something about this piece of code, because when I remove it there are no errors.
Thanks in advice!
Re: CreateVehicle returns a very big and incorrect ID -
ViniBorn - 09.10.2012
Check the model value, It must be between 411 and 611
Re: CreateVehicle returns a very big and incorrect ID -
AndreT - 09.10.2012
I suppose you have something like this in your script:
pawn Код:
new id = CreateVehicle(...);
some_array[id] = ...;
Now the case is that when something is wrong (invalid model ID, server full of vehicles), the CreateVehicle native returns INVALID_VEHICLE_ID (65535).
You need to add a safety guard for this:
pawn Код:
new id = CreateVehicle(...);
if(id != INVALID_VEHICLE_ID)
{
// continue
}
Re: CreateVehicle returns a very big and incorrect ID -
Universal - 09.10.2012
Yeah, you were right guys, the model was invalid... Thanks!