warning 203: symbol is never used: "vehicleid"
#1

So, I'm trying to create my own vehicle system using this tutorial: https://sampforum.blast.hk/showthread.php?tid=416104

I've already fixed all the errors, but I'm still getting this warning:
Код:
warning 203: symbol is never used: "vehicleid"
The code is:

Код:
VehicleFile(vehicleid)
{
	new strPath[64];
	format(strPath, sizeof(strPath), "Test/Vehicles/%d.ini");
	return strPath;
}
However, there are some other functions such as:

Код:
VehicleSave(vehicleid)
{
	new INI:vFile = INI_Open(VehicleFile(vehicleid));

LoadAllVehicles()
{
	new index = 0;

	while(fexist(VehicleFile(index)))
	{
		VehicleLoad(index, VehicleFile(index));
And if I remove "vehicleid" from the "VehicleFile" function, it shows warnings on all the other functions that do use VehicleFile(vehicleid). So, is there any way to fix this? It's very annoying and I'm not sure if it would create any bugs.
Reply
#2

The '%d' specifier in your format needs a value. That's what the vehicleid parameter is for.

PHP код:
format(strPathsizeof(strPath), "Test/Vehicles/%d.ini"vehicleid); 
The '%d' specifier will be replaced by whatever value vehicleid holds.

Quote:
Originally Posted by Cepillado
Посмотреть сообщение
And if I remove "vehicleid" from the "VehicleFile" function, it shows warnings on all the other functions that do use VehicleFile(vehicleid). So, is there any way to fix this? It's very annoying and I'm not sure if it would create any bugs.
Leaving it like this will indeed cause bugs. All your files will be called ".ini".
Reply
#3

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
The '%d' specifier in your format needs a value. That's what the vehicleid parameter is for.

PHP код:
format(strPathsizeof(strPath), "Test/Vehicles/%d.ini"vehicleid); 
That's what I thought at first, but wouldn't this cause an issue with the LoadAllVehicles function?

Код:
LoadAllVehicles()
{
	new index = 0;

	while(fexist(VehicleFile(index)))
	{
		VehicleLoad(index, VehicleFile(index));
		index++;
	}

	printf("Vehicles Loaded: %d", index);
}
The function assigns "index" as the value for the VehicleFile function, not "vehicleid". How would the string be formatted if it's already set to "vehicleid"?
Reply
#4

A function's parameter doesn't necessarily have to have the same name as the variable used when the function is called. The parameter 'vehicleid' is given the value that is passed to the function upon calling it.
Reply
#5

I didn't know that, thank you very much.
Reply
#6

You're welcome.
Reply
#7

Now I'm having a different issue, I hope that it's not because of that, the server is only saving the first vehicle created as 0.ini, all vehicles created after that don't get saved.
Reply
#8

No, it's not because of that. Are you using the code from the tutorial?
Reply
#9

Yes, I just double checked, when the game mode closes it only saves 1 file (Maybe there's not enough time for it to save them all?), I made a command to force save all vehicles and it does work.
Reply
#10

You should save data immediately after its values changed and not upon server termination.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)