Thanks but im becoming this error.
Код:
[17:45:02] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id FROM FraktionsCars ORDER by id DESC", callback: "(null)", format: "(null)"
[17:45:02] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[17:45:02] [DEBUG] mysql_tquery - scheduling query "SELECT id FROM FraktionsCars ORDER by id DESC"..
[17:45:02] [DEBUG] cache_get_row_count - connection: 1
[17:45:02] [WARNING] cache_get_row_count - no active cache
[17:45:02] [DEBUG] mysql_tquery - connection: 1, query: "SELECT id FROM FraktionsCars WHERE id='1'", callback: "(null)", format: "(null)"
[17:45:02] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[17:45:02] [DEBUG] mysql_tquery - scheduling query "SELECT id FROM FraktionsCars WHERE id='1'"..
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - query was successful
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - no callback specified, skipping result saving
[17:45:02] [DEBUG] cache_get_row_count - connection: 1
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks()
[17:45:02] [WARNING] cache_get_row_count - no active cache
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[17:45:02] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO FraktionsCars (id,FraktionsID) VALUES ('1','5')", callback: "(null)", format: "(null)"
[17:45:02] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - no callback specified, skipping result saving
[17:45:02] [DEBUG] mysql_tquery - scheduling query "INSERT INTO FraktionsCars (id,FraktionsID) VALUES ('1','5')"..
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks()
[17:45:02] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE FraktionsCars SET ModelID='411', CarX='180.695541', CarY=", callback: "(null)", format: "(null)"
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[17:45:02] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[17:45:02] [DEBUG] mysql_tquery - scheduling query "UPDATE FraktionsCars SET ModelID='411', CarX='180.695541', CarY='-66.606407', CarZ='2.293365', CarR='333.622283', CarDMG='1000.000000', Color1='3', Color2='3', Tank='30', Nitro='0', Abgeschleppt='0', Motorschaden='0', Kennzeichen='Medic', LastDriver='Niemand' WHERE id='1'"..
[17:45:02] [ERROR] CMySQLQuery::Execute[()] - (error #1062) Duplicate entry '1' for key 'PRIMARY'
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - error will be triggered in OnQueryError
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks()
[17:45:02] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
[17:45:02] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[17:45:02] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - query was successful
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - no callback specified, skipping result saving
[17:45:02] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks()
[17:45:02] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
PHP код:
ocmd:createfcar(playerid, params[])
{
new Model,FraktionsID,Color1,Color2,Kennzeichen[24],string[128],query[400];
if(!IsPlayerAnAdmin(playerid,5))return SendClientMessage(playerid,COLOR_LIGHTRED,"Du bist kein Administrator!");
if(sscanf(params,"dddds[24]",Model,FraktionsID,Color1,Color2,Kennzeichen))return SendClientMessage(playerid,COLOR_LIGHTRED,"/createfcar [vehicleid] [fraktionsid] [color1] [color2] [kennzeichen]");
if(Model<400||Model>611)return SendClientMessage(playerid,COLOR_LIGHTRED,"Gьltige ModelID's sind 400-611");
if(FraktionsID>=25)return SendClientMessage(playerid,COLOR_LIGHTRED,"Diese Fraktion gibt es nicht!");
new i=getFreeFraktAuto();
new k=getFreeFraktAutoDBid();
format(query,sizeof(query),"INSERT INTO FraktionsCars (id,FraktionsID) VALUES ('%i','%d')",k,FraktionsID);
mysql_function_query(dbhandle,query,false,"","");
new carid=k;
new Float:cx,Float:cy,Float:cz,Float:cr;
GetPlayerPos(playerid,cx,cy,cz);
GetPlayerFacingAngle(playerid,cr);
FCar[i][fx]=cx;
FCar[i][fy]=cy;
FCar[i][fz]=cz;
FCar[i][fr]=cr;
FCar[i][fFraktionsID]=FraktionsID;
FCar[i][fColor1]=Color1;
FCar[i][fColor2]=Color2;
FCar[i][fTank]=30;
FCar[i][fdmg]=1000;
FCar[i][fNitro]=0;
FCar[i][fAbgeschleppt]=0;
FCar[i][fMotorschaden]=0;
FCar[i][fModelID]=Model;
format(FCar[i][fKennzeichen],24,"%s",Kennzeichen);
format(FCar[i][fLastDriver],24,"Niemand");
format(query,sizeof(query),"UPDATE FraktionsCars SET ModelID='%i', CarX='%f', CarY='%f', CarZ='%f', CarR='%f', CarDMG='%f', Color1='%d', Color2='%d', Tank='%d', Nitro='%i', Abgeschleppt='%i', Motorschaden='%i', Kennzeichen='%s', LastDriver='%s' WHERE id='%i'",
FCar[i][fModelID],FCar[i][fx],FCar[i][fy],FCar[i][fz],FCar[i][fr],FCar[i][fdmg],FCar[i][fColor1],FCar[i][fColor2],FCar[i][fTank],FCar[i][fNitro],FCar[i][fAbgeschleppt],FCar[i][fMotorschaden],FCar[i][fKennzeichen],FCar[i][fLastDriver],carid);
mysql_function_query(dbhandle,query,false,"","");
FCar[i][fDBID]=k;
FCar[i][fID] = CreateVehicle(Model,cx,cy,cz,cr,Color1,Color2,0);
SetVehicleNumberPlate(FCar[i][fID],FCar[i][fKennzeichen]);
PutPlayerInVehicle(playerid,FCar[i][fID],0);
format(string,sizeof(string),"** %s hat ein Fraktionsauto (ID: %d, FraktionsID: %d DbID: %d ) erstellt!",SpielerName(playerid),GetPlayerVehicleID(playerid),FCar[i][fFraktionsID],FCar[i][fDBID]);
SendAdminMessage(COLOR_YELLOW,string);
AdminLog(string);
return 1;
}
stock getFreeFraktAuto()
{
new fAuto;
for(new i=1; i<MAX_FCARS; i++)
{
if(FCar[i][fID]==0&&FCar[i][fDBID]==0)
{
fAuto=i;
return fAuto;
}
}
return fAuto;
}
stock getFreeFraktAutoDBid()
{
new pAuto,maxautos,query[256];
format(query,sizeof(query),"SELECT id FROM FraktionsCars ORDER by id DESC");
mysql_function_query(dbhandle,query,false,"","");
mysql_store_result();
if(mysql_num_rows()>0)
{
maxautos = cache_get_field_content_int(0,"id",dbhandle);
}
mysql_free_result();
for(new i=1; i<=maxautos+1; i++)
{
format(query,sizeof(query),"SELECT id FROM FraktionsCars WHERE id='%i'",i);
mysql_function_query(dbhandle,query,false,"","");
mysql_store_result();
if(mysql_num_rows()==0)
{
pAuto=i;
return pAuto;
}
}
return pAuto;
}