Mysql Error
#1

I have dynamic vehicle system on mysql but when i try to create a vehicle with this command:
pawn Код:
CMD:vcreate(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be admin to use this command!");

    new
        Float:Pos[4],
        ivModel,
        ivPrice,
        type,
        ivColors[2],
        Query[300],
        iMsg[148];

    if(sscanf(params, "iiiii", ivModel, ivPrice, ivColors[0], ivColors[1],type)) return SendClientMessage(playerid, -1, ""#CRED"Usage: "#CORANGE"/VCreate < Vehicle Model > < Price > < Color 1 > < Color 2 > < Type >");

    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    GetPlayerFacingAngle(playerid, Pos[3]);

    ++ Total_Veh_Created;

    vInfo[Total_Veh_Created][vModel]    = ivModel;
    vInfo[Total_Veh_Created][vColor1]   = ivColors[0];
    vInfo[Total_Veh_Created][vColor2]   = ivColors[1];
    vInfo[Total_Veh_Created][vPrice]    = ivPrice;
    vInfo[Total_Veh_Created][vPosX]     = Pos[0];
    vInfo[Total_Veh_Created][vPosY]     = Pos[1];
    vInfo[Total_Veh_Created][vPosZ]     = Pos[2];
    vInfo[Total_Veh_Created][vPosA]     = Pos[3];
    strmid(vInfo[Total_Veh_Created][vOwner], "Unbought", 0, 20, 20);
    strmid(vInfo[Total_Veh_Created][vPlate], "ChangeME", 0, 32, 32);
    vInfo[Total_Veh_Created][vPaintJ]   = 0;
    vInfo[Total_Veh_Created][vLocked]   = 1;
    vInfo[Total_Veh_Created][vForFact]  = 0;
    vInfo[Total_Veh_Created][vFact]   = 0;
    vInfo[Total_Veh_Created][vType]   = type;
    for(new i = 0; i < MAX_VEH_MODS; ++i) vMods[Total_Veh_Created][i] = 0;
    format(Query, sizeof(Query), "INSERT INTO `privateveh` (`vID`, `vModel`, `vColor1`, `vColor2`, `vPrice`, `vOwner`, `vPosX`, `vPosY`, `vPosZ`, `vPosA`, `vPlate`, `vPaintJ`, `vForFact`, `vFact`, `vType`) VALUES (%d, %d, %d, %d, %d, 'Unbought', %f, %f, %f, %f, 'ChangeME', 0,0,0,%d)",
    Total_Veh_Created,
    ivModel,
    ivColors[0],
    ivColors[1],
    ivPrice,
    Pos[0],
    Pos[1],
    Pos[2],
    Pos[3],
    type);
    mysql_query(Query);
    new cCar = CreateVehicle(ivModel, Pos[0], Pos[1], Pos[2], Pos[3], ivColors[0], ivColors[1], 500000);
    SetVehicleNumberPlate(cCar, "ChangeME");
    OwnedVeh(cCar) = Total_Veh_Created;
    SavePrivVeh(Total_Veh_Created);
    format(iMsg, sizeof(iMsg), ""#CYELLOW"Vehicle: "#CBLUE"%i (VID: %i) "#CYELLOW"has been created. Price: "#CBLUE"$%i "#CYELLOW"Plate: "#CBLUE"ChangeME", ivModel, Total_Veh_Created, ivPrice);
    SendClientMessage(playerid, -1, iMsg);
    return 1;
}
mysql gives me this error
Код:
[13:52:08] CMySQLHandler::Query(INSERT INTO `privateveh` (`vID`, `vModel`, `vColor1`, `vColor2`, `vPrice`, `vOwner`, `vPosX`, `vPosY`, `vPosZ`, `vPosA`, `vPlate`, `vPaintJ`, `vForFact`, `vFact`, `vType`) VALUES (107, 560, 0, 0, 0, 'Unbought', 1081.714843, -310.938781, 73.992187, 291.462707, 'ChangeME', 0,0,0,4)) - An error has occured. (Error ID: 1062, Duplicate entry '107' for key 'vID')
Reply
#2

vID is probably set to primary Key, Could you please paste the definition of the table? (make sure it's AUTO_INCREMENT)
Reply
#3

Quote:
Originally Posted by Kitten
Посмотреть сообщение
vID is probably set to primary Key, Could you please paste the definition of the table? (make sure it's AUTO_INCREMENT)
You mean this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)