forward InitiateVehicles();
public InitiateVehicles()
{
new rows, fields, vehicles;
cache_get_data(rows, fields);
for(new row; row < MAX_DYN_VEHICLES; row++)
{
Vehicle[row][VehicleDatabaseID] = cache_get_field_content_int(row, "id", SQL);
Vehicle[row][Model] = cache_get_field_content_int(row, "Model", SQL);
Vehicle[row][VehiclePos][0] = cache_get_field_content_float(row, "X", SQL);
Vehicle[row][VehiclePos][1] = cache_get_field_content_float(row, "Y", SQL);
Vehicle[row][VehiclePos][2] = cache_get_field_content_float(row, "Z", SQL);
Vehicle[row][VehiclePos][3] = cache_get_field_content_float(row, "A", SQL);
Vehicle[row][VehicleVW] = cache_get_field_content_int(row, "VW", SQL);
Vehicle[row][VehicleInt] = cache_get_field_content_int(row, "Int", SQL);
Vehicle[row][VehicleColour][0] = cache_get_field_content_int(row, "Colour1", SQL);
Vehicle[row][VehicleColour][1] = cache_get_field_content_int(row, "Colour2", SQL);
Vehicle[row][VehicleGroup] = cache_get_field_content_int(row, "Group", SQL);
Vehicle[row][Siren] = cache_get_field_content_int(row, "Siren", SQL);
if(Vehicle[row][VehiclePos][0] != 0.00000 && Vehicle[row][VehiclePos][1] != 0.00000 && Vehicle[row][VehiclePos][2] != 0.00000)
{
Vehicle[row][VehID] = CreateVehicle(Vehicle[row][Model], Vehicle[row][VehiclePos][0], Vehicle[row][VehiclePos][1], Vehicle[row][VehiclePos][2], Vehicle[row][VehiclePos][3], Vehicle[row][VehicleColour][0], Vehicle[row][VehicleColour][1], -1, Vehicle[row][Siren]);
SetVehicleVirtualWorld(Vehicle[row][VehID], Vehicle[row][VehicleVW]);
LinkVehicleToInterior(Vehicle[row][VehID], Vehicle[row][VehicleInt]);
}
printf("%d | %d | %d", row, Vehicle[row][VehicleDatabaseID], Vehicle[row][VehID]);
vehicles++;
}
switch(vehicles)
{
case 0: printf("[SCRIPT-LOAD/ERR] The script initiated 0 vehicles.", vehicles);
default: printf("[SCRIPT-LOAD] The script has initiated %d vehicles", vehicles);
}
}
ROW|DID|VID
[18:53:18] 0 | 1 | 1
CMD:editvehicle(playerid, params[])
{
new id, usage[16], amount;
if(sscanf(params, "ds[16]D(0)", id, usage, amount))
{
if(Player[playerid][AdminLevel] >= 5)
{
SendClientMessage(playerid, WHITE, "USAGE: /editvehicle [id] [usage] [(optional) amount]");
return SendClientMessage(playerid, GREY, "Usages: spawn, colour(1-2), group, delete");
}
}
else if(Player[playerid][AdminLevel] >= 5)
{
if(id < 1 || id > MAX_VEHICLES) return SendClientMessage(playerid, WHITE, "That is not a valid vehicle ID!");
if(Vehicle[id][VehicleDatabaseID] < 1) return SendClientMessage(playerid, WHITE, "That is not a valid dynamic vehicle ID!");
Array[0] = 0;
if(strcmp(usage, "spawn", true) == 0)
{
new Float:Pos[4];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
Vehicle[id][VehiclePos][0] = Pos[0];
Vehicle[id][VehiclePos][1] = Pos[1];
Vehicle[id][VehiclePos][2] = Pos[2];
Vehicle[id][VehiclePos][3] = Pos[3];
Vehicle[id][VehicleVW] = GetPlayerVirtualWorld(playerid);
Vehicle[id][VehicleInt] = GetPlayerInterior(playerid);
format(Array, sizeof(Array), "You have moved the spawn of vehicle %d", id);
SendClientMessage(playerid, WHITE, Array);
format(Array, sizeof(Array), "[/EDITVEHICLE] %s has moved the spawn of vehicle %d to X: %f, Y: %f, Z: %f", GetName(playerid), id, Pos[0], Pos[1], Pos[2]);
}
else
{
SendClientMessage(playerid, WHITE, "USAGE: /editvehicle [id] [usage] [(optional) amount]");
return SendClientMessage(playerid, GREY, "Usages: spawn, colour(1-2), group, delete");
}
Log(4, Array);
RespawnVehicle(id);
SaveVehicle(id);
}
else SendClientMessage(playerid, WHITE, "You are not authorized to preform this command.");
return 1;
}
RespawnVehicle(id)
{
DestroyVehicle(Vehicle[id][VehID]);
if(Vehicle[id][VehiclePos][0] != 0.00000 && Vehicle[id][VehiclePos][1] != 0.00000 && Vehicle[id][VehiclePos][2] != 0.00000)
{
Vehicle[id][VehID] = CreateVehicle(Vehicle[id][Model], Vehicle[id][VehiclePos][0], Vehicle[id][VehiclePos][1], Vehicle[id][VehiclePos][2], Vehicle[id][VehiclePos][3], Vehicle[id][VehicleColour][0], Vehicle[id][VehicleColour][1], -1, Vehicle[id][Siren]);
SetVehicleVirtualWorld(Vehicle[id][VehID], Vehicle[id][VehicleVW]);
LinkVehicleToInterior(Vehicle[id][VehID], Vehicle[id][VehicleInt]);
}
return 1;
}
else if(Player[playerid][AdminLevel] >= 5)
{
if(id < 1 || id > MAX_VEHICLES) return SendClientMessage(playerid, WHITE, "That is not a valid vehicle ID!");
if(Vehicle[id][VehID] > 1) return SendClientMessage(playerid, WHITE, "That is not a valid dynamic vehicle ID!");
Array[0] = 0;
id = id - 1; // Here we subtract the ID the player put into the command.
if(strcmp(usage, "spawn", true) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, WHITE, "You must be in a vehicle to edit the spawn!");
new Float:Pos[4];
GetVehiclePos(GetPlayerVehicleID(playerid), Pos[0], Pos[1], Pos[2]);
GetVehicleZAngle(GetPlayerVehicleID(playerid), Pos[3]);
Vehicle[id][VehiclePos][0] = Pos[0];
Vehicle[id][VehiclePos][1] = Pos[1];
Vehicle[id][VehiclePos][2] = Pos[2];
Vehicle[id][VehiclePos][3] = Pos[3];
Vehicle[id][VehicleVW] = GetPlayerVirtualWorld(playerid);
Vehicle[id][VehicleInt] = GetPlayerInterior(playerid);
format(Array, sizeof(Array), "You have moved the spawn of vehicle %d", id + 1);
SendClientMessage(playerid, WHITE, Array);
format(Array, sizeof(Array), "[/EDITVEHICLE] %s has moved the spawn of vehicle %d to X: %f, Y: %f, Z: %f", GetName(playerid), id + 1, Pos[0], Pos[1], Pos[2]);
}
else
{
SendClientMessage(playerid, WHITE, "USAGE: /editvehicle [id] [usage] [(optional) amount]");
return SendClientMessage(playerid, GREY, "Usages: spawn, colour(1-2), group, delete");
}
Log(4, Array);
RespawnVehicle(id); // Here we respawn that ID.
SaveVehicle(id);
but id is 0 ( slot 1 ) Vehicle[id][VehID] so i dont understand you
|
CMD:spawnvehicle(playerid, params[])
{
if(Player[playerid][AdminLevel] >= 2)
{
new vehicle, colour[2];
if(sscanf(params, "iD(0)D(0)", vehicle, colour[0], colour[1])) return SendClientMessage(playerid, WHITE, "SYNTAX: /spawnvehicle [model] [(optional) colour] [(optional) colour]");
else if(!(400 <= vehicle <= 611)) return SendClientMessage(playerid, WHITE, "You specified an invalid model ID. (IDs start at 400, and end at 611).");
else if(!(0 <= colour[0] <= 255 && 0 <= colour[1] <= 255)) return SendClientMessage(playerid, WHITE, "You specified an invalid colour ID. (IDs start at 0, and end at 255).");
else for(new i; i < sizeof(AdminVehicles); i++) if(i >= MAX_ADMIN_VEHICLES) return SendClientMessage(playerid, WHITE, "The maximum limit of 50 spawned vehicles has been reached.");
else if(AdminVehicles[i] == INVALID_VEHICLE_ID)
{
new Float:Pos[4];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
AdminVehicles[i] = CreateVehicle(vehicle, Pos[0], Pos[1], Pos[2], Pos[3], colour[0], colour[1], -1);
LinkVehicleToInterior(AdminVehicles[i], GetPlayerInterior(playerid));
SetVehicleVirtualWorld(AdminVehicles[i], GetPlayerVirtualWorld(playerid));
return SendClientMessage(playerid, WHITE, "You have successfully created a vehicle.");
}
}
else SendClientMessage(playerid, WHITE, "You are not authorized to use that command.");
return 1;
}
CMD:destroyvehicles(playerid, params[])
{
if(Player[playerid][AdminLevel] >= 4)
{
for(new i = 0; i < sizeof(AdminVehicles); i++)
{
if(AdminVehicles[i] != INVALID_VEHICLE_ID)
{
DestroyVehicle(AdminVehicles[i]);
AdminVehicles[i] = INVALID_VEHICLE_ID;
}
}
SendClientMessage(playerid, WHITE, "You have successfully destroyed all administrative spawned vehicles.");
}
else SendClientMessage(playerid, WHITE, "You are not authorized to preform this command.");
return 1;
}