GetVehicleColor doesn't works ! ! !
#1

I'm trying to save vehicle color on SII. I've tried with dini also, but nothing, and thought to ask someone for help :S. I've used this INC before, but dont remember if I've tried to save on a file.
Код:
// GETVEHICLECOLOR.INC
/*
	@Release:	GetVehicleColor
	@Release Type:	Include
	@Author:	RyDeR`
	@Last Update:	04/01/2011 - 19:36
	@Version:	1.2
*/

#if !defined SetSharingData
	#define SetSharingData(%0,%1) \
	    setproperty(0, "", (%0), (%1))
#endif

#if !defined GetSharingData
	#define GetSharingData(%0,%1) \
	    getproperty(0, "", (%0), (%1))
#endif

native _AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2) 

= AddStaticVehicle;
native _AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, 

color2, respawn_delay) = AddStaticVehicleEx;
native _CreateVehicle(vehicletype, Float: x, Float: y, Float: z, Float: rotation, color1, color2, respawn_delay) = 

CreateVehicle;
native _DestroyVehicle(vehicleid) = DestroyVehicle;
native _ChangeVehicleColor(vehicleid, color1, color2) = ChangeVehicleColor;

#define AddStaticVehicle \
	__AddStaticVehicle

#define AddStaticVehicleEx \
	__AddStaticVehicleEx

#define CreateVehicle \
	__CreateVehicle

#define DestroyVehicle \
	__DestroyVehicle

#define ChangeVehicleColor \
	__ChangeVehicleColor

stock __AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2)
{
	new
		vehicleID,
		string[24]
	;
	vehicleID = _AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, 

color1, color2);

	format(string, sizeof(string), "%d-%d", color1, color2);
	SetSharingData(vehicleID, string);
	
	return vehicleID;
}

stock __AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, 

color2, respawn_delay)
{
	new
		vehicleID,
		string[24]
	;
	vehicleID = _AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, 

color1, color2, respawn_delay);

	format(string, sizeof(string), "%d-%d", color1, color2);
	SetSharingData(vehicleID, string);

	return vehicleID;
}

stock __CreateVehicle(vehicletype, Float: x, Float: y, Float: z, Float: rotation, color1, color2, respawn_delay)
{
	new
		vehicleID,
		string[24]
	;
	vehicleID = _CreateVehicle(vehicletype, Float: x, Float: y, Float: z, Float: rotation, color1, color2, 

respawn_delay);

	format(string, sizeof(string), "%d-%d", color1, color2);
	SetSharingData(vehicleID, string);

	return vehicleID;
}

stock __DestroyVehicle(vehicleid)
{
	SetSharingData(vehicleid, "0-0");
	return _DestroyVehicle(vehicleid);
}

stock __ChangeVehicleColor(vehicleid, color1, color2)
{
	new
		string[24]
	;
	format(string, sizeof(string), "%d-%d", color1, color2);
	SetSharingData(vehicleid, string);
	
	return _ChangeVehicleColor(vehicleid, color1, color2);
}

stock __OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	#pragma unused \
	    playerid

	new
		string[24]
	;
	format(string, sizeof(string), "%d-%d", color1, color2);
	SetSharingData(vehicleid, string);
	return 1;
}

stock GetVehicleColor(vehicleid, &color1, &color2)
{
	new
	    stringData[24],
	    stringColor[2][12],
	    i
	;
	GetSharingData(vehicleid, stringData);
	
	if((i = strfind(stringData, "-", true)) != -1)
	{
		strmid(stringColor[0], stringData, 0, i);
		strmid(stringColor[1], stringData, (i + 1), strlen(stringData));

		color1 = strval(stringColor[0]);
		color2 = strval(stringColor[1]);
		return 1;
	}
	return 0;
}
On my command:
pawn Код:
new color1,color2;
GetVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
INI_WriteInt("Color1", color1);
INI_WriteInt("Color2", color2);
And on the file which is saved:
Код:
Owner=the_runner
Model=522
Color1=0 // ever 0
Color2=0 // ever 0
ID=0
x=1861.2303
y=1179.1230
z=10.4272
a=138.3676
plate=the_runner
Hope anyone may know what's the problem
Reply
#2

Is it the same if you use DINI to write?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)