first you need a value(data) of veh owner/faction for save/load
PHP код:
new CarOwner[MAX_VEHICLES][MAX_PLAYER_NAME], Bool:CarOwned[MAX_VEHICLES], VehType[MAX_VEHICLES], PlayerFaction[MAX_PLAYERS];//it just example, you can use in enumerations or something you want
public OnGameModeInit()
{
LoadCars();
return 1;
}
static LoadCars()
{
...mysql query etc..
cache_get_value_name_int(idx, "faction", VehType[vehicleid]); // load veh faction
cache_get_value_name_null(idx, "owned", CarOwned[vehicleid]); //load owner
cache_get_value_name(idx, "owner", CarOwner[vehicleid]); //load owner
...
}
static SaveCars()
{
...mysql query to save/update car value with faction&owner etc..
}
also load player data PlayerFaction when player login,
and you can check when player entered in veh
PHP код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(CarOwned[vehicleid])
{
static string[64];
format(string, sizeof(string), "This car owner is : %s", CarOwner[vehicleid]);
SendClientMessage(playerid, -1, string);
}
if(VehType[vehicleid] != PlayerFaction[playerid])
{
static string[64], factname[32];
switch(VehType[vehicleid]){
case 1:{
format(factname, sizeof(factname), "FBI");
}
default:{
format(factname, sizeof(factname), "NONE");
}
}
format(string, sizeof(string), "This car is Faction: %s", factname);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}
this just a example,
you can make more good and great by youself!