Why it doesn't save VehicleColor?
#1

As in title:


Код:
#include <a_samp>
#include <dini>
#include <vfunc>


new pname[24];
new PlayerVehicle[MAX_PLAYERS];
new isarenda[MAX_PLAYERS];
new arendaveh[MAX_VEHICLES];
new vehiclearenda[MAX_PLAYERS];
new vpj[MAX_VEHICLES];
new kolor1;
new kolor2;


public OnFilterScriptInit()
{
	print("\n=====================================");
	print(" Ultra Tuned Car Saver loaded!");
	print("                   by pasha97 aka [UFF]Pasha aka [N.R.G]Boss_Pasha");
	print("=====================================\n");
	for(new i = 0; i < MAX_VEHICLES; i++)
	{

	vpj[i] = 3;
	}
	return 1;
}

public OnFilterScriptExit()
{
	print("\n=====================================");
	print(" Ultra Tuned Car Saver unloaded!");
	print("=====================================\n");
	return 1;
}


public OnPlayerConnect(playerid)
{
  	GetPlayerName(playerid, pname, sizeof(pname));
	new file[256];format(file,sizeof(file),"Tuned Cars/%s.sav", pname);
  	if(dini_Isset(file,"ID") && dini_Isset(file,"X")  && dini_Isset(file,"Y") && dini_Isset(file,"Z") && dini_Isset(file,"ROT") && dini_Isset(file,"COLOR1") && dini_Isset(file,"COLOR2")){
	PlayerVehicle[playerid]=CreateVehicle(dini_Int(file,"ID"),dini_Int(file,"X"),dini_Int(file,"Y"),dini_Int(file,"Z"),dini_Int(file,"ROT"),dini_Int(file,"COLOR1"),dini_Int(file,"COLOR2"),100);
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT1"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT2"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT3"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT4"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT5"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT6"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT7"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT8"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT9"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT10"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT11"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT12"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT13"));
	AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT14"));
	ChangeVehicleColor(PlayerVehicle[playerid], dini_Int(file,"COLOR1"), dini_Int (file,"COLOR2"));
	ChangeVehiclePaintjob(PlayerVehicle[playerid], dini_Int(file,"PAINTJOB"));
	arendaveh[PlayerVehicle[playerid]] = playerid;
	isarenda[PlayerVehicle[playerid]] = 1;}
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    DestroyVehicle(PlayerVehicle[playerid]);
	isarenda[PlayerVehicle[playerid]] = 0;
	return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
   	if(strcmp(cmdtext, "/zauto", true) == 0)
	{
	new file[256];
	new str[256];
	new Float:nx,Float:ny,Float:nz,Float:nrot,Model, comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14, kolorki;
	new Var[50];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "Tuned Cars/%s.sav", pname);
	if(!dini_Exists(file))
	{
	dini_Create(file);
	}
	if(!IsPlayerInAnyVehicle(playerid)){
	SendClientMessage(playerid,0xFF0000FF,"Nie jesteś w pojeździe!");
	return 1;}
  	if(IsPlayerInAnyVehicle(playerid)){
    if(dini_Isset(file,"ID") && dini_Isset(file,"X")  && dini_Isset(file,"Y") && dini_Isset(file,"Z") && dini_Isset(file,"ROT") && dini_Isset(file,"COLOR1") && dini_Isset(file,"COLOR2")){
	SendClientMessage(playerid,0xFFCC00FF,"Twуj prywatny pojazd został zmieniony!");}
	GetPlayerPos(playerid,nx,ny,nz);
 	GetVehicleZAngle(GetPlayerVehicleID(playerid),nrot);
	Model=GetVehicleModel(GetPlayerVehicleID(playerid));
	comp1 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_SPOILER);
	comp2 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_HOOD);
	comp3 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_ROOF);
	comp4 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_SIDESKIRT);
	comp5 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_EXHAUST);
	comp6 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_WHEELS);
	comp7 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_HYDRAULICS);
	comp8 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_FRONT_BUMPER);
	comp9 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_REAR_BUMPER);
	comp10 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_LAMPS);
	comp11 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_NITRO);
	comp12 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_STEREO);
	comp13 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_VENT_RIGHT);
	comp14 = GetVehicleComponentInSlot(GetPlayerVehicleID(playerid), CARMODTYPE_VENT_LEFT);
	kolorki = GetVehicleColor(GetPlayerVehicleID(playerid), kolor1, kolor2);
	dini_IntSet(file,"ID",Model);
	format(Var, sizeof(Var),"%0.2f", nx);
	dini_IntSet(file,"X",strval(Var));
	format(Var, sizeof(Var),"%0.2f", ny);
	dini_IntSet(file,"Y",strval(Var));
	format(Var, sizeof(Var),"%0.2f", nz+0.5);
	dini_IntSet(file,"Z",strval(Var));
	format(Var, sizeof(Var),"%0.2f", nrot);
	dini_IntSet(file,"ROT",strval(Var));
	dini_IntSet(file,"COLOR1", kolorki);
	dini_IntSet(file,"COLOR2", kolorki);
	dini_IntSet(file,"COMPONENT1",comp1);
	dini_IntSet(file,"COMPONENT2",comp2);
	dini_IntSet(file,"COMPONENT3",comp3);
	dini_IntSet(file,"COMPONENT4",comp4);
	dini_IntSet(file,"COMPONENT5",comp5);
	dini_IntSet(file,"COMPONENT6",comp6);
	dini_IntSet(file,"COMPONENT7",comp7);
	dini_IntSet(file,"COMPONENT8",comp8);
	dini_IntSet(file,"COMPONENT9",comp9);
	dini_IntSet(file,"COMPONENT10",comp10);
	dini_IntSet(file,"COMPONENT11",comp11);
	dini_IntSet(file,"COMPONENT12",comp12);
	dini_IntSet(file,"COMPONENT13",comp13);
	dini_IntSet(file,"COMPONENT14",comp14);
	dini_IntSet(file,"PAINTJOB",vpj[GetPlayerVehicleID(playerid)]);
	PlayerVehicle[playerid]=GetPlayerVehicleID(playerid);
	arendaveh[PlayerVehicle[playerid]] = playerid;
	isarenda[PlayerVehicle[playerid]] = 1;
	SendClientMessage(playerid,0x00FF00FF,"Twуj prywatny pojazd został zapisany!");
}
	return 1;
	}
   	if(strcmp(cmdtext, "/pauto", true) == 0)
	{
		GetPlayerName(playerid, pname, sizeof(pname));
		new file[256], str[256];format(file,sizeof(file),"Tuned Cars/%s.sav", pname);
		new Float:nx,Float:ny,Float:nz,Float:nrot;
		GetPlayerPos(playerid, nx, ny, nz);
		GetPlayerFacingAngle(playerid, nrot);
		if(dini_Isset(file,"ID") && dini_Isset(file,"X")  && dini_Isset(file,"Y") && dini_Isset(file,"Z") && dini_Isset(file,"ROT") && dini_Isset(file,"COLOR1") && dini_Isset(file,"COLOR2")){
		SetVehiclePos(PlayerVehicle[playerid], nx, ny, nz);
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT1"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT2"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT3"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT4"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT5"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT6"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT7"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT8"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT9"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT10"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT11"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT12"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT13"));
		AddVehicleComponent(PlayerVehicle[playerid], dini_Int(file,"COMPONENT14"));
		ChangeVehicleColor(PlayerVehicle[playerid], dini_Int(file,"COLOR1"), dini_Int(file,"COLOR2"));
		ChangeVehiclePaintjob(PlayerVehicle[playerid], dini_Int(file,"PAINTJOB"));
		PutPlayerInVehicle(playerid, PlayerVehicle[playerid], 0);
	    SendClientMessage(playerid, 0x00FF00FF, "Twуj prywatny pojazd został załadowany!");
	}
	    else{
	    SendClientMessage(playerid, 0xFF0000FF, "Nie posiadasz prywatnego pojazdu!");}
	    return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	vehiclearenda[playerid] = GetPlayerVehicleID(playerid);
	if(isarenda[vehiclearenda[playerid]] == 1)
	{
	if(newstate == PLAYER_STATE_DRIVER)
	{
	if(arendaveh[vehiclearenda[playerid]] == playerid)
	{
	SendClientMessage(playerid,0xFFCC00FF,"{ffcc00}To twуj prywatny pojazd!");
	}
	else
	{
	RemovePlayerFromVehicle(playerid);
	SendClientMessage(playerid,0xFF0000,"{ff0000}To nie jest twуj pojazd!");
	}
	}
	}
	return 1;
}


public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	vpj[vehicleid] = paintjobid;
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}
Reply
#2

Because it's not made to do so. And as there's no native functions to get a vehicle color/paintjob, you'll need this: https://sampforum.blast.hk/showthread.php?tid=339088
Reply
#3

look at my include, i did this...
Reply
#4

Oh right, sorry.

You're using it wrong - the function doesn't return the color, it puts it in to the two variables that are passed by reference. You're putting the colours in to the variables kolor1 and kolor2 but never saving them. Vehicles have TWO colors.

[pawn]
kolorki = GetVehicleColor(GetPlayerVehicleID(playerid), kolor1, kolor2);
[pawn]

kolorki is always going to be the PRIMARY color, but you won't be saving the secondary one.
Reply
#5

So i have two questions:


1. How can i choose second variable from this function?

2. Primary color is not saving properly - why?
Reply
#6

pawn Код:
new c1, c2;
GetVehicleColors(vehicleid, c1, c2);

Save variables c1 and c2 to player's file.
Reply
#7

I think im doing this with this part:

Код:
new kolor1;
new kolor2;
(...)
then i'm doing this:
Код:
(...)
if(strcmp(cmdtext, "/zauto", true) == 0)
	{
  GetVehicleColor(GetPlayerVehicleID(playerid), kolor1, kolor2);

(...)

dini_IntSet(file,"COLOR1", kolor1);
	dini_IntSet(file,"COLOR2", kolor2);
(...)

}
But it still doesn't work...

//edit: I can add that i'm doing change of color in GUI, maybe it matters or sth?

//edit2: I tried to spray my car in Pay n Spray garage, it doesn't work either.
Reply
#8

Well, i changed my color in modshop which is implemented in GTA:SA and it saved properly...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)