15.08.2016, 17:15
pawn Код:
public OnVehicleSpawn(vehicleid)
{
if(vehicleid != INVALID_VEHICLE_ID)
{
if(VehicleSQLID[vehicleid] > 0)
{
SetVehiclePos(vehicleid, VehSpawnX[vehicleid], VehSpawnY[vehicleid], VehSpawnZ[vehicleid]);
SetVehicleZAngle(vehicleid, VehSpawnAngle[vehicleid]);
}
pawn Код:
CMD:respawnallvehicles(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
new string[128];
for(new v = 1; v < GetVehiclePoolSize()+1; v++)
{
if(GetVehicleModel(v) != 510 && !IsVehicleInUse(v))
{
SetVehicleToRespawn(v);
SetVehicleZAngle(v, VehSpawnAngle[v]);
}
}
format(string, sizeof(string), ""COL_GREEN"All Vehicles Respawned.");
SendClientMessage(playerid, COLOUR_WHITE, string);
SendClientMessageToAll(COLOUR_WHITE, "All vehicles have been respawned.");
return 1;
}
pawn Код:
CMD:spawnrentveh(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(AdminLevel[playerid] < 4) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
new vmodel, colour1, colour2;
if(sscanf(params, "ddd", vmodel, colour1, colour2)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /spawnrentveh [model] [colour 1] [colour 2]");
new plate[50];
new Float:scx,Float:scy, Float:scz, Float:sca;
GetPlayerPos(playerid, scx, scy, scz);
GetPlayerFacingAngle(playerid, sca);
new vehicleid = CreateVehicle(vmodel, scx,scy,scz,sca,colour1,colour2,0);
VehFuel[vehicleid] = random(100);
VehModel[vehicleid] = vmodel;
VehColour1[vehicleid] = colour1;
VehColour2[vehicleid] = colour2;
VehJob[vehicleid] = 0;
RentVeh[vehicleid] = 1;
RentedBy[vehicleid] = -1;
RentTime[vehicleid] = -1;
format(VehPlate[vehicleid], 32, plate);
VehSpawnX[vehicleid] = scx;
VehSpawnY[vehicleid] = scy;
VehSpawnZ[vehicleid] = scz;
VehSpawnAngle[vehicleid] = GetPlayerFacingAngle(playerid, sca);
VehicleFaction[vehicleid] = 0;
VehicleRank[vehicleid] = 0;
VehFactioned[vehicleid] = 0;
VehOwned[vehicleid] = 0;
VehOwner[vehicleid] = 0;
VehHealth[vehicleid] = 1000;
if(IsEngineVeh(vehicleid) == 1)
{
VehFType[vehicleid] = RandomEx(1, 2);//1 = Petrol, 2 = Diesel.
VehSpark[vehicleid] = RandomEx(1500, 2500);
VehGear[vehicleid] = RandomEx(1500, 2500);
VehElec[vehicleid] = RandomEx(1500, 2500);
VehWater[vehicleid] = RandomEx(350, 400);
VehOil[vehicleid] = RandomEx(650, 800);
VehExhaust[vehicleid] = RandomEx(1500, 2500);
VehFLine[vehicleid] = 3; //3 = perfect/excellent, 2 = damaged, 1 = broken
VehRadi[vehicleid] = RandomEx(2000, 2500);
VehFSize[vehicleid] = RandomEx(40, 70); //fuel size litres
VehFuel[vehicleid] = RandomEx(30, 35); //one minute of fuel basically. Random every minute.
VehBattery[vehicleid] = RandomEx(20, 35);
VehFUsed[vehicleid] = VehFType[vehicleid];
}
format(plate, sizeof(plate), "RENTAL%d", vehicleid);
new vehslotfree = GetFreeMySQLSlot("vehicles");
new query[550];
if(vehslotfree == 0)
{
format(query, sizeof(query), "INSERT INTO `vehicles` (Inactive, VehModel, VehOwner, VehSpawnX, VehSpawnY, VehSpawnZ,VehSpawnAngle, VehColour1, VehColour2, VehFuel, RentVeh) VALUES (0,%d,0,%f,%f,%f,%f,%d,%d,%d,%d)", vmodel,scx, scy, scz,sca,colour1,colour2,VehFuel[vehicleid],1);
mysql_tquery(dbHandle, query, "SpawnVeh", "i", vehicleid);
format(query, sizeof(query), "UPDATE vehicles SET VehPlate = '%s' WHERE id = %d", plate, VehicleSQLID[vehicleid]);
mysql_tquery(dbHandle, query,"", "");
}
else
{
format(query, sizeof(query), "UPDATE vehicles SET Inactive = 0, VehModel = %d, VehOwner = 0, VehSpawnX = %f, VehSpawnY = %f, VehSpawnZ = %f, VehSpawnAngle = %f, VehColour1 = %d, VehColour2 = %d, VehFuel = %d, VehPlate = '0', VehCash = 0, VehArmour = 0, VehFaction = 0, VehFRank = 0, RentVeh = %d, VehOwned = 0, VehFactioned = 0 WHERE id = %d", vmodel, scx, scy, scz, sca, colour1, colour2, VehFuel[vehicleid],1, vehslotfree);
mysql_tquery(dbHandle, query, "", "");
VehicleSQLID[vehicleid] = vehslotfree;
format(query, sizeof(query), "UPDATE vehicles SET VehPlate = '%s' WHERE id = %d", plate, VehicleSQLID[vehicleid]);
mysql_tquery(dbHandle, query, "", "");
}
SetVehicleNumberPlate(vehicleid,plate);
UpdateVehicleParts(vehicleid);
return 1;
}
pawn Код:
CMD:asaveveh(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(AdminLevel[playerid] == 0)return SendClientMessage(playerid, COLOUR_GREY, "You are not authorised to use this command.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOUR_GREY, "You must be in a vehicle.");
new vehicleid = GetPlayerVehicleID(playerid);
if(VehicleSQLID[vehicleid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "This is not a saved vehicle.");
new Float:x, Float:y, Float:z, Float:a;
GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, Float:a);
VehSpawnX[vehicleid] = x;
MySQL_SetFloat(VehicleSQLID[vehicleid], "VehSpawnX", x, "vehicles");
VehSpawnY[vehicleid] = y;
MySQL_SetFloat(VehicleSQLID[vehicleid], "VehSpawnY", y, "vehicles");
VehSpawnZ[vehicleid] = z;
MySQL_SetFloat(VehicleSQLID[vehicleid], "VehSpawnZ", z, "vehicles");
VehSpawnAngle[vehicleid] = a;
MySQL_SetFloat(VehicleSQLID[vehicleid], "VehSpawnAngle", a, "vehicles");
SendClientMessage(playerid, COLOUR_ORANGE, "Vehicle Saved, It will now spawn here in the future.");
return 1;
}