Code:
CMD:edv(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] <= 4 && PlayerInfo[playerid][pFactionMod] != 1 && PlayerInfo[playerid][pGangDirector] != 1)
return AdmErrorMsg;
new
vehid, action[128];
if(sscanf(params, "is[128]D(0)D(0)", vehid, action))
{
SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /editdynamicvehicle [id] [action]");
SendClientMessage(playerid, COLOR_GREY, "Available actions: faction, family, group, colors, lockfeature, sirenfeature");
return 1;
}
if(IsValidVehicle(sVehicleInfo[vehid][v_id]))
{
new
Float:vx, Float:vy, Float:vz, Float:vrz;
GetVehiclePos(sVehicleInfo[vehid][v_id], vx, vy, vz);
GetVehicleZAngle(sVehicleInfo[vehid][v_id], vrz);
if(strcmp(action, "faction", true) == 0)
{
new faction;
if(sscanf(params, "is[128]d", vehid, action, faction))
return SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /editdynamicvehicle [id] faction [faction ID]");
format(sqlstring, sizeof(sqlstring), "UPDATE `vehicles` SET `faction` = %d WHERE ID = %d", faction, sVehicleInfo[vehid][v_sqlid]);
mysql_pquery(sqlGameConnection, sqlstring);
sVehicleInfo[vehid][v_faction] = faction;
SendClientMessage(playerid, COLOR_GREY, "You have successfully adjusted the vehicle's faction.");
}
if(strcmp(action, "family", true) == 0)
{
new family;
if(sscanf(params, "is[128]d", vehid, action, family))
return SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /editdynamicvehicle [id] family [gang slot]");
format(sqlstring, sizeof(sqlstring), "UPDATE `vehicles` SET `family` = %d WHERE ID = %d", family, sVehicleInfo[vehid][v_sqlid]);
mysql_pquery(sqlGameConnection, sqlstring);
sVehicleInfo[vehid][v_family] = family;
SendClientMessage(playerid, COLOR_GREY, "You have successfully adjusted the vehicle's family.");
}
if(strcmp(action, "sirenfeature", true) == 0)
{
if(!sscanf(params, "is[128]", vehid, action))
{
if(!sVehicleInfo[vehid][v_sirenfeature])
{
sVehicleInfo[vehid][v_sirenfeature] = 1;
SendClientMessage(playerid, COLOR_GREY, "You have successfully enabled the vehicle's siren feature.");
}
else
{
sVehicleInfo[vehid][v_sirenfeature] = 0;
SendClientMessage(playerid, COLOR_GREY, "You have successfully disabled the vehicle's siren feature.");
}
format(sqlstring, sizeof(sqlstring), "UPDATE `vehicles` SET `Siren` = %d WHERE ID = %d", sVehicleInfo[vehid][v_sirenfeature], sVehicleInfo[vehid][v_sqlid]);
mysql_pquery(sqlGameConnection, sqlstring);
SendClientMessage(playerid, COLOR_GREY, sqlstring);
DestroyVehicle(sVehicleInfo[vehid][v_id]);
sVehicleInfo[vehid][v_id] = CreateVehicle(sVehicleInfo[vehid][v_model],sVehicleInfo[vehid][v_x],sVehicleInfo[vehid][v_y],sVehicleInfo[vehid][v_z]+2,sVehicleInfo[vehid][v_rz],sVehicleInfo[vehid][v_color1],sVehicleInfo[vehid][v_color2],900, sVehicleInfo[vehid][v_sirenfeature]);
}
}
if(strcmp(action, "group", true) == 0)
{
new group;
if(sscanf(params, "is[128]d", vehid, action, group))
return SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /editdynamicvehicle [id] group [group]");
format(sqlstring, sizeof(sqlstring), "UPDATE `vehicles` SET `group` = %d WHERE ID = %d", group, sVehicleInfo[vehid][v_sqlid]);
mysql_pquery(sqlGameConnection, sqlstring);
sVehicleInfo[vehid][v_group] = group;
SendClientMessage(playerid, COLOR_GREY, "You have successfully adjusted the vehicle's group.");
}
if(strcmp(action, "lockfeature", true) == 0)
{
sVehicleInfo[vehid][v_lockfeature] = !sVehicleInfo[vehid][v_lockfeature];
format(sqlstring, sizeof(sqlstring), "UPDATE `vehicles` SET `lockfeature` = %d WHERE ID = %d", sVehicleInfo[vehid][v_lockfeature], sVehicleInfo[vehid][v_sqlid]);
mysql_pquery(sqlGameConnection, sqlstring);
if(sVehicleInfo[vehid][v_lockfeature] == 1)
SendClientMessage(playerid, COLOR_GREY, "You have successfully enabled the vehicle's locking feature.");
else
SendClientMessage(playerid, COLOR_GREY, "You have successfully disabled the vehicle's locking feature.");
SendClientMessage(playerid, COLOR_GREY, "This feature allows families/factions to lock/unlock the vehicle.");
SendClientMessage(playerid, COLOR_GREY, "It's important the vehicle is set to a faction ID or gang slot for this to work.");
}
else if(strcmp(action, "colors", true) == 0)
{
new color1, color2;
if(sscanf(params, "is[128]dd", vehid, action, color1, color2))
return SendClientMessage(playerid, -1, "{00BFFF}Usage:{FFFFFF} /editdynamicvehicle [id] colors [color1] [color2]");
format(sqlstring, sizeof(sqlstring), "UPDATE `vehicles` SET `color1`= %d, `color2`= %d WHERE `ID`=%d", color1, color2, sVehicleInfo[vehid][v_sqlid]);
mysql_pquery(sqlGameConnection, sqlstring);
sVehicleInfo[vehid][v_color1] = color1;
sVehicleInfo[vehid][v_color2] = color2;
ChangeVehiclePaintjob(sVehicleInfo[vehid][v_id], 3);
ChangeVehicleColor(sVehicleInfo[vehid][v_id], color1, color2);
SendClientMessage(playerid, COLOR_GREY, "You have successfully adjusted the vehicle's colors.");
}
else
return 1;
}
else
SendClientMessage(playerid, COLOR_GREY, "Invalid dynamic vehicle ID.");
return 1;
}