Car Mod Help
#1

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
Reply
#2

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]);
Reply
#3

"0 0 0 0 0 0 0 0 0 0"
must be the numbers then?
Reply
#4

Only thing i can think of is that your not passing the correct vehicleid.
Where do you call SaveMods?
Reply
#5

it is called under
OnEnterExitModShop(playerid, enterexit, interiorid)
OnVehicleMod(playerid,vehicleid,componentid)
Reply
#6

Whats the bug than?
Reply
#7

if i knew i'd have either fixed it or posted it here =
EDIT: It gets the vehicle ID right, i checked
Reply
#8

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.
Reply
#9

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;
}
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)