Car Sys -
Luis- - 12.12.2010
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` (
`carid` int(11) NOT NULL AUTO_INCREMENT,
`modelid` int(11) NOT NULL,
`x` float NOT NULL,
`y` float NOT NULL,
`z` float NOT NULL,
`o` float NOT NULL,
`color1` int(11) NOT NULL,
`color2` int(11) NOT NULL,
`owner` char(32) NOT NULL DEFAULT 'Dealer',
`value` int(11) NOT NULL,
`familyid` int(11) NOT NULL,
`typeid` int(11) NOT NULL,
`gangid` int(11) NOT NULL,
`locked` int(11) NOT NULL,
`alarm` int(11) NOT NULL,
`engine` int(11) NOT NULL,
`ticket` int(11) NOT NULL,
`warn` int(11) NOT NULL,
`fuel` int(11) NOT NULL,
`drugs` int(11) NOT NULL,
`money` int(11) NOT NULL,
`mats` int(11) NOT NULL,
`owned` int(11) NOT NULL,
`mod1` int(11) NOT NULL DEFAULT '0',
`mod2` int(11) NOT NULL DEFAULT '0',
`mod3` int(11) NOT NULL DEFAULT '0',
`mod4` int(11) NOT NULL DEFAULT '0',
`mod5` int(11) NOT NULL DEFAULT '0',
`mod6` int(11) NOT NULL DEFAULT '0',
`mod7` int(11) NOT NULL DEFAULT '0',
`mod8` int(11) NOT NULL DEFAULT '0',
`mod9` int(11) NOT NULL DEFAULT '0',
`mod10` int(11) NOT NULL DEFAULT '0',
`mod11` int(11) NOT NULL DEFAULT '0',
`mod12` int(11) NOT NULL DEFAULT '0',
`paintjob` int(11) NOT NULL DEFAULT '-1',
`destroyed` int(11) NOT NULL DEFAULT '0',
`gun1` int(3) NOT NULL DEFAULT '0',
`gun2` int(3) NOT NULL DEFAULT '0',
`gun3` int(3) NOT NULL DEFAULT '0',
`ammo1` int(6) NOT NULL DEFAULT '0',
`ammo2` int(6) NOT NULL DEFAULT '0',
`ammo3` int(6) NOT NULL DEFAULT '0',
`fueltype` int(3) NOT NULL DEFAULT '1',
`plate` char(6) NOT NULL,
PRIMARY KEY (`carid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=715 ;
But it not saving or Loading?
Re: Car Sys -
DVDK - 12.12.2010
You query is way too long, try to make it in parts.
Also, check your SQL log for any errors.
Re: Car Sys -
Sweet_Mafia™ - 12.12.2010
What DVDK said, make it into parts or it can be bugged.