MySQL saving problem
#1

Hi so, when I am parking my car /carpark, it doesn't update it for some reason, I can't see why


Here's the logs:

PHP код:
[17:32:21] [DEBUGmysql_format connection1len200format"UPDATE `vehicles` SET vX=%f, vY=%f, vZ=%f, vA=%f WHERE ID=%d"
[17:32:21] [DEBUGmysql_tquery connection1query"UPDATE `vehicles` SET vX=-1989.818, vY=257.565, vZ=34.771, vA=28"callback"(null)"format"(null)"
[17:32:21] [DEBUGCMySQLQuery::Execute[] - starting query execution
[17:32:21] [DEBUGCMySQLQuery::Execute[] - query was successfully executed within 0.220 milliseconds
[17:32:21] [DEBUGCMySQLQuery::Execute[] - no callback specifiedskipping result saving 
Here's the command with the saving part:

PHP код:
CMD:carpark(playeridparams[])
{
    new 
FloatxFloatyFloatzFloatavehicleid GetPlayerVehicleID(playerid), query[200];
    if(!
IsPlayerInAnyVehicle(playerid))
        return 
SendErrorMessage(playerid"You're not in a vehicle!");
    if(
Player[playerid][VehSlot1] == vehicleid || Player[playerid][VehSlot2] == vehicleid -  1)
    {
        
GetVehiclePos(vehicleidxyz);
        
GetVehicleZAngle(vehicleida);
        
SendInfoMessage(playerid"You have parked your vehicle.");
        
mysql_format(mysqlquerysizeof(query), "UPDATE `vehicles` SET vX=%f, vY=%f, vZ=%f, vA=%f WHERE ID=%d"xyzavehicleid);
        
mysql_tquery(mysqlquery);
        new 
model GetVehicleModel(vehicleid);
        
DestroyVehicle(vehicleid);
        
CreateVehicle(modelxyzaVehicle[vehicleid -1][Color1], Vehicle[vehicleid -1][Color2], -1);
        
PutPlayerInVehicle(playeridvehicleid0);
    }
    else return 
SendErrorMessage(playerid"You don't own this vehicle!");
    return 
true;

It has to be something with that:
PHP код:
[17:32:21] [DEBUGCMySQLQuery::Execute[] - no callback specifiedskipping result saving 
Any idea why?
Reply
#2

Ok so No callback specified is totally normal, so it's not because of that, I can't see what the problem is, why can't I update the v pos
Reply
#3

Hello there,

You should be subtracting 1 from "vehicleid" in all actions.

pawn Код:
CMD:carpark(playerid, params[])
{
    new Float: x, Float: y, Float: z, Float: a, vehicleid = (GetPlayerVehicleID(playerid) - 1), query[200];

    if(!IsPlayerInAnyVehicle(playerid))
        return SendErrorMessage(playerid, "You're not in a vehicle!");

    if(Player[playerid][VehSlot1] == vehicleid || Player[playerid][VehSlot2] == vehicleid)
    {
        GetVehiclePos(vehicleid, x, y, z);
        GetVehicleZAngle(vehicleid, a);

        SendInfoMessage(playerid, "You have parked your vehicle.");

        mysql_format(mysql, query, sizeof(query), "UPDATE `vehicles` SET vX=%f, vY=%f, vZ=%f, vA=%f WHERE ID=%d", x, y, z, a, vehicleid);
        mysql_tquery(mysql, query);

        new model = GetVehicleModel(vehicleid);

        DestroyVehicle(vehicleid);
        CreateVehicle(model, x, y, z, a, Vehicle[vehicleid -1][Color1], Vehicle[vehicleid -1][Color2], -1);
        PutPlayerInVehicle(playerid, vehicleid, 0);
    }

    else return SendErrorMessage(playerid, "You don't own this vehicle!");

    return true;
}
Assumed from this part: if(Player[playerid][VehSlot1] == vehicleid - 1 || Player[playerid][VehSlot2] == vehicleid - 1). Let me know if it worked or not.
Reply
#4

Not working, it will respawn the wrong car and the pos didn't save either.
Reply
#5

Quote:
Originally Posted by vernz
Посмотреть сообщение
Not working, it will respawn the wrong car and the pos didn't save either.
Then the ID of the entry you're trying to update is most likely wrong. Look into getting the correct handle ID.

By the way, in the code I posted, I forgot to remove the subtractions from it: "CreateVehicle(model, x, y, z, a, Vehicle[vehicleid -1][Color1], Vehicle[vehicleid -1][Color2], -1);". See if it still spawns the wrong vehicle by using: "CreateVehicle(model, x, y, z, a, Vehicle[vehicleid][Color1], Vehicle[vehicleid][Color2], -1);". If so, look into getting the correct handle ID as I've mentioned before.
Reply
#6

When I park the car, it respawn at the correct pos where I parked it so it's not the problem, and with that, it spawn the wrong car
Reply
#7

Quote:
Originally Posted by vernz
Посмотреть сообщение
When I park the car, it respawn at the correct pos where I parked it so it's not the problem, and with that, it spawn the wrong car
It spawns the car at the correct position because of this:

pawn Код:
GetVehiclePos(vehicleid, x, y, z);
It's logical that it will.

As you have mentioned that it spawns the wrong car, then the problem is that you're using the wrong handle ID (vehicleid). You should save the SQL ID of the vehicles in the array and use that instead.
Reply
#8

Not quite sure what you mean
Reply
#9

Quote:
Originally Posted by vernz
Посмотреть сообщение
Not quite sure what you mean
ID=%d", x, y, z, a, vehicleid

%d, vehicleid = wrong ID in table
Reply
#10

I don't own this vehicle works properly when I am actually not the owner and when I am, it also works so the id is supposed to be good
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)