• 04 Juillet 2025, 16:15:11


Auteur Sujet: mysql vehicule systeme  (Lu 1129 fois)

0 Membres et 1 Invité sur ce sujet

Hors ligne karimos

  • *
  • Nouveau
  • Messages: 15
    • Voir le profil
mysql vehicule systeme
« le: 04 Janvier 2012, 16:23:32 »
bonjours je suis entrain de creer un nouveau systeme de vehicule avec mysql j'ai deja fait le load et creation mais au niveau du save je suis bloqué

voici ma base de donne

id _ auto increment
model
price
col1
col2
secured
x
y
z
a

quand je veut changer la valeur du prix du vehicule par exemple
je fait GetPlayerVehicleID(); mais je me suis apercu que si je supprimais une champs de la table sa ne marcherais plus donc je cherche une solution pour avoir l'id du vehicule dans la base de donnes

voici les bout de code

enum vInfoE
{
     id,
     owner[25],
     model,
     price,
col[2],
secured,
     Float:pos[4],
}
new VehicleInfo[MAX_VEHICLES][vInfoE];

stock LoadVehicles() // You might want to make this an public so you could call it on an timer.
{
    new query[255];
    for(new i = 1; i < MAX_VEHICLES; i++) // Makes an loop so all vehicles get loaded.
    {
        format(query, sizeof(query), "SELECT * FROM vehicles WHERE id= %d", i);
        mysql_query(query); // Querys the "Query" Variable.
        mysql_store_result(); // Stores the result from Query
        if(mysql_num_rows() == 0){ continue; } // Checks if theres anyrow.
mysql_fetch_row_format(query, "|");
sscanf(query, "e<p<|>is[25]iiiffff>", VehicleInfo[i]);
        new str[128];
format(str,sizeof(str),"veh %s",VehicleInfo[i][owner]);
print(str);
        CreateVehicle(VehicleInfo[i][model],VehicleInfo[i][pos][0],VehicleInfo[i][pos][1],VehicleInfo[id][pos][2],VehicleInfo[i][pos][3],VehicleInfo[i][col][0],VehicleInfo[i][col][1], 10);
}


CMD:vcreate(playerid, params[]) // Create vehicle command, not Tested.
{
    new vmodel,vcol1,vcol2,Query[200];
    if(sscanf(params, "iii", vmodel,vcol1,vcol2)) return SendClientMessage(playerid, COLOR_ADMIN, "Usage: /vreate [Model] [col1] [col2]");
    new Float:pPOS[4];
    GetPlayerPos(playerid, pPOS[0], pPOS[1], pPOS[2]);
    GetPlayerFacingAngle(playerid , pPOS[3]);
    format(Query, sizeof(Query), "INSERT INTO vehicles (owner, model, price, col1, col2, secured, x, y, z, a) VALUES ('%s', %d, %d, %d, %d, 0, %f, %f, %f, %f);",DEFAULT_VEHICLE_OWNER, vmodel, DEFAULT_SELL_PRICE, vcol1, vcol2, pPOS[0], pPOS[1], pPOS[2], pPOS[3]);
    mysql_query(Query);
    CreateVehicle(vmodel,pPOS[0],pPOS[1],pPOS[2],pPOS[3],vcol1,vcol2,10);
    format(Query, sizeof(Query), "Created an %d at x: %f y: %f z: %f a: %f);",vmodel ,pPOS[0], pPOS[1], pPOS[2], pPOS[3]);
    SendClientMessage(playerid, COLOR_ADMIN, Query);
    return 1;
}