Mysql putting info in the Wrong place -
MCZOFT - 13.01.2015
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 код:
Onplayerupdate( value 4 this one )
.
.
.
mysql_format(dbhandle, query, sizeof 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],
0, CarInfo[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(dbhandle, query, using CarHandler, "");
here is a picture when im doing the command
here is the command apark
PHP код:
YCMD:apark(playerid, params[], help)
{
if(help) return SCM(playerid, COLOR_GREY, "Not supported");
if(IsPlayerConnected(playerid))
{
new Float:x,Float:y,Float:z,Float:a,carid,string[256];
carid = GetPlayerVehicleID(playerid);
GetVehiclePos(carid, x, y, z);
GetVehicleZAngle(carid, a);
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(string, sizeof(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.", 10000, 3);
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(carid, CarInfo[carid][cPaintjob]);
}
SetVehicleModifications(carid);
PutPlayerInVehicle(playerid, carid, 0);
new lights, alarm, doors, bonnet, boot, objective;
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, alarm, doors, bonnet, boot, objective);
engineOn[GetPlayerVehicleID(playerid)] = true;
TogglePlayerControllable(playerid, 1);
return 1;
}
else
{
SCM(playerid, COLOR_GREY, "* You can only do this on ownable cars!");
return 1;
}
}
else
{
SCM(playerid, COLOR_GREY, "* You are not authorized to use that command !");
return 1;
}
}
return 1;
}
Re: Mysql putting info in the Wrong place -
donsta3000 - 13.01.2015
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.
Re: Mysql putting info in the Wrong place -
Vince - 13.01.2015
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.
Re : Mysql putting info in the Wrong place -
MCZOFT - 13.01.2015
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 .... ,
Re: Re : Mysql putting info in the Wrong place -
Vince - 13.01.2015
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.
Re : Mysql putting info in the Wrong place -
MCZOFT - 13.01.2015
i'll see what i can do , and i'll post a reply
Re : Mysql putting info in the Wrong place -
MCZOFT - 14.01.2015
Fixed, thaks anyway Vince