PHP код:
//==============================================================================
//--->>> Dynamic Car System
//==============================================================================
#include <a_samp>
#include <YSI\y_hooks>
//==============================================================================
//--->>> Config
//==============================================================================
#define MAX_SPAWN_VEHICLES 300
#define PLATES "SA-ONLINE"
//==============================================================================
//==============================================================================
//--->>> Forward
//==============================================================================
forward LoadVehicle(query[], vehicleid, connectionHandle);
//==============================================================================
//--->>> Variables
//==============================================================================
enum VehicleEnum
{
vID,
Float:vPosX,
Float:vPosY,
Float:vPosZ,
Float:vAngle,
vColor1,
vColor2,
VehicleVar
};
new vInfo[MAX_SPAWN_VEHICLES][VehicleEnum];
//==============================================================================
//==============================================================================
//--->>> Publics
//==============================================================================
public LoadVehicle(query[], vehicleid, connectionHandle)
{
mysql_store_result();
if(mysql_num_rows())
{
new tmp[156];
while(mysql_retrieve_row())
{
mysql_get_field("svID", tmp); vehicleid = strval(tmp);
mysql_get_field("VehicleID", vInfo[vehicleid][vID]);
mysql_get_field("PosX", tmp); vInfo[vehicleid][vPosX] = floatstr(tmp);
mysql_get_field("PosY", tmp); vInfo[vehicleid][vPosY] = floatstr(tmp);
mysql_get_field("PosZ", tmp); vInfo[vehicleid][vPosZ] = floatstr(tmp);
mysql_get_field("Angle", tmp); vInfo[vehicleid][vAngle] = floatstr(tmp);
mysql_get_field("Color1", tmp); vInfo[vehicleid][vColor1] = strval(tmp);
mysql_get_field("Color2", tmp); vInfo[vehicleid][vColor2] = strval(tmp);
}
}
mysql_free_result();
for(new i = 0; i < MAX_SPAWN_VEHICLES; i++)
{
CreateNewVehicle(i);
}
return 1;
}
//==============================================================================
//==============================================================================
//--->>> Stocks
//==============================================================================
stock SaveVehicle(vehicleid)
{
new Query[512];
format(Query, sizeof(Query), "UPDATE `Vehicles` SET\
`VehicleID` = %d,\
`PosX` = %d\
`PosY` = %f,\
`PosZ` = %f,\
`Angle` = %f, \
`Color1` = %d, \
`Color2` = %d \
WHERE svID = %d",
vInfo[vehicleid][vID],
vInfo[vehicleid][vPosX],
vInfo[vehicleid][vPosY],
vInfo[vehicleid][vPosZ],
vInfo[vehicleid][vAngle],
vInfo[vehicleid][vColor1],
vInfo[vehicleid][vColor2],
vehicleid);
return 1;
}
stock CreateNewVehicle(vehicleid)
{
vInfo[vehicleid][VehicleVar] = CreateVehicle(vInfo[vehicleid][vID], vInfo[vehicleid][vPosX], vInfo[vehicleid][vPosY], vInfo[vehicleid][vPosZ], vInfo[vehicleid][vAngle], vInfo[vehicleid][vColor1], vInfo[vehicleid][vColor2], 120);
printf("Vehicle id: %d, Model: %d, Pos X: %f, Pos Y %f, Pos Z: %f, Angle: %f, color1: %d, color2: %d",vInfo[vehicleid][VehicleVar],vInfo[vehicleid][vID], vInfo[vehicleid][vPosX], vInfo[vehicleid][vPosY], vInfo[vehicleid][vPosZ], vInfo[vehicleid][vAngle], vInfo[vehicleid][vColor1], vInfo[vehicleid][vColor2]);
//SetVehicleNumberPlate(vInfo[vehicleid][VehicleVar], ""#PLATES"");
return 1;
}
//==============================================================================
//==============================================================================
//--->>> Hooks
//==============================================================================
hook OnGameModeInit()
{
mysql_query_callback(0, "SELECT * FROM Vehicles", "LoadVehicle");
/*for(new i = 0; i < MAX_SPAWN_VEHICLES; i++)
{
CreateNewVehicle(i);
}*/
return 1;
}
hook OnGameModeExit()
{
return 1;
}
if yet not spawning, Reply what is it printing please.