warning 203: symbol is never used: "vehicleid" -
Cepillado - 28.12.2015
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.
Re: warning 203: symbol is never used: "vehicleid" -
AndySedeyn - 28.12.2015
The '%d' specifier in your format needs a value. That's what the vehicleid parameter is for.
PHP код:
format(strPath, sizeof(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".
Respuesta: Re: warning 203: symbol is never used: "vehicleid" -
Cepillado - 28.12.2015
Quote:
Originally Posted by AndySedeyn
The '%d' specifier in your format needs a value. That's what the vehicleid parameter is for.
PHP код:
format(strPath, sizeof(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"?
Re: warning 203: symbol is never used: "vehicleid" -
AndySedeyn - 28.12.2015
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.
Respuesta: warning 203: symbol is never used: "vehicleid" -
Cepillado - 28.12.2015
I didn't know that, thank you very much.
Re: warning 203: symbol is never used: "vehicleid" -
AndySedeyn - 28.12.2015
You're welcome.
Respuesta: warning 203: symbol is never used: "vehicleid" -
Cepillado - 28.12.2015
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.
Re: warning 203: symbol is never used: "vehicleid" -
AndySedeyn - 28.12.2015
No, it's not because of that. Are you using the code from the tutorial?
Respuesta: warning 203: symbol is never used: "vehicleid" -
Cepillado - 28.12.2015
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.
Re: warning 203: symbol is never used: "vehicleid" -
AndySedeyn - 28.12.2015
You should save data immediately after its values changed and not upon server termination.