Hallo Breadfish
wenn ich 2 Fraktionsfahrzeuge erstelle übernimmt er immer das alte fahrzeug mit dann sieht es so aus
ich hoffe ihr könnt mir da helfen
enum fInfo
{
bool:fLock,
fCarid,
fVehid,
Float:fPos[4],
fCol[2],
fWheel,
fFraction,
fCarRotate,
fCarNitro,
fCarHyd,
fCarAusp,
fCarSideL,
fCarSideR,
fCarFB,
fCarRB,
fCarSpoiler,
fCarRoof,
fCarHood,
fCarVents,
fCarLamps,
fCarPJ,
fNeon,
fParkkralle,
fAbgeschleppt
};
new FractionCars[MAX_FRACTION_CARS][fInfo];
forward LoadFractionCars();
forward SaveFractionCars();
forward fUnlockCar(Carid);
forward fLockCar(Carid);
forward RemoveFromCar(playerid);
forward DestroyAndCreateFractionCar(fc);
forward FractionLockDoors();
ocmd:efa(playerid,params[])
{
new modelid,frakid,Float:PosX2,Float:PosY2,Float:PosZ2,Float:PosA2,color1,color2;
if (SpielerInfo[playerid][pAdmin] <= 5) return SendClientMessage(playerid,COLOR_YELLOW,"[FRAKTIONSCAR]: Du bist kein Admin !");
if(sscanf(params,"dddd",modelid,frakid,color1,color2)) return SendClientMessage(playerid,0x00FF00FF,"Benutze: /efa [Model ID] [Fraktion ID] [Color 1] [Color 2])");
new fc = FreeFrakCheck();
new query[128];
format(query,sizeof(query),"INSERT INTO frakcars (id) VALUES ('%d')",fc);
mysql_function_query(mysqlcon,query, true, "","");
mysql_free_result();
GetPlayerPos(playerid,PosX2,PosY2,PosZ2);
GetPlayerFacingAngle(playerid,PosA2);
FractionCars[fc][fVehid] = modelid;
FractionCars[fc][fPos][0] = PosX2;
FractionCars[fc][fPos][1] = PosY2;
FractionCars[fc][fPos][2] = PosZ2;
FractionCars[fc][fPos][3] = PosA2;
new Color[2];
if(SpielerInfo[playerid][sMember]==1)
{
Color[0] = 152;
Color[1] = 1;
}
else if(SpielerInfo[playerid][sMember]==2)
{
Color[0] = 0;
Color[1] = 0;
}
else if(SpielerInfo[playerid][sMember]==3)
{
Color[0] = 61;
Color[1] = 61;
}
else if(SpielerInfo[playerid][sMember]==4)
{
Color[0] = 3;
Color[1] = 1;
}
else if(SpielerInfo[playerid][sMember]==4)
{
Color[0] = 1;
Color[1] = 1;
}
else
{
Color[0] = color1;
Color[1] = color1;
}
FractionCars[fc][fCol][0] = Color[0];
FractionCars[fc][fCol][1] = Color[1];
FractionCars[fc][fFraction] = frakid;
FractionCars[fc][fCarid] = CreateVehicle(FractionCars[fc][fVehid],FractionCars[fc][fPos][0],FractionCars[fc][fPos][1],FractionCars[fc][fPos][2],FractionCars[fc][fPos][3],FractionCars[fc][fCol][0],FractionCars[fc][fCol][1],-1);
SetVehicleNumberPlate(FractionCars[fc][fCarid], Fracs[FractionCars[fc][fFraction]-1]);
SendClientMessage(playerid,COLOR_YELLOW,"[FRAKTIONSCAR]: Du hast das Auto erfolgreich erstellt!");
SendClientMessage(playerid,COLOR_YELLOW,"[FRAKTIONSCAR]: Vergiss aber nicht es später mit /fpark umzuparken!");
SendClientMessage(playerid,COLOR_YELLOW,"[INFO]: Für weitere Befehle verwende /fcarinfo");
PutPlayerInVehicle(playerid,FractionCars[fc][fCarid],0);
SaveFractionCars();
return 1;
}
stock FreeFrakCheck()
{
new bedin[128],query[128];
for(new i;i<MAX_FRACTION_CARS;i++)
{
format(bedin,sizeof(bedin),"id='%i'",i);
format(query,sizeof(query),"SELECT * FROM frakcars WHERE %s",bedin);
mysql_function_query(mysqlcon,query, true, "","");
mysql_store_result();
if(mysql_retrieve_row()==0) return i;
}
return 0;
}
public FractionLockDoors(){
new i;
for(;i<MAX_PLAYERS;i++){
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
new fc;
for(;fc<MAX_FRACTION_CARS; fc++)
{
if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611)
{
if(FractionCars[fc][fLock])
{
if(SpielerInfo[i][sMember]==FractionCars[fc][fFraction])
{
SetVehicleParamsForPlayer(FractionCars[fc][fCarid],i,0,0);
}
else
{
SetVehicleParamsForPlayer(FractionCars[fc][fCarid],i,0,1);
}
}
}fc++;
}
}
}return 1;
}
public LoadFractionCars()
{
new query[128], idx;
print("[ERFOLGREICH]: Fraktionsfahrzeuge geladen...");
while (idx < MAX_FRACTION_CARS)
{
format(query,sizeof(query),"SELECT * FROM `frakcars` WHERE `id`='%i'",idx);
mysql_function_query(mysqlcon,query, true, "LoadMysqlFractionCars", "i",idx);
idx++;
}
return 1;
}
forward LoadMysqlFractionCars(idx);
public LoadMysqlFractionCars(idx)
{
new rows,fields, val[128];
cache_get_data(rows,fields);
if(rows)
{
cache_get_field_content(0,"VehID",val), FractionCars[idx][fVehid] = strval(val);
cache_get_field_content(0,"PosX",val), FractionCars[idx][fPos][0] = strval(val);
cache_get_field_content(0,"PosY",val), FractionCars[idx][fPos][1] = strval(val);
cache_get_field_content(0,"PosZ",val), FractionCars[idx][fPos][2] = strval(val);
cache_get_field_content(0,"PosR",val), FractionCars[idx][fPos][3] = strval(val);
cache_get_field_content(0,"Col1",val), FractionCars[idx][fCol][0] = strval(val);
cache_get_field_content(0,"Col2",val), FractionCars[idx][fCol][1] = strval(val);
cache_get_field_content(0,"Fraktion",val), FractionCars[idx][fFraction] = strval(val);
cache_get_field_content(0,"Wheel",val), FractionCars[idx][fWheel] = strval(val);
cache_get_field_content(0,"parkkralle",val), FractionCars[idx][fParkkralle] = strval(val);
cache_get_field_content(0,"Abgeschleppt",val), FractionCars[idx][fAbgeschleppt] = strval(val);
mysql_free_result();
if(FractionCars[idx][fVehid] >= 400 && FractionCars[idx][fVehid] <= 611)
{
FractionCars[idx][fCarid] = CreateVehicle(FractionCars[idx][fVehid],FractionCars[idx][fPos][0],FractionCars[idx][fPos][1],FractionCars[idx][fPos][2],FractionCars[idx][fPos][3],FractionCars[idx][fCol][0],FractionCars[idx][fCol][1], -1);
SetVehicleNumberPlate(FractionCars[idx][fCarid], Fracs[FractionCars[idx][fFraction]-1]);
SetVehicleToRespawn(FractionCars[idx][fCarid]);
FractionCars[idx][fLock] = false;
}
}
}
public SaveFractionCars()
{
new query[1024];
for(new idx;idx<MAX_FRACTION_CARS; idx++)
{
if(FractionCars[idx][fVehid] >= 400 && FractionCars[idx][fVehid] <= 611)
{
format(query,sizeof(query),"UPDATE `frakcars` SET `VehID` = '%d', `PosX` = '%f' ,`PosY` = '%f' ,`PosZ` = '%f' ,`PosR` = '%f',`Col1` = '%d',`Col2` = '%d',`Fraktion` = '%d',`Wheel` = '%d',`parkkralle` = '%d',`Abgeschleppt` = '%d' WHERE `id` = '%d'",
FractionCars[idx][fVehid], FractionCars[idx][fPos][0], FractionCars[idx][fPos][1], FractionCars[idx][fPos][2], FractionCars[idx][fPos][3], FractionCars[idx][fCol][0], FractionCars[idx][fCol][1], FractionCars[idx][fFraction], FractionCars[idx][fWheel],FractionCars[idx][fParkkralle],FractionCars[idx][fAbgeschleppt], idx);
mysql_function_query(mysqlcon,query,false, "SendQuery","");
}
}
return 1;
}
forward SendQuery();
public SendQuery()
{
return 1;
}
public DestroyAndCreateFractionCar(fc){
if(FractionCars[fc][fVehid] >= 400 && FractionCars[fc][fVehid] <= 611){
DestroyVehicle(FractionCars[fc][fCarid]);
FractionCars[fc][fCarid] = CreateVehicle(FractionCars[fc][fVehid],FractionCars[fc][fPos][0],FractionCars[fc][fPos][1],FractionCars[fc][fPos][2],FractionCars[fc][fPos][3],FractionCars[fc][fCol][0],FractionCars[fc][fCol][1],-255);
return true;
}return false;
}
public fLockCar(Carid){
new i;
for(;i<MAX_PLAYERS;i++){
SetVehicleParamsForPlayer(Carid,i,0,1);
}return 1;
}
public fUnlockCar(Carid){
new i;
for(;i<MAX_PLAYERS;i++){
SetVehicleParamsForPlayer(Carid,i,0,0);
}return 1;
}