30.03.2016, 09:42
Hello. So, I am editing the South Central RP gamemode and I tried adding the siren sound that comes in 0.3.7. -Link. I managed to implement it into the /createcar command.
. It is creating the car and I am able to play the siren by pressing H. Its all good. But here comes the part I cant handle. I created a new column into the database to be saving the siren, If 0 or 1. Screenshot:http://i.imgur.com/gyPVnbQ.jpg
I followed the exact way the carFaction had been created, for some reason its not loading the carSiren.
Every info about the carSiren I have added.
As you can see, everywhere that I had to add the carSiren info, its added. What did I do wrong, so its not working?
pawn Код:
CMD:createcar(playerid, params[])
{
static
model[32],
color1,
color2,
id = -1,
type = 0,
addsiren = 0;
if (PlayerData[playerid][pAdmin] < 5)
return SendErrorMessage(playerid, "You don't have permission to use this command.");
if (sscanf(params, "s[32]I(-1)I(-1)I(0)I(0)", model, color1, color2, type, addsiren))
{
SendSyntaxMessage(playerid, "/createcar [model id/name] [color 1] [color 2] <faction> <siren>");
SendClientMessage(playerid, COLOR_YELLOW, "[TYPES]:{FFFFFF} 1: Police | 2: News | 3: Medical | 4: Government | 5: Company");
return 1;
}
if ((model[0] = GetVehicleModelByName(model)) == 0)
return SendErrorMessage(playerid, "Invalid model ID.");
static
Float:x,
Float:y,
Float:z,
Float:angle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angle);
id = Car_Create(0, model[0], x, y, z, angle, color1, color2, type, addsiren);
if (id == -1)
return SendErrorMessage(playerid, "The server has reached the limit for dynamic vehicles.");
SetPlayerPosEx(playerid, x, y, z + 2, 1000);
SendServerMessage(playerid, "You have successfully created vehicle ID: %d.", CarData[id][carVehicle]);
return 1;
}
I followed the exact way the carFaction had been created, for some reason its not loading the carSiren.
Every info about the carSiren I have added.
pawn Код:
enum carData {
carID,
carExists,
carModel,
carOwner,
Float:carPos[4],
carColor1,
carColor2,
carPaintjob,
carLocked,
carMods[14],
carImpounded,
carImpoundPrice,
carFaction,
carSiren,
carWeapons[5],
carAmmo[5],
carVehicle
};
pawn Код:
forward Car_Load();
public Car_Load()
{
static
rows,
fields,
str[128];
cache_get_data(rows, fields, g_iHandle);
for (new i = 0; i < rows; i ++) if (i < MAX_DYNAMIC_CARS)
{
CarData[i][carExists] = true;
CarData[i][carID] = cache_get_field_int(i, "carID");
CarData[i][carModel] = cache_get_field_int(i, "carModel");
CarData[i][carOwner] = cache_get_field_int(i, "carOwner");
CarData[i][carPos][0] = cache_get_field_float(i, "carPosX");
CarData[i][carPos][1] = cache_get_field_float(i, "carPosY");
CarData[i][carPos][2] = cache_get_field_float(i, "carPosZ");
CarData[i][carPos][3] = cache_get_field_float(i, "carPosR");
CarData[i][carColor1] = cache_get_field_int(i, "carColor1");
CarData[i][carColor2] = cache_get_field_int(i, "carColor2");
CarData[i][carPaintjob] = cache_get_field_int(i, "carPaintjob");
CarData[i][carLocked] = cache_get_field_int(i, "carLocked");
CarData[i][carImpounded] = cache_get_field_int(i, "carImpounded");
CarData[i][carImpoundPrice] = cache_get_field_int(i, "carImpoundPrice");
CarData[i][carFaction] = cache_get_field_int(i, "carFaction");
CarData[i][carSiren] = cache_get_field_int(i, "carSiren");
for (new j = 0; j < 14; j ++)
{
if (j < 5)
{
format(str, sizeof(str), "carWeapon%d", j + 1);
CarData[i][carWeapons][j] = cache_get_field_int(i, str);
format(str, sizeof(str), "carAmmo%d", j + 1);
CarData[i][carAmmo][j] = cache_get_field_int(i, str);
}
format(str, sizeof(str), "carMod%d", j + 1);
CarData[i][carMods][j] = cache_get_field_int(i, str);
}
Car_Spawn(i);
}
for (new i = 0; i < MAX_DYNAMIC_CARS; i ++) if (CarData[i][carExists]) {
format(str, sizeof(str), "SELECT * FROM `carstorage` WHERE `ID` = '%d'", CarData[i][carID]);
mysql_tquery(g_iHandle, str, "OnLoadCarStorage", "d", i);
}
return 1;
}
pawn Код:
Car_Create(ownerid, modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, type = 0, addsiren = 0)
{
for (new i = 0; i != MAX_DYNAMIC_CARS; i ++)
{
if (!CarData[i][carExists])
{
if (color1 == -1)
color1 = random(127);
if (color2 == -1)
color2 = random(127);
CarData[i][carExists] = true;
CarData[i][carModel] = modelid;
CarData[i][carOwner] = ownerid;
CarData[i][carPos][0] = x;
CarData[i][carPos][1] = y;
CarData[i][carPos][2] = z;
CarData[i][carPos][3] = angle;
CarData[i][carColor1] = color1;
CarData[i][carColor2] = color2;
CarData[i][carPaintjob] = -1;
CarData[i][carLocked] = false;
CarData[i][carImpounded] = -1;
CarData[i][carImpoundPrice] = 0;
CarData[i][carFaction] = type;
CarData[i][carSiren] = addsiren;
for (new j = 0; j < 14; j ++)
{
if (j < 5)
{
CarData[i][carWeapons][j] = 0;
CarData[i][carAmmo][j] = 0;
}
CarData[i][carMods][j] = 0;
}
CarData[i][carVehicle] = CreateVehicle(modelid, x, y, z, angle, color1, color2, -1, -1);
if (CarData[i][carVehicle] != INVALID_VEHICLE_ID) {
ResetVehicle(CarData[i][carVehicle]);
}
mysql_tquery(g_iHandle, "INSERT INTO `cars` (`carModel`) VALUES(0)", "OnCarCreated", "d", i);
return i;
}
}
return -1;
}
pawn Код:
Car_Save(carid)
{
static
query[900];
if (CarData[carid][carVehicle] != INVALID_VEHICLE_ID)
{
for (new i = 0; i < 14; i ++) {
CarData[carid][carMods][i] = GetVehicleComponentInSlot(CarData[carid][carVehicle], i);
}
}
format(query, sizeof(query), "UPDATE `cars` SET `carModel` = '%d', `carOwner` = '%d', `carPosX` = '%.4f', `carPosY` = '%.4f', `carPosZ` = '%.4f', `carPosR` = '%.4f', `carColor1` = '%d', `carColor2` = '%d', `carPaintjob` = '%d', `carLocked` = '%d'",
CarData[carid][carModel],
CarData[carid][carOwner],
CarData[carid][carPos][0],
CarData[carid][carPos][1],
CarData[carid][carPos][2],
CarData[carid][carPos][3],
CarData[carid][carColor1],
CarData[carid][carColor2],
CarData[carid][carPaintjob],
CarData[carid][carLocked]
);
format(query, sizeof(query), "%s, `carMod1` = '%d', `carMod2` = '%d', `carMod3` = '%d', `carMod4` = '%d', `carMod5` = '%d', `carMod6` = '%d', `carMod7` = '%d', `carMod8` = '%d', `carMod9` = '%d', `carMod10` = '%d', `carMod11` = '%d', `carMod12` = '%d', `carMod13` = '%d', `carMod14` = '%d'",
query,
CarData[carid][carMods][0],
CarData[carid][carMods][1],
CarData[carid][carMods][2],
CarData[carid][carMods][3],
CarData[carid][carMods][4],
CarData[carid][carMods][5],
CarData[carid][carMods][6],
CarData[carid][carMods][7],
CarData[carid][carMods][8],
CarData[carid][carMods][9],
CarData[carid][carMods][10],
CarData[carid][carMods][11],
CarData[carid][carMods][12],
CarData[carid][carMods][13]
);
format(query, sizeof(query), "%s, `carImpounded` = '%d', `carImpoundPrice` = '%d', `carFaction` = '%d', `carSiren` = '%d', `carWeapon1` = '%d', `carWeapon2` = '%d', `carWeapon3` = '%d', `carWeapon4` = '%d', `carWeapon5` = '%d', `carAmmo1` = '%d', `carAmmo2` = '%d', `carAmmo3` = '%d', `carAmmo4` = '%d', `carAmmo5` = '%d' WHERE `carID` = '%d'",
query,
CarData[carid][carImpounded],
CarData[carid][carImpoundPrice],
CarData[carid][carFaction],
CarData[carid][carSiren],
CarData[carid][carWeapons][0],
CarData[carid][carWeapons][1],
CarData[carid][carWeapons][2],
CarData[carid][carWeapons][3],
CarData[carid][carWeapons][4],
CarData[carid][carAmmo][0],
CarData[carid][carAmmo][1],
CarData[carid][carAmmo][2],
CarData[carid][carAmmo][3],
CarData[carid][carAmmo][4],
CarData[carid][carID]
);
return mysql_tquery(g_iHandle, query);
}