Car Mod Help -
jonrb - 23.01.2010
Hello, i am trying to make a car mod saving system (it's in my vehicle 'streamer').
There is a problem with the code in practice (the compiler throws up 0 errors and 0 warnings)
Код:
SaveMods(vehid)
{
new modelstr[5],str[256];
new nos,hyd,spoil,wheels,rscoop,exhaust,rbumper,fbumper;
format(modelstr,sizeof(modelstr),"%i",vehid);
nos = GetVehicleComponentInSlot(vehid, CARMODTYPE_NITRO);
hyd = GetVehicleComponentInSlot(vehid, CARMODTYPE_HYDRAULICS);
spoil = GetVehicleComponentInSlot(vehid, CARMODTYPE_SPOILER);
wheels = GetVehicleComponentInSlot(vehid, CARMODTYPE_WHEELS);
rscoop = GetVehicleComponentInSlot(vehid, CARMODTYPE_ROOF);
exhaust = GetVehicleComponentInSlot(vehid, CARMODTYPE_EXHAUST);
rbumper = GetVehicleComponentInSlot(vehid, CARMODTYPE_REAR_BUMPER);
fbumper = GetVehicleComponentInSlot(vehid, CARMODTYPE_FRONT_BUMPER);
format(str,256,"%i %i %i %i %i %i %i %i %i %i",nos,hyd,spoil,wheels,rscoop,exhaust,rbumper,fbumper,Vcolour1[vehid],Vcolour2[vehid]);
dini_Set(MODFILE,modelstr,str);
}
Please note: Vcolour1 and Vcolour2 are declared
using print() markers i found out that the code does not format the string right, no matter what mods the car has the string is "0 0 0 0 0 0 0 0 0 0"
what further confuses me is that this code worked
before I added
Код:
rscoop = GetVehicleComponentInSlot(vehid, CARMODTYPE_ROOF);
exhaust = GetVehicleComponentInSlot(vehid, CARMODTYPE_EXHAUST);
rbumper = GetVehicleComponentInSlot(vehid, CARMODTYPE_REAR_BUMPER);
fbumper = GetVehicleComponentInSlot(vehid, CARMODTYPE_FRONT_BUMPER);
Thank you for your time
Re: Car Mod Help -
mansonh - 23.01.2010
what does putting this in give you? that will tell you if its the formatting, for the numbers.
Код:
printf("%i %i %i %i %i %i %i %i %i %i",nos,hyd,spoil,wheels,rscoop,exhaust,rbumper,fbumper,Vcolour1[vehid],Vcolour2[vehid]);
Re: Car Mod Help -
jonrb - 23.01.2010
"0 0 0 0 0 0 0 0 0 0"
must be the numbers then?
Re: Car Mod Help -
mansonh - 23.01.2010
Only thing i can think of is that your not passing the correct vehicleid.
Where do you call SaveMods?
Re: Car Mod Help -
jonrb - 24.01.2010
it is called under
OnEnterExitModShop(playerid, enterexit, interiorid)
OnVehicleMod(playerid,vehicleid,componentid)
Re: Car Mod Help -
Joey09 - 24.01.2010
Whats the bug than?
Re: Car Mod Help -
jonrb - 24.01.2010
if i knew i'd have either fixed it or posted it here =
EDIT: It gets the vehicle ID right, i checked
Re: Car Mod Help -
mansonh - 24.01.2010
Yah that all looks clean.
Its a longshot but try %d instead of %i, they are both meant to be integers but could be a possible cause.
Re: Car Mod Help -
jonrb - 24.01.2010
annoyingly, still doesn't work.
could my strtok() be buggy?
pawn Код:
stock strtok(const string[], &index,seperator=' ')
{
new length = strlen(string);
new offset = index;
new result[MAX_STRING];
while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
if ((index < length) && (string[index] == seperator))
{
index++;
}
return result;
}
Re: Car Mod Help -
mansonh - 24.01.2010
Well you said that using print showed on the servers command line also showed "0 0 0 0..." so that is separate.
When i mean server command line i mean the command window of the actual server not the ingame text.