Please Help me with Y_INI
#1

Hi guys , i wrote a Vehicle Ownship yet.
now it can create a file , write in the datebase and give me a car when i send the cmd.
but when the sever restart ,it cant add the car in.
please help me.

Hi ******, thanks you to share your work to us!

Код:
forward load_veh_data_basic(vid, name[], value[]);
public load_veh_data_basic(vid, name[], value[])
{

    INI_String("Owner", vInfo[vid][vOwner],MAX_PLAYER_NAME);
    INI_Float("Position_X", vInfo[vid][vX]);
    INI_Float("Position_Y", vInfo[vid][vY]);
    INI_Float("Position_Z", vInfo[vid][vZ]);
    INI_Float("Position_R", vInfo[vid][vR]);
    INI_Int("Color_1", vInfo[vid][vColor1]);
    INI_Int("Color_2", vInfo[vid][vColor2]);
	return 0;
}
Код:
enum VehInfo
{
	vOwner[MAX_PLAYER_NAME],
	vModel,
	vLock,
	Float:vX,
	Float:vY,
	Float:vZ,
	Float:vR,
	vColor1,
	vColor2
};

new vInfo[MAX_VEHICLES][VehInfo];
Код:
public OnGameModeInit()
{
	for(new i=0;i<MAX_PLAYERCAR;i++)
	{
	    new file[64];
   		format(file,sizeof(file),"/Vehicles/%d.ini",i);
    	INI_ParseFile(file, "load_veh_data_%s",.bPassTag = true);
    	AddStaticVehicle(vInfo[i][vModel],vInfo[i][vX],vInfo[i][vY],vInfo[i][vZ],vInfo[i][vR],vInfo[i][vColor1],vInfo[i][vColor2]);
		if(!fexist(file)){break;}
	}
	return 1;
}
Код:
CMD:buycar(playerid, params[])
{
	new file[64];
    for(new i=0;i<MAX_PLAYERCAR;)
    {
	    format(file,sizeof(file),"/Vehicles/%d.ini",i);
		if(fexist(file))
		{
		    continue;
		}
		else
		{
		    new Float:x,Float:y,Float:z,Float:r;
			GetPlayerPos(playerid,x,y,z);
			GetPlayerFacingAngle(playerid,r);
			new INI:iniFile = INI_Open(file);
			INI_WriteString(iniFile, "Owner", GetName(playerid));
			INI_WriteInt(iniFile, "Model", 422);
			INI_WriteFloat(iniFile,"Position_X",x);
			INI_WriteFloat(iniFile,"Position_Y",y);
			INI_WriteFloat(iniFile,"Position_Z",z);
			INI_WriteFloat(iniFile,"Position_R",r);
			INI_WriteInt(iniFile,"Color_1",1);
			INI_WriteInt(iniFile,"Color_2",1);
		    INI_Close(iniFile);
			new buycar = CreateVehicle(422, x, y, z, r, 1, 1, -1);
			PutPlayerInVehicle(playerid, buycar, 0);
		    vInfo[buycar][vOwner] = GetName(playerid);
		}
    }
	return 1;
}
Reply


Messages In This Thread
Please Help me with Y_INI - by VivianKris - 12.06.2011, 07:25

Forum Jump:


Users browsing this thread: 1 Guest(s)