CMD:arearespawn(playerid, params[]) { new Float:radius; if(playerVariables[playerid][pAdminLevel] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!"); if(sscanf(params, "i", radius)) return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/arearespawn [Radius in Meters]"); GetPlayerPos(playerid, playerVariables[playerid][pPos][0], playerVariables[playerid][pPos][1], playerVariables[playerid][pPos][2]); for (new x = 0; x < MAX_VEHICLES; x++) { if(IsVehicleInRangeOfPoint(x, radius, playerVariables[playerid][pPos][0], playerVariables[playerid][pPos][1], playerVariables[playerid][pPos][2])) { SetVehicleToRespawnEx(x); format(szMessage, sizeof(szMessage), "You have respawned all cars within the radius of %i meters.", radius); SendClientMessage(playerid, COLOR_NICESKY, szMessage); format(szMessage, sizeof(szMessage), "AdmCmd:{FFFFFF} %s just performed an area respawn with the radius of %i meters.", playerVariables[playerid][pAdminName], radius); submitToAdmins(szMessage, COLOR_HOTORANGE); } } return 1; }
stock IsVehicleInRangeOfPoint(vehicleid, Float: radius, Float:x, Float:y, Float:z) { new Float:Floats[6]; GetVehiclePos(vehicleid, Floats[0], Floats[1], Floats[2]); Floats[3] = (Floats[0] -x); Floats[4] = (Floats[1] -y); Floats[5] = (Floats[2] -z); if (((Floats[3] < radius) && (Floats[3] > -radius)) && ((Floats[4] < radius) && (Floats[4] > -radius)) && ((Floats[5] < radius) && (Floats[5] > -radius))) return 1; return 0; }
RespawnNearbyVehicles(playerid, Float:radi)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i=1; i<MAX_VEHICLES; i++)
{
if(GetVehicleModel(i))
{
new Float:posx, Float:posy, Float:posz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetVehiclePos(i, posx, posy, posz);
tempposx = (posx - x);
tempposy = (posy - y);
tempposz = (posz - z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
SetVehicleToRespawn(i);
}
}
}
}
CMD:arearespawn(playerid, params[])
{
new Float:radius;
if(playerVariables[playerid][pAdminLevel] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
if(sscanf(params, "d", radius)) return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/arearespawn [Radius in Meters]");
if(radius < 1 || radius > 40)return SendClientMessage(playerid, -1, "Dot radio (1 - 40)");
RespawnNearbyVehicles(playerid, radius);
format(szMessage, sizeof(szMessage), "You have respawned all cars within the radius of %i meters.", radius);
SendClientMessage(playerid, COLOR_NICESKY, szMessage);
format(szMessage, sizeof(szMessage), "AdmCmd:{FFFFFF} %s just performed an area respawn with the radius of %i meters.", playerVariables[playerid][pAdminName], radius);
submitToAdmins(szMessage, COLOR_HOTORANGE);
return 1;
}
pawn Код:
pawn Код:
|