Vehicle color and paintjob!
#1

Hello!
I almost make big big big vehicle saving system (5 vehicles max.)
But I dont now how I could save vehicle color or paintjob!
Код:
ENUM:
vcolor1[6],
vcolor2[6],
paintjob[6],
Код:
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
????? How to make it?
I dont have an idea??
return 1;
}
Reply
#2

Hi, you have to save the components in scripting files every time someone tune the vehicle
Reply
#3

These shouldn't be strings, but integers;
pawn Код:
vcolor1,
vcolor2,
paintjob,
It's pretty simple;
pawn Код:
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
VehicleInfo[vehicleid][paintjob] = paintjobid;
return 1;
}
As for vehicles colours;
pawn Код:
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
VehicleInfo[vehicleid][vcolor1] = color1;
VehicleInfo[vehicleid][vcolor2] = color2;
return 1;
}
Just change "VehicleInfo" to your vehicles enum variable.
Reply
#4

Currently, you cannot. You need to know the vehicle ID of those vehicles so you can compare it with the vehicleid of OnVehiclePaintjob. So on creating of the vehicle, store the vehicle ID to your enum-array and then check if they do match. If they do, assign the paintjobid to the variable for that index.
Reply
#5

I have more of them
Read it all!
I have 5 of them
Thats why:
Код:
ENUM:
vcolor1[6],
vcolor2[6],
paintjob[6],
Reply
#6

OOh hey konst. Can you create what ould it look like(its possible I have seen it )
=)
Reply
#7

@Luis You forget:

Quote:

#include <dini> - http://dracoblue.net/downloads/dini/
Quote:

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
VehicleInfo[vehicleid][paintjob] = paintjobid;
new file[50],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(file,sizeof(file),"Server TUNE/%s.ini",name);
if(!dini_Exists(file)){
dini_Create(file);
dini_IntSet(file,"Paintjob",paintjobid);
}else{
dini_IntSet(file,"Paintjob",paintjobid);
}
return 1;
}

and

Quote:

OnVehicleRespray(playerid, vehicleid, color1, color2)
{
VehicleInfo[vehicleid][vcolor1] = color1;
VehicleInfo[vehicleid][vcolor2] = color2;
new file[50],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(file,sizeof(file),"Server/Tune/%s.ini",name);
if(!dini_Exists(file)){
dini_Create(file);
dini_IntSet(file,"vcolor1",color1);
dini_IntSet(file,"vcolor2",color2);
}else{
dini_IntSet(file,"vcolor1",color1);
dini_IntSet(file,"vcolor2",color2);
}
return 1;
}

Reply
#8

I have all of that !!!!
Just how to save variables (paintjob id)
Reply
#9

@kyriakos587: I wouldn't suggest using dini as it's really old and slow. There are better ways to go with: SQL (MySQL or SQLite) or y_ini.

As there are 5 only vehicles, no need to use an array with size of MAX_VEHICLES (totally pointless):
PHP код:
enum e_Vehicles
{
    
VehicleID,
    
Color1,
    
Color2,
    
Paintjob
};
new 
Vehicles[5][e_Vehicles];
// 5 vehicles: bounds 0-4
// OnGameModeInit/OnFilterScriptInit:
for (new i!= sizeof (Vehicles); ++i)
{
    
Vehicles[i][VehicleID] = INVALID_VEHICLE_ID;
    
Vehicles[i][Color1] = Vehicles[i][Color1] = -1;
    
Vehicles[i][Paintjob] = 3;
}
// OnVehiclePaintjob
for (new i!= sizeof (Vehicles); ++i)
{
    if (
vehicleid == Vehicles[i][VehicleID])
    {
        
Vehicles[i][Paintjob] = paintjobid;
    }
}
// OnVehicleRespray
for (new i!= sizeof (Vehicles); ++i)
{
    if (
vehicleid == Vehicles[i][VehicleID])
    {
        
Vehicles[i][Color1] = color1;
        
Vehicles[i][Color2] = color2;
    }
}
// When creating a vehicle check if the vehicle ID is not INVALID_VEHICLE_ID and:
Vehicles[index_here][VehicleID] = CreateVehicle(...);
// when destroying a vehicle (same as above):
DestroyVehicle(Vehicles[index_here][VehicleID]);
Vehicles[index_here][VehicleID] = INVALID_VEHICLE_ID;
// don't forget to reset it 
And for Pay n' Sprays: http://pastebin.com/zX96D4dA
but instead of "-1" as colors, use "random(256)" so it'll be synced with all the players (otherwise use MP2's include for that, it also saves paintjob etc.).
Reply
#10

But I have it like this!

Код:
enum pInfo
{
//OTHER STUFF ...
Model[6],
vcolor1[6],
vcolor2[6],
comp1[6],
comp2[6],
comp3[6],
comp4[6],
comp5[6],
comp6[6],
comp7[6],
comp8[6],
comp9[6],
paintjob[6]
//OTHER STUFF ...
}
new PlayerInfo[MAX_PLAYERS][pInfo];
How to make i with this?
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)