PHP код:
LoadVehicles(storeid)
{
new Data[150],Field[258],idx;
mysql_queryS("SELECT * FROM `Vehicles` WHERE `VehicleID` = %d",storeid);
mysql_store_result();
if(mysql_num_rows() == 1){
mysql_fetch_rowEx(Data);
Field = strtuk( Data, idx, '|' );
for(new s = 0; s < 20; s++)
{
switch(s)
{
case 0: Vehicles[storeid][VehicleID] = strval(Field);
case 1: Vehicles[storeid][ModelID] = strval(Field);
case 2: Vehicles[storeid][Color1] = strval(Field);
case 3: Vehicles[storeid][Color2] = strval(Field);
case 4: Vehicles[storeid][VPosX] = floatstr(Field);
case 5: Vehicles[storeid][VPosY] = floatstr(Field);
case 6: Vehicles[storeid][VPosZ] = floatstr(Field);
case 7: Vehicles[storeid][VPosAngle] = floatstr(Field);
case 8: Vehicles[storeid][LockStatus] = strval(Field);
case 9: Vehicles[storeid][FactionCar] = strval(Field);
case 10: strmid(Vehicles[storeid][VOwner],Field,0,strlen(Field),255);
case 11: strmid(Vehicles[storeid][VPlate],Field,0,strlen(Field),255);
case 12: Vehicles[storeid][SpeedoColor] = strval(Field);
case 13: Vehicles[storeid][FlashAble] = strval(Field);
case 14: Vehicles[storeid][RDuty] = strval(Field);
case 15: Vehicles[storeid][VehicleWorld] = strval(Field);
case 16: Vehicles[storeid][VehicleInteriorID] = strval(Field);
case 17: Vehicles[storeid][Impounded] = strval(Field);
case 18: Vehicles[storeid][SavedVehicle] = strval(Field);
}
Field = strtuk( Data, idx, '|' );
}
if(Vehicles[storeid][JustChangedColor] == 1)
{
Vehicles[storeid][DLID] = CreateVehicle(Vehicles[storeid][ModelID], Vehicles[storeid][VPosX], Vehicles[storeid][VPosY], Vehicles[storeid][VPosZ], Vehicles[storeid][VPosAngle], Vehicles[storeid][Color1], Vehicles[storeid][Color2], -1);
SetVehicleVirtualWorld(Vehicles[storeid][DLID], 0);
LinkVehicleToInterior(Vehicles[storeid][DLID], 0);
Vehicles[storeid][JustChangedColor] = 0;
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(Vehicles[storeid][DLID],engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(Vehicles[storeid][DLID],VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}
else
{
Vehicles[storeid][DLID] = CreateVehicle(Vehicles[storeid][ModelID], Vehicles[storeid][VPosX], Vehicles[storeid][VPosY], Vehicles[storeid][VPosZ], Vehicles[storeid][VPosAngle], Vehicles[storeid][Color1], Vehicles[storeid][Color2], -1);
SetVehicleVirtualWorld(Vehicles[storeid][DLID], Vehicles[storeid][VehicleWorld]);
LinkVehicleToInterior(Vehicles[storeid][DLID], Vehicles[storeid][VehicleInteriorID]);
VehicleFuel[Vehicles[storeid][DLID]] = 100;
VehicleBattery[Vehicles[storeid][DLID]] = 100;
}
SetVehicleNumberPlate(Vehicles[storeid][DLID], Vehicles[storeid][VPlate]);
Vehicles[Vehicles[storeid][DLID]][SavedVehicle] = 1;
if(Vehicles[storeid][JustChanged] == 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(Player[i][JustChangedCar] == Vehicles[storeid][DLID])
{
PutPlayerInVehicle(i, Vehicles[storeid][DLID], 0);
Vehicles[storeid][JustChanged] = 0;
Player[i][JustChangedCar] = -1;
}
}
}
printf("[System] Vehicle Slot: %d, Vehicle /dl: %d, has been successfully spawned!", storeid, Vehicles[storeid][DLID]);
ServerVehicle[Vehicles[storeid][DLID]] = 1;
SpawnedVehicles++;
mysql_free_result();
}
}
LoadOwnedVehicle(storeid, playerid)
{
new Data[150],Field[258],idx;
mysql_queryS("SELECT * FROM `OwnedVehicles` WHERE `vStoreID` = %d",storeid);
mysql_store_result();
if(mysql_num_rows() == 1){
mysql_fetch_rowEx(Data);
Field = strtuk( Data, idx, '|' );
for(new s = 0; s < 20; s++)
{
switch(s)
{
case 0: OwnedVehicles[storeid][vStoreID] = strval(Field);
case 1: OwnedVehicles[storeid][vModelID] = strval(Field);
case 2: OwnedVehicles[storeid][vColor1] = strval(Field);
case 3: OwnedVehicles[storeid][vColor2] = strval(Field);
case 4: OwnedVehicles[storeid][vPositionX] = floatstr(Field);
case 5: OwnedVehicles[storeid][vPositionY] = floatstr(Field);
case 6: OwnedVehicles[storeid][vPositionZ] = floatstr(Field);
case 7: OwnedVehicles[storeid][vPositionAngle] = floatstr(Field);
case 8: OwnedVehicles[storeid][vLockStatus] = strval(Field);
case 9: strmid(OwnedVehicles[storeid][VehicleOwner],Field,0,strlen(Field),255);
case 10: strmid(OwnedVehicles[storeid][VehiclePlate],Field,0,strlen(Field),255);
case 11: OwnedVehicles[storeid][vSpeedoColor] = strval(Field);
case 12: OwnedVehicles[storeid][vWorld] = strval(Field);
case 13: OwnedVehicles[storeid][vInteriorID] = strval(Field);
case 14: OwnedVehicles[storeid][vImpounded] = strval(Field);
case 15: OwnedVehicles[storeid][vSavedVehicle] = strval(Field);
case 16: OwnedVehicles[storeid][vFuel] = strval(Field);
case 17: OwnedVehicles[storeid][vBattery] = strval(Field);
}
Field = strtuk( Data, idx, '|' );
}
if(OwnedVehicles[storeid][vJustChangedColor] == 1)
{
OwnedVehicles[storeid][vDLID] = CreateVehicle(OwnedVehicles[storeid][vModelID], OwnedVehicles[storeid][vPositionX], OwnedVehicles[storeid][vPositionY], OwnedVehicles[storeid][vPositionZ], OwnedVehicles[storeid][vPositionAngle], OwnedVehicles[storeid][vColor1], OwnedVehicles[storeid][vColor2], -1);
SetVehicleVirtualWorld(OwnedVehicles[storeid][vDLID], 0);
LinkVehicleToInterior(OwnedVehicles[storeid][vDLID], 0);
OwnedVehicles[storeid][vJustChangedColor] = 0;
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(OwnedVehicles[storeid][vDLID],engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(OwnedVehicles[storeid][vDLID],VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}
else
{
if(OwnedVehicles[storeid][vImpounded] == 1)
{
ImpoundCount++;
if(ImpoundCount >= 48)
{
new rand = random(sizeof(RandomImpoundSpawn));
OwnedVehicles[storeid][vDLID] = CreateVehicle(OwnedVehicles[storeid][vModelID], RandomImpoundSpawn[rand][0], RandomImpoundSpawn[rand][1], RandomImpoundSpawn[rand][2], RandomImpoundSpawn[rand][3], OwnedVehicles[storeid][vColor1], OwnedVehicles[storeid][vColor2], -1);
SetVehicleVirtualWorld(OwnedVehicles[storeid][vDLID], OwnedVehicles[storeid][vDLID]);//set vw
VehicleFuel[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vFuel];
VehicleBattery[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vBattery];
}else{
OwnedVehicles[storeid][vDLID] = CreateVehicle(OwnedVehicles[storeid][vModelID], RandomImpoundSpawn[ImpoundCount][0], RandomImpoundSpawn[ImpoundCount][1], RandomImpoundSpawn[ImpoundCount][2], RandomImpoundSpawn[ImpoundCount][3], OwnedVehicles[storeid][vColor1], OwnedVehicles[storeid][vColor2], -1);
SetVehicleVirtualWorld(OwnedVehicles[storeid][vDLID], 0);
LinkVehicleToInterior(OwnedVehicles[storeid][vDLID], 0);
VehicleFuel[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vFuel];
VehicleBattery[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vBattery];
VehicleJustImpounded[OwnedVehicles[storeid][vDLID]] = 0;
}
}
else
{
OwnedVehicles[storeid][vDLID] = CreateVehicle(OwnedVehicles[storeid][vModelID], OwnedVehicles[storeid][vPositionX], OwnedVehicles[storeid][vPositionY], OwnedVehicles[storeid][vPositionZ], OwnedVehicles[storeid][vPositionAngle], OwnedVehicles[storeid][vColor1], OwnedVehicles[storeid][vColor2], -1);
SetVehicleVirtualWorld(OwnedVehicles[storeid][vDLID], OwnedVehicles[storeid][vWorld]);//set vw
LinkVehicleToInterior(OwnedVehicles[storeid][vDLID], OwnedVehicles[storeid][vInteriorID]);//set int
VehicleFuel[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vFuel];
VehicleBattery[OwnedVehicles[storeid][vDLID]]= OwnedVehicles[storeid][vBattery];
}
}
SetVehicleNumberPlate(OwnedVehicles[storeid][vDLID], OwnedVehicles[storeid][VehiclePlate]);
OwnedVehicles[storeid][vSavedVehicle] = 1;
OwnedVehicles[storeid][vSpawned] = 1;
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(OwnedVehicles[storeid][vDLID],engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(OwnedVehicles[storeid][vDLID],engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
if(OwnedVehicles[storeid][vJustChanged] == 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(Player[i][JustChangedCar] == OwnedVehicles[storeid][vDLID])
{
PutPlayerInVehicle(i, OwnedVehicles[storeid][vDLID], 0);
OwnedVehicles[storeid][vJustChanged] = 0;
Player[i][JustChangedCar] = -1;
}
}
}
if(playerid != -1)
{
fSendClientMessage(playerid, GRAYLOGIN, "> Your Vehicle: %s with Plate: %s, has been spawned!", GetVehicleName(OwnedVehicles[storeid][vModelID]), OwnedVehicles[storeid][VehiclePlate]);
fSendClientMessage(playerid, GRAYLOGIN, "> It is located in %s!",GetVehicleZone(OwnedVehicles[storeid][vDLID]));
Player[playerid][SpawnedPersonalCar] = OwnedVehicles[storeid][vDLID];
//SetPlayerCheckpoint(playerid, OwnedVehicles[storeid][vPositionX], OwnedVehicles[storeid][vPositionY], OwnedVehicles[storeid][vPositionZ], 5.0);
//Player[playerid][Checkpoint] = 1;
}
ServerVehicle[OwnedVehicles[storeid][vDLID]] = 0;
SpawnedVehicles++;
mysql_free_result();
}
}
AssignOwnedVehicles(playerid)
{
new Data[1000],Field[258],idx;
new MyCarStoreID;
mysql_queryM("SELECT `vStoreID` FROM `OwnedVehicles` WHERE `VehicleOwner` = '%s' LIMIT 10",GetName(playerid));
mysql_store_result();
if(mysql_num_rows() >= 0){
for(new i=0; i < mysql_num_rows(); i++){
mysql_fetch_rowEx(Data);
idx = 0;
Field = strtuk( Data, idx, '|' );
for(new s = 0; s < 4; s++)
{
switch(s)
{
case 0: MyCarStoreID = strval(Field);
}
Field = strtuk( Data, idx, '|' );
}
if(PlayerVehicleSlot[playerid][i] == -1){PlayerVehicleSlot[playerid][i] = MyCarStoreID;}
}
}
return 1;
}