Car Sys
#1

Okay I am using Underground RP and I am making 0.3c so I am wanting to set it so when a player changes there License Plate it saves so when they re connect it will still be there?

The Save Car Function
pawn Код:
public SaveCar(vehicleid)
{
    printf("Updating Car (%d)...", vehicleid);
    new query[1024];
    format(query, sizeof(query), "UPDATE cars SET modelid=%d,x=%f,y=%f,z=%f,o=%f,color1=%d,color2=%d,owner='%s',value=%d,familyid=%d,typeid=%d,gangid=%d,locked=%d,alarm=%d,engine=%d,ticket=%d,warn=%d,fuel=%d,drugs=%d,money=%d,mats=%d,owned=%d, mod1=%d, mod2=%d, mod3=%d, mod4=%d, mod5=%d, mod6=%d, mod7=%d, mod8=%d, mod9=%d, mod10=%d, mod11=%d, mod12=%d, paintjob=%d, destroyed=%d, gun1=%d, gun2=%d, gun3=%d, ammo1=%d, ammo2=%d, ammo3=%d, fueltype=%d plate=%s WHERE carid=%d",
    VehicleInfo[vehicleid][cModel],//
    VehicleInfo[vehicleid][cLocationx],//
    VehicleInfo[vehicleid][cLocationy],//
    VehicleInfo[vehicleid][cLocationz],//
    VehicleInfo[vehicleid][cAngle],//
    VehicleInfo[vehicleid][cColorOne],//
    VehicleInfo[vehicleid][cColorTwo],//
    VehicleInfo[vehicleid][cOwner],//
    VehicleInfo[vehicleid][cValue],//
    VehicleInfo[vehicleid][cFamily],
    VehicleInfo[vehicleid][cType],
    VehicleInfo[vehicleid][cGang],
    VehicleInfo[vehicleid][cLock],
    VehicleInfo[vehicleid][cAlarm],
    VehicleInfo[vehicleid][cStarted],
    VehicleInfo[vehicleid][cTicket],
    VehicleInfo[vehicleid][cWarn],
    VehicleInfo[vehicleid][cGas],
    VehicleInfo[vehicleid][cDrugs],
    VehicleInfo[vehicleid][cMoney],
    VehicleInfo[vehicleid][cMaterials],
    VehicleInfo[vehicleid][cOwned],
    VehicleInfo[vehicleid][mod1],
    VehicleInfo[vehicleid][mod2],
    VehicleInfo[vehicleid][mod3],
    VehicleInfo[vehicleid][mod4],
    VehicleInfo[vehicleid][mod5],
    VehicleInfo[vehicleid][mod6],
    VehicleInfo[vehicleid][mod7],
    VehicleInfo[vehicleid][mod8],
    VehicleInfo[vehicleid][mod9],
    VehicleInfo[vehicleid][mod10],
    VehicleInfo[vehicleid][mod11],
    VehicleInfo[vehicleid][mod12],
    VehicleInfo[vehicleid][paintjob],
    VehicleInfo[vehicleid][destroyed],
    VehicleInfo[vehicleid][cGun1],
    VehicleInfo[vehicleid][cGun2],
    VehicleInfo[vehicleid][cGun3],
    VehicleInfo[vehicleid][cAmmo1],
    VehicleInfo[vehicleid][cAmmo2],
    VehicleInfo[vehicleid][cAmmo3],
    VehicleInfo[vehicleid][cFuelType],
    VehicleInfo[vehicleid][cPlate],
    vehicleid );
    printf(" SQL: %s",query);
    samp_mysql_query(query);
    return true;
}
Here is the Save Car Function
pawn Код:
public LoadCar() {
    IsDatabaseConnected();
    new sql[64], car[45][64], row[255];

    format(sql, sizeof(sql), "SELECT COUNT(*) FROM cars");
    samp_mysql_query(sql);
    samp_mysql_store_result();
    samp_mysql_fetch_row(row);
    totalcars = strvalEx(row);
    samp_mysql_free_result();
    for (new i=1; i<=totalcars; i++)
    {
    format(sql, sizeof(sql), "SELECT * FROM cars WHERE carid=%d", i);
    samp_mysql_query(sql);
    samp_mysql_store_result();
    samp_mysql_fetch_row(row);
    split(row, car, '|');
    samp_mysql_free_result();
//  carid = strvalEx(fields[0]);
    VehicleInfo[i][cModel] = strvalEx(car[1]);
    VehicleInfo[i][cLocationx] = floatstr(car[2]);
    VehicleInfo[i][cLocationy] = floatstr(car[3]);
    VehicleInfo[i][cLocationz] = floatstr(car[4]);
    VehicleInfo[i][cAngle] = floatstr(car[5]);
    VehicleInfo[i][cColorOne] = strvalEx(car[6]);
    VehicleInfo[i][cColorTwo] = strvalEx(car[7]);
    strmid(VehicleInfo[i][cOwner], car[8], 0, strlen(car[8]), 255);
    VehicleInfo[i][cValue] = strvalEx(car[9]);
    VehicleInfo[i][cFamily] =  strvalEx(car[10]);
    VehicleInfo[i][cType] = strvalEx(car[11]);
    VehicleInfo[i][cGang] = strvalEx(car[12]);
    VehicleInfo[i][cLock] = strvalEx(car[13]);
    VehicleInfo[i][cAlarm] = strvalEx(car[14]);
    VehicleInfo[i][cStarted] = strvalEx(car[15]);
    VehicleInfo[i][cTicket] = strvalEx(car[16]);
    VehicleInfo[i][cWarn] = strvalEx(car[17]);
    VehicleInfo[i][cGas] = strvalEx(car[18]);
    VehicleInfo[i][cDrugs] = strvalEx(car[19]);
    VehicleInfo[i][cMoney] = strvalEx(car[20]);
    VehicleInfo[i][cMaterials] = strvalEx(car[21]);
    VehicleInfo[i][cOwned] = strvalEx(car[22]);
    VehicleInfo[i][mod1] = strvalEx(car[23]);
    VehicleInfo[i][mod2] = strvalEx(car[24]);
    VehicleInfo[i][mod3] = strvalEx(car[25]);
    VehicleInfo[i][mod4] = strvalEx(car[26]);
    VehicleInfo[i][mod5] = strvalEx(car[27]);
    VehicleInfo[i][mod6] = strvalEx(car[28]);
    VehicleInfo[i][mod7] = strvalEx(car[29]);
    VehicleInfo[i][mod8] = strvalEx(car[30]);
    VehicleInfo[i][mod9] = strvalEx(car[31]);
    VehicleInfo[i][mod10] = strvalEx(car[32]);
    VehicleInfo[i][mod11] = strvalEx(car[33]);
    VehicleInfo[i][mod12] = strvalEx(car[34]);
    VehicleInfo[i][paintjob] = strvalEx(car[35]);
    VehicleInfo[i][destroyed] = strvalEx(car[36]);
    VehicleInfo[i][cGun1] = strvalEx(car[37]);
    VehicleInfo[i][cGun2] = strvalEx(car[38]);
    VehicleInfo[i][cGun3] = strvalEx(car[39]);
    VehicleInfo[i][cAmmo1] = strvalEx(car[40]);
    VehicleInfo[i][cAmmo2] = strvalEx(car[41]);
    VehicleInfo[i][cAmmo3] = strvalEx(car[42]);
    VehicleInfo[i][cFuelType] = strvalEx(car[43]);
    VehicleInfo[i][cPlate] = strvalEx(car[44]);
    if (carsreloaded==0) AddStaticVehicleEx(VehicleInfo[i][cModel], VehicleInfo[i][cLocationx], VehicleInfo[i][cLocationy], VehicleInfo[i][cLocationz]+0.3, VehicleInfo[i][cAngle], VehicleInfo[i][cColorOne], VehicleInfo[i][cColorTwo], 2500000);
        else CarRespawn(i);
    }
    carsreloaded++;
    format(row, sizeof(row), "LoadSQLCars(): %d cars loaded", totalcars);
    printf(row);
}
Also here is the Table Database
PHP код:
CREATE TABLE IF NOT EXISTS `cars` (
  `
caridint(11NOT NULL AUTO_INCREMENT,
  `
modelidint(11NOT NULL,
  `
xfloat NOT NULL,
  `
yfloat NOT NULL,
  `
zfloat NOT NULL,
  `
ofloat NOT NULL,
  `
color1int(11NOT NULL,
  `
color2int(11NOT NULL,
  `
ownerchar(32NOT NULL DEFAULT 'Dealer',
  `
valueint(11NOT NULL,
  `
familyidint(11NOT NULL,
  `
typeidint(11NOT NULL,
  `
gangidint(11NOT NULL,
  `
lockedint(11NOT NULL,
  `
alarmint(11NOT NULL,
  `
engineint(11NOT NULL,
  `
ticketint(11NOT NULL,
  `
warnint(11NOT NULL,
  `
fuelint(11NOT NULL,
  `
drugsint(11NOT NULL,
  `
moneyint(11NOT NULL,
  `
matsint(11NOT NULL,
  `
ownedint(11NOT NULL,
  `
mod1int(11NOT NULL DEFAULT '0',
  `
mod2int(11NOT NULL DEFAULT '0',
  `
mod3int(11NOT NULL DEFAULT '0',
  `
mod4int(11NOT NULL DEFAULT '0',
  `
mod5int(11NOT NULL DEFAULT '0',
  `
mod6int(11NOT NULL DEFAULT '0',
  `
mod7int(11NOT NULL DEFAULT '0',
  `
mod8int(11NOT NULL DEFAULT '0',
  `
mod9int(11NOT NULL DEFAULT '0',
  `
mod10int(11NOT NULL DEFAULT '0',
  `
mod11int(11NOT NULL DEFAULT '0',
  `
mod12int(11NOT NULL DEFAULT '0',
  `
paintjobint(11NOT NULL DEFAULT '-1',
  `
destroyedint(11NOT NULL DEFAULT '0',
  `
gun1int(3NOT NULL DEFAULT '0',
  `
gun2int(3NOT NULL DEFAULT '0',
  `
gun3int(3NOT NULL DEFAULT '0',
  `
ammo1int(6NOT NULL DEFAULT '0',
  `
ammo2int(6NOT NULL DEFAULT '0',
  `
ammo3int(6NOT NULL DEFAULT '0',
  `
fueltypeint(3NOT NULL DEFAULT '1',
  `
platechar(6NOT NULL,
  
PRIMARY KEY (`carid`)
ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=715 
But it not saving or Loading?
Reply
#2

You query is way too long, try to make it in parts.
Also, check your SQL log for any errors.
Reply
#3

What DVDK said, make it into parts or it can be bugged.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)