mysql vehicle
#1

hi Im developping a mysql vehicles systeme but im blocked :

there is my code :

PHP код:
new PlayerInfo[MAX_PLAYERS][pInfoE];
enum vInfoE // You could really name this anything.. Foo, pop, vehicle, vehicles whatever you like.
{
     
id,
     
owner[25],
     
model,
     
price,
     
col[2],
     
secured,
     
Float:pos[4],
}
new 
VehicleInfo[MAX_VEHICLES][vInfoE]; 
PHP код:
CMD:vcreate(playeridparams[]) // Create vehicle command, not Tested.
{
    new 
vmodel,vcol1,vcol2,Query[200];
    if(
sscanf(params"iii"vmodel,vcol1,vcol2)) return SendClientMessage(playeridCOLOR_ADMIN"Usage: /vreate [Model] [col1] [col2]");
    new 
Float:pPOS[4];
    
GetPlayerPos(playeridpPOS[0], pPOS[1], pPOS[2]);
    
GetPlayerFacingAngle(playerid pPOS[3]);
    
format(Querysizeof(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_OWNERvmodelDEFAULT_SELL_PRICEvcol1vcol2pPOS[0], pPOS[1], pPOS[2], pPOS[3]);
    
mysql_query(Query);
    
CreateVehicle(vmodel,pPOS[0],pPOS[1],pPOS[2],pPOS[3],vcol1,vcol2,10);
    
format(Querysizeof(Query), "Created an %d at x: %f y: %f z: %f a: %f);",vmodel ,pPOS[0], pPOS[1], pPOS[2], pPOS[3]);
    
SendClientMessage(playeridCOLOR_ADMINQuery);
    return 
1;
}
CMD:vreload(playeridparams[]) // Reload's Vehicles
{
    for(new 
iMAX_VEHICLESi++)
    {
        if (
IsVehicleConnected(i)) return DestroyVehicle(i);
        else { break; }
    }
    
LoadVehicles();
    
SendClientMessage(playeridCOLOR_ADMIN"Vehicle's reloaded");
    return 
1;

PHP код:
stock LoadVehicles() // You might want to make this an public so you could call it on an timer.
{
    new 
query[255];
    for(new 
1MAX_VEHICLESi++) // Makes an loop so all vehicles get loaded.
    
{
        
format(querysizeof(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);
    }

I want change value of enum vehicle but I dont know how can in have id of the vehicle in the database.
I test to do GetPlayerVehicleID(playerid); but when i delete one vehicle in database , it don`t going to work;
so i wanna know how can I have the vehicles id database,
and sorry for bad english
Reply
#2

uppppp
Reply
#3

Show us your table in phpmyadmin.
Reply
#4

there is my table :

id AutoIncrement
owner
model
price
col1
col2
secured
x
y
z
a
Reply


Forum Jump:


Users browsing this thread: