21.12.2013, 23:48
Hey guys, I wanted to create a command to respawn cars within a certain radius of the player using the command so you don't have to respawn all the server's cars if only one area is messed up.
But if I get in game and type in the right format just nothing happens. And I do not get any error back when compiling. Any ideas?
But if I get in game and type in the right format just nothing happens. And I do not get any error back when compiling. Any ideas?
Код:
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;
}


