30.09.2010, 14:39
ok, This is my savevehicles, Now when you type a command and you don't have that car, It inserts it in to the database, Now when you go to buy vehicle 2 it should do the same thing but it's not calling the insert funcition
It updates it if it exists and inserts it if it don't. How can i make this work
pawn Код:
forward SaveVehicles(playerid, car);
public SaveVehicles(playerid, car)
{
new string[512];
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, sizeof(plname));
if(i dunno what to put here)
{
format(string, sizeof(string),"UPDATE vehicles SET vModel=%d,ParkX='%f',ParkY='%f',ParkZ='%f',ParkA='%f',Color1=%d,Color2=%d,VehicleOwner='%s',VehicleDescription='%s',Owned=%d,Locked=%d,LockBought=%d,RentPrice=%d,Alarm=%d,VehKey=%d WHERE CarId ='%d'",
VehicleInfo[car][vModel],
VehicleInfo[car][vX],
VehicleInfo[car][vY],
VehicleInfo[car][vZ],
VehicleInfo[car][vAngle],
VehicleInfo[car][vColorOne],
VehicleInfo[car][vColorTwo],
plname,
VehicleInfo[car][vDescription],
VehicleInfo[car][vOwned],
VehicleInfo[car][vLock],
VehicleInfo[car][vLockBuyed],
VehicleInfo[car][vRentPrice],
VehicleInfo[car][vAlarm],
VehicleInfo[car][vKey],
VehicleInfo[car][vCarId]);
mysql_query(string);
printf("%s",string);
format(string, sizeof(string),"UPDATE vehicles SET Component0=%d,Component1=%d,Component2=%d,Component3=%d,Component4=%d,Component5=%d,Component6=%d,Component7=%d,Component8=%d,Component9=%d,Component10=%d,Component11=%d,Component12=%d,Component13=%d,PaintJob=%d,Insurance=%d,Scratches=%d WHERE CarId ='%d'",
VehicleInfo[car][vComponent0],
VehicleInfo[car][vComponent1],
VehicleInfo[car][vComponent2],
VehicleInfo[car][vComponent3],
VehicleInfo[car][vComponent4],
VehicleInfo[car][vComponent5],
VehicleInfo[car][vComponent6],
VehicleInfo[car][vComponent7],
VehicleInfo[car][vComponent8],
VehicleInfo[car][vComponent9],
VehicleInfo[car][vComponent10],
VehicleInfo[car][vComponent11],
VehicleInfo[car][vComponent12],
VehicleInfo[car][vComponent13],
VehicleInfo[car][vPaintJob],
VehicleInfo[car][vInsurances],
VehicleInfo[car][vScratches],
VehicleInfo[car][vCarId]);
mysql_query(string);
//,Component0=%d,Component1=%d,Component2=%d,Component3=%d,Component4=%d,Component5=%d,Component6=%d,Component7=%d,Component8=%d,Component9=%d,Component10=%d,Component11=%d,Component12=%d,Component13=%d,PaintJob=%d,Insurance=%d,Scratches=%d
printf("%s",string);
}
else
{
new Query[512];
format(Query, sizeof(Query), "INSERT INTO vehicles (vModel,ParkX,ParkY,ParkZ,ParkA,Color1,Color2,VehicleOwner,VehicleDescription,Owned,Locked,LockBought,RentPrice,Alarm,VehKey,PaintJob,Insurance,Scratches) VALUES ('%d','%f','%f','%f','%f','%d','%d','%s','%s','%d','%d','%d','%d','%d','%d','%d','%d','%d')",
//VehicleInfo[car][vCarId],
VehicleInfo[car][vModel],
VehicleInfo[car][vX],
VehicleInfo[car][vY],
VehicleInfo[car][vZ],
VehicleInfo[car][vAngle],
VehicleInfo[car][vColorOne],
VehicleInfo[car][vColorTwo],
plname,
VehicleInfo[car][vDescription],
VehicleInfo[car][vOwned],
VehicleInfo[car][vLock],
VehicleInfo[car][vLockBuyed],
VehicleInfo[car][vRentPrice],
VehicleInfo[car][vAlarm],
VehicleInfo[car][vKey],
VehicleInfo[car][vPaintJob],
VehicleInfo[car][vInsurances],
VehicleInfo[car][vScratches]);
mysql_query(Query);
printf("%s",Query);
}
return 1;
}