Mysql putting info in the Wrong place
#1

Hello ,

directly : after im doing the command /apark , it destroyes the vehicle and it never come back till i'll relog ( i will find the car in the last position before i'll do apark)


here is the update of mysql


PHP код:
Onplayerupdatevalue 4 this one 
.
.
.
mysql_format(dbhandlequerysizeof query"INSERT INTO vehicles VALUES (%d, %d, %.2f, %.2f, %.2f, %.2f, %d, %d, %d, '%e', %d, %d, %d, %d, '%e') \
        ON DUPLICATE KEY UPDATE    id = LAST_INSERT_ID(id), model = VALUES(model), "
,
        
CarInfo[idx][cdbID], CarInfo[idx][cModel], CarInfo[idx][cLocationx],    CarInfo[idx][cLocationy],
        
CarInfo[idx][cLocationz], CarInfo[idx][cAngle], CarInfo[idx][cColorOne], CarInfo[idx][cColorTwo],
        
0CarInfo[idx][cOwner], CarInfo[idx][cLock], CarInfo[idx][cPaintjob], CarInfo[idx][cVirWorld], CarInfo[idx][cCode], CarInfo[idx][cPlate]);
strcat(query"locX = VALUES(locX), \
        locY = VALUES(locY), locZ = VALUES(locZ), angle = VALUES(angle), \
        color1 = VALUES(color1), color2 = VALUES(color2), ownerId = VALUES(ownerId), \
        owner = VALUES(owner),\
        locked = VALUES(locked), paintjob = VALUES(paintjob), \
        virtualworld = VALUES(virtualworld), code = VALUES(code), plate = VALUES(plate)"
);
        
mysql_tquery_inline(dbhandlequeryusing CarHandler""); 
here is a picture when im doing the command




here is the command apark

PHP код:
YCMD:apark(playeridparams[], help)
{
    if(
help) return SCM(playeridCOLOR_GREY"Not supported");
    if(
IsPlayerConnected(playerid))
    {
        new 
Float:x,Float:y,Float:z,Float:a,carid,string[256];
        
carid GetPlayerVehicleID(playerid);
        
GetVehiclePos(caridxyz);
        
GetVehicleZAngle(carida);
        if(
PlayerInfo[playerid][pAdmin] >= 1)
        {
            if(
IsAnOwnableCar(carid))
            {
                
CarInfo[carid][cLocationx] = x;
                
CarInfo[carid][cLocationy] = y;
                
CarInfo[carid][cLocationz] = z;
                
CarInfo[carid][cAngle] = a;
                
format(stringsizeof(string), "~n~ You have parked your car in this location. ~n~");
                
GameTextForPlayer(playerid"You have parked this car in this position. It will respawn here."100003);
                
OnPropUpdate(4,carid);
                
DestroyVehicle(carid);
                
ownedcar[carid] = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
                if(
CarInfo[carid][cPaintjob] != 999)
                {
                    
ChangeVehiclePaintjob(caridCarInfo[carid][cPaintjob]);
                }
                
SetVehicleModifications(carid);
                
PutPlayerInVehicle(playeridcarid0);
                new 
lightsalarmdoorsbonnetbootobjective;
                
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1lightsalarmdoorsbonnetbootobjective);
                  
engineOn[GetPlayerVehicleID(playerid)] = true;
                  
TogglePlayerControllable(playerid1);
                return 
1;
            }
            else
            {
                
SCM(playeridCOLOR_GREY"* You can only do this on ownable cars!");
                return 
1;
            }
        }
        else
        {
            
SCM(playeridCOLOR_GREY"* You are not authorized to use that command !");
            return 
1;
        }
    }
    return 
1;

Reply
#2

Firstly, your English is atrocious so it is very hard to understand the issue. I can't tell if your complaining about the fact that the vehicle is getting destroyed or the MYSQL isn't working properly. I am really failing to understand why you are doing half the things you are in that command, so if you could speak some sense maybe I will be able to help.

Many thanks.
Reply
#3

This doesn't seem like the place to use ON DUPLICATE KEY. It seems like 'id' should be the primary key (and thus a unique value). The primary key's only purpose is to uniquely identify the row in the table. It should have no other purpose or meaning. The primary key should never be changed.
Reply
#4

donsta3000 i dont know why vince understood my problem ... , at least just be quiet and Watch the pro's helping , that's all what you're carrying about ? english , you'll never see me again doing a single mistake .. , so end it here "Teacher of English"

, Vince , it's complicated .. i changed the
PHP код:
 LAST_INSERT_ID(id
to
PHP код:
LAST_INSERT_ID() 
and i got ID of 778 going up , 778 779 .... ,
Reply
#5

Quote:
Originally Posted by MCZOFT
Посмотреть сообщение
i dont know why vince understood my problem ...
Actually I didn't understand anything at all, I was merely looking at the query. I've never needed to use last_insert_id or any of those constructs. The id column should be the primary key and have auto_increment enabled. That way a new unique id is automatically generated when a new row is inserted and you don't have to mess with all these weird constructs.
Reply
#6

i'll see what i can do , and i'll post a reply
Reply
#7

Fixed, thaks anyway Vince
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)