Vehicle Load Error
#1

Hey guys.

In a previous post I managed to make my vehicle system's saving part work properly (thanks to user Konstantinos).
Now I have some difficulties loading the previously bought and saved vehicle(s).

In the folder scriptfiles/Jбrművek (in english: vehicles) there is the car saved as "0.ini".
Since SaveAllVehicles(); is under OnGameModeExit, I restarted the server with the rcon command "/rcon gmx" to see if the vehicle loads properly.
The gamemode doesn't want to load now if that "0.ini" file is in the scriptfiles/Jбrművek (in english: vehicles) folder. On the other hand, if I remove "0.ini", the gamemode loads and the server works fine.

Please help.
Reply
#2

What about the code that loads your cars? can you upload it?
Reply
#3

Yes of course, here you are:

Код:
stock VehicleLoad(vid, file[])
{
	INI_ParseFile(file, "LoadVehicle_%d", .bExtra = true, .extra = vid);
	VehicleCreate(VehicleInfo[vid][vmodel],
	VehicleInfo[vid][xspawn],
	VehicleInfo[vid][yspawn],
	VehicleInfo[vid][zspawn],
	VehicleInfo[vid][aspawn],
	VehicleInfo[vid][col1],
	VehicleInfo[vid][col2],
	VehicleInfo[vid][respawn],
	VehicleInfo[vid][owner]);
}
+

Код:
stock LoadAllVehicles()
{
	new index = 0;
	while(fexist(VehiclePath(index)))
	{
	    for(new i=0; i<MAX_VEHICLES; i++)
	    {
	        if(validcar[i])
	        {
	            VehicleLoad(index, VehiclePath(index));
	            index++;
	        }
	    }
	}
	printf("Jarmuvek betoltve: %i", index);
}
+

Код:
public LoadVehicle_data(vid, name[], value[])
{
	INI_Int("Model", VehicleInfo[vid][vmodel]);
	INI_Float("XSpawn", VehicleInfo[vid][xspawn]);
	INI_Float("YSpawn", VehicleInfo[vid][yspawn]);
	INI_Float("ZSpawn", VehicleInfo[vid][zspawn]);
	INI_Float("AngleSpawn", VehicleInfo[vid][aspawn]);
	INI_Int("Color1", VehicleInfo[vid][col1]);
	INI_Int("Color2", VehicleInfo[vid][col2]);
	INI_Int("Respawn", VehicleInfo[vid][respawn]);
	INI_String("Owner", VehicleInfo[vid][owner], MAX_PLAYER_NAME);
	return 1;
}
Reply
#4

My guess is infinite loop. You increase "index" only if the "i" is validcar so if it's not, it will keep running.

If the file doesn't exist or the limit is reached, use break; to stop the loop. Also the way you load them is a bit weird. What are you trying to do?
Reply
#5

My resource is T0pAz's vehicle system, I'm just trying to memorize it and understand the things how they work. I don't really understand this part:

Код:
stock VehicleLoadAll()
{
	new index = 0;
	while(fexist(VehiclePath(index)))
	{
	    for(new i=0; i<MAX_VEHICLES; i++)
	    {
	        if(validcar[i])
	        {
	            VehicleLoad(index, VehiclePath(index));
	            index++;
	        }
	    }
	}
	printf("Vehicles Loaded: %i", index);
}
What do you mean by using break; ? Something like this?

Код:
stock VehicleLoadAll()
{
	new index = 0;
	while(fexist(VehiclePath(index)))
	{
	    for(new i=0; i<MAX_VEHICLES; i++)
	    {
	        if(validcar[i])
	        {
	            VehicleLoad(index, VehiclePath(index));
	            index++;
	        }
                else
                {
                    break;
                }
	    }
	}
	printf("Vehicles Loaded: %i", index);
}
Reply
#6

Do you have a link for it so I can check what that array is meant for?

When you load all the vehicles let's say in OnGameModeInit, that means that there are no vehicles (unless you create before but in all the cases, they're loaded first) so I don't see the point of looping through all the vehicles. One loops is just enough.
Reply
#7

THREAD
Reply
#8

Okay, the mistake was done by you as he doesn't use a second loop in his tutorial but in the code you posted above, it does. Just follow his tutorial step by step and I'm sure you'll get it working.
Reply
#9

Thank you again, it's working.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)