mysql car load problem [+Rep]
#1

hello guys i'm working in my own mysql car ownership system
but i got big problem cars don't loads

onplayerconnect

pawn Код:
public OnPlayerConnect(playerid)
{
    LoadVehicleForPlayer(playerid);
    return 1;
}
LoadVehicleForPlayer

pawn Код:
stock LoadVehicleForPlayer(playerid)
{
    mysql_function_query(mysql, "SELECT * FROM `pvehicles`", true,"OnPlayerLoadVehicles", ""); // we won't pass any other variables to the callback
    return 1;
}
pawn Код:
forward OnPlayerLoadVehicles(playerid);
public OnPlayerLoadVehicles(playerid)
{
    new
    idx,
    result[256],
    query[128];
    new id,owner,model,col1,col2,Float:sx,Float:sy,Float:sz,Float:sa;
    new name[MAX_PLAYER_NAME], Str[250];
    GetPlayerName(playerid, name, 24);
    mysql_format(mysql, query, sizeof(query), "SELECT * FROM `pvehicles` WHERE `vOwner` = '%s'", name);
    mysql_query(mysql, query, "", "");
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, "p<|>is[24]iiiffff", id, owner, model, col1, col2, sx, sy, sz, sa);
            VehicleInfo[idx][vID] = id;
            VehicleInfo[idx][vOwner] = owner;
            VehicleInfo[idx][vModel] = model;
            VehicleInfo[idx][vColor1] = col1;
            VehicleInfo[idx][vColor2] = col2;
            VehicleInfo[idx][vX] = sx;
            VehicleInfo[idx][vY] = sy;
            VehicleInfo[idx][vZ] = sz;
            VehicleInfo[idx][vA] = sa;
            CreateVehicle(model, sx, sy, sz, sa, col1, col2, -1);
            //SetVehicleNumberPlate(i, str);
            SetVehicleToRespawn(idx);
            idx++; // Now increment our index!
   
        }
    }
    mysql_free_result();
    return 1;
}
//------------------------------------------------------------------------------
plz help
sorry for my bad english
Reply
#2

You never passed playerid to mysql_function_query.The OnPlayerLoadVehicles Callback will be called with random playerid(could be 0 , I am not sure).

You don't need another function to call a function and needn't select all vehicles.Just directly fetch the player's vehicles.

Код:
public OnPlayerConnect(playerid)
{
   static query[128];
   mysql_format(mysql, query, sizeof(query), "SELECT * FROM `pvehicles` WHERE `vOwner` = '%s'", name);
   mysql_function_query(mysql, query, true,"OnPlayerLoadVehicles", "i",playerid);
   return 1;
}
Use the same OnPlayerLoadVehicles callback(the one which you have).
Reply
#3

Quote:
Originally Posted by Yashas
Посмотреть сообщение
You never passed playerid to mysql_function_query.The OnPlayerLoadVehicles Callback will be called with random playerid(could be 0 , I am not sure).

You don't need another function to call a function and needn't select all vehicles.Just directly fetch the player's vehicles.

Код:
public OnPlayerConnect(playerid)
{
   static query[128];
   mysql_format(mysql, query, sizeof(query), "SELECT * FROM `pvehicles` WHERE `vOwner` = '%s'", name);
   mysql_function_query(mysql, query, true,"OnPlayerLoadVehicles", "i",playerid);
   return 1;
}
Use the same OnPlayerLoadVehicles callback(the one which you have).
the same it don't load anything
plz help
Reply
#4

help!
Reply
#5

plz help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)