PDA

View Full Version : Vehicle System Error


DOL4N
16/05/2015, 09:49 PM
Hey guys.

I'm working on a gamemode, which (would) include a vehicle buying/saving/loading system. I made every single stock which it requires. Saving path, free slot, saving vehicle, loading vehicle, creating vehicle.
Compiled it several times, no errors or warnings.

Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase

But when i write
LoadAllVehicles(); under OnGameModeInit and
SaveAllVehicles(); under OnGameModeExit,
it suddenly starts to show some errors which have nothing to do with the stocks or OnGameModeInit & -Exit. But when i remove the above lines, it shows no error.
.inc folder is up to date, every include which I need is on the top of the script.

Errors:

When LoadAllVehicles(); is under OnGameModeInit:

gamemodes\roleplay.pwn(337 -- 338) : error 047: array sizes do not match, or destination array is too small

Line 337: CreateVehicleEx(VehicleInfo[vehicleID][vmodel],VehicleInfo[vehicleID][xspawn],VehicleInfo[vehicleID][yspawn],VehicleInfo[vehicleID][zspawn],
Line 338: VehicleInfo[vehicleID][anglespawn],VehicleInfo[vehicleID][col1],VehicleInfo[vehicleID][col2],VehicleInfo[vehicleID][respawn],VehicleInfo[vehicleID][owner]);

When SaveAllVehicles(); is under OnGameModeExit:

gamemodes\roleplay.pwn(305) : error 017: undefined symbol "Open"
gamemodes\roleplay.pwn(305) : warning 213: tag mismatch

Line 305: new INI:dFile = Open(VehiclePath(vehicleID));

Please help me, I'm trying to solve this problem for 2 days..

willsuckformoney
16/05/2015, 10:03 PM
Show your enum for VehicleInfo?

Konstantinos
16/05/2015, 10:07 PM
I assume the problem is with CreateVehicleEx and specifically the last parameter.

Do you use y_ini? If so, INI_Open.

DOL4N
16/05/2015, 10:07 PM
Here it is:
enum vInfo
{
vmodel,
Float:xspawn,
Float:yspawn,
Float:zspawn,
Float:anglespawn,
col1,
col2,
respawn,
owner[MAX_PLAYER_NAME]
}

Konstantinos
16/05/2015, 10:13 PM
Can you post the parameters of CreateVehicleEx function? For example using v_owner[MAX_PLAYER_NAME] as a parameter would give the error but without a size at all, it wouldn't.

DOL4N
16/05/2015, 10:19 PM
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[MAX_PLAYER_NAME]) <--- Konstantinos: [MAX_PLAYER_NAME] should not be there?
{
new carid = GetVehicleFreeSlot();
VehicleInfo[carid][vmodel] = modelid;
VehicleInfo[carid][xspawn] = x;
VehicleInfo[carid][yspawn] = y;
VehicleInfo[carid][zspawn] = z;
VehicleInfo[carid][anglespawn] = angle;
VehicleInfo[carid][col1] = color1;
VehicleInfo[carid][col2] = color2;
VehicleInfo[carid][respawn] = respawntime;
format(VehicleInfo[carid][owner], MAX_PLAYER_NAME, ownername);
validcar[carid] = true;
CreateVehicle(modelid, x, y, z, angle, color1, color2, respawntime);
return carid;
}

Konstantinos
16/05/2015, 10:20 PM
The size shouldn't be there. Replace it with ownername[]

DOL4N
16/05/2015, 10:30 PM
It seems to be working. Thank you! +REP