MySQL vehicle ID problem.
#1

I'll try to explain this problem to best of my ability, basically I have a command '/acar create < model id / model name.'
This inserts a new row in to the MySQL table `VehicleInfo` (a new vehicle). Once this has finished querying, I then send a new query to the database, getting the data from it and then spawning the vehicle. Although, during testing I created 6 vehicles then empty'd the table but when I go in to the server and create another new vehicle it's registering the ID as 7 instead of 1 again (Note: 1 - 6 vehicle ID's nolonger exist within the table)

I also stopped the server then empty'd the table.

Here is some code:

Command:
PHP код:
if(!strcmp(iParams"create"true6)) {
        if(
PlayerInfo[playerid][aAdmin] < 4) return SendError(playeridCANT_USE_CMD);
        if(!
strlen(iParamsEx)) return SCP(playerid"/acar create""< model / id >");
        new 
slctedID;
        if(!
IsNumeric(iParamsEx)) slctedID ModelFromName(iParamsEx);
        else 
slctedID strval(iParamsEx);
        if(
slctedID 400 || slctedID 611) return SCP(playerid"/acar create""< model / id >");
        new 
Float:playerXFloat:playerYFloat:playerZFloat:playerA;
        
GetPlayerPos(playeridplayerXplayerYplayerZ);
        
GetPlayerFacingAngle(playeridplayerA);
        
CreateNewVehicle(PlayerName(playerid), slctedIDplayerXplayerYplayerZplayerA);
        new 
iFormat[159];
        
format(iFormatsizeof(iFormat), "(( AdmCmd | {CCCCCC}You have successfully created a new vehicle: %s! {D13F3F}))"VehicleName[slctedID 400]);
        
SendPlayerMessage(playerid0xD13F3FFFiFormat"(( AdmCmd | {CCCCCC}");
        return 
1;
    } 
CreateNewVehicle function
PHP код:
stock CreateNewVehicle(vehOwner[], vehModelFloat:vehXFloat:vehYFloat:vehZFloat:vehAvVW 0rRes VEHICLE_OWNED) {
    new 
iQuery[450];
    
mysql_format(PipelineiQuerysizeof(iQuery), "INSERT INTO `VehicleInfo` (`Owner`, `Model`, `X`, `Y`, `Z`, `A`, `VirtualWorld`, `Type`) VALUES ('%e', %d, %f, %f, %f, %f, %d, %d)"vehOwnervehModelvehXvehYvehZvehAvVWrRes);
    
mysql_tquery(PipelineiQuery"OnVehicleCreation");

OnVehicleCreation
PHP код:
public OnVehicleCreation() {
    new 
vehicleid cache_insert_id();
    
printf("[ON VEHICLE CREATE] %d has been created successfully!"vehicleid);
    new 
iQuery[159]; mysql_format(PipelineiQuerysizeof(iQuery), "SELECT * FROM `VehicleInfo` WHERE `ID` = %d LIMIT 1"vehicleid);
    
mysql_tquery(PipelineiQuery"OnLoadVehicles""d"0);
    return 
1;

Reply


Messages In This Thread
MySQL vehicle ID problem. - by Bwandon - 22.05.2017, 15:19
Re: MySQL vehicle ID problem. - by Vince - 22.05.2017, 15:28
Re: MySQL vehicle ID problem. - by Bwandon - 22.05.2017, 15:33
Re: MySQL vehicle ID problem. - by DobbysGamertag - 22.05.2017, 17:42

Forum Jump:


Users browsing this thread: 1 Guest(s)