Vehicle colors dont save.
#1

Hi,

Ive got a problem. This piece of code doesent save the vehicle colors. Everything, all checks and things, are valid, but he just dont work. Ive added a print() to the code, and it shown me that it can pass all checks, but it just dont save on a weird way. I need some help!

Код:
public SavePlayerVehicleColor(playerid, c1, c2)
{
    GetPlayerName(playerid, pname, sizeof(pname));
	format(file, sizeof file,"%s/%s.ini",CARFILE,pname);
 	if (dini_Exists(file))
  	{
   		dini_IntSet((file),"Color1",c1);
		dini_IntSet((file),"Color2",c2);
		return 1;
	}
}
Reply
#2

This won't work. You need to use a static name for the folder and create it.

pawn Код:
public SavePlayerVehicleColor(playerid, c1, c2)
{
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof file,"VehicleColors/%s.ini",pname);
    if (dini_Exists(file))
    {
        dini_IntSet((file),"Color1",c1);
        dini_IntSet((file),"Color2",c2);
        return 1;
    }
}
Reply
#3

It's not working, the function still saves 0 in the file instead of the right carcolor ...
Reply
#4

Had to get vehicle's colors first. I was looking for this, but I dont remember where I did see, but were a stock.
Reply
#5

Yeah, you have to get the vehicles color first. For this you have to hook CreateVehicle (and all variations of it), pay'n'spray and modshops to update the vehicles color in some variable.
Reply
#6

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
This won't work. You need to use a static name for the folder and create it.

pawn Код:
public SavePlayerVehicleColor(playerid, c1, c2)
{
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof file,"VehicleColors/%s.ini",pname);
    if (dini_Exists(file))
    {
        dini_IntSet((file),"Color1",c1);
        dini_IntSet((file),"Color2",c2);
        return 1;
    }
}
And why is this static and CARFILE isn't? (I assume that CARFILE is a #define)
Sorry, but don't give advices if you don't know much about programming...
Reply
#7

Yes, CARFILE is a location:
Quote:

#define CARFILE "OwnedCars"

Anyway, im looking for that function you all here are talking about. Ty.
Reply
#8

There is no function to get the color, you have to save it when you create the vehicle.

Build a new function like AddVehicle(model, ......, color1, color2)

This function calls CreateVehicle or AddStaticVehicle and you save the vehicle colors in an array. (But don't forget to change that colors, when a player changes the color in a modshop)


Now, if you save the vehicle data, read the colors out of that array.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)