Why this doesent save?
#1

Hi,
My question is simple: Why this doesent work?

Код:
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    if(pVeh[playerid] != -1 && pVeh[playerid] == vehicleid)
	{
        GetPlayerName(playerid, pname, sizeof(pname));
		format(file, sizeof file,"%s/%s.ini",CARFILE,pname);
	    if (dini_Exists(file))
	    {
	        dini_IntSet(file,"Color1",color1);
			dini_IntSet(file,"Color2",color2);
 			return 1;
		}
	}
	return 1;
}
And Yes, all variable's are valid.
Reply
#2

Show us your CARFILE define.
Reply
#3

Код:
#define CARFILE "OwnedCars" //
It works on all the other car data .
Reply
#4

Aren't you supposed to check if the dini doesn't exist? And if it doesn't - create it? I'm not sure i haven't used dini for a long time. From the looks of that code it will write the color to the file if the file exists, but if it doesn't exist it will do nothing. (and maybe cause a crash)

EDIT: I may be confused with the standard file functions not sure. Like i said i havn't used dini for a long time. (and even then i used it for a very short time)
Reply
#5

pawn Код:
#define CARFILE OwnedCars

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    if(pVeh[playerid] != -1 && pVeh[playerid] == vehicleid)
    {
        GetPlayerName(playerid, pname, sizeof(pname));
        format(file, sizeof file,"%s/%s.ini", CARFILE, pname);
        if(dini_Exists(file))
        {
            dini_IntSet(file,"Color1",color1);
            dini_IntSet(file,"Color2",color2);
        }
        else
        {
            dini_Create(file);
            dini_IntSet(file,"Color1",color1);
            dini_IntSet(file,"Color2",color2);
        }
    }
    return 1;
}
Try now.
Reply
#6

This function will only be called if pVeh[playerid] is not -1. Ive made a function on another point in the script that creates a file if a player buys a car, so i dont have to create it.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)