Help with command
#1

Hi, how can i make command that respawn all Closes vehicle in specific radius, for ex. i want to respawn all vehicle that are in 25 radus from me. if someone have that command can it give me
Reply
#2

Wrong section..
Reply
#3

where to post this i am new to forum, please give me link
Reply
#4

Maybe here
http://forum.sa-mp.com/showthread.ph...7813&page=1079
Reply
#5

Here is the command +REP if helped
Код:
CMD:respawncars(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 3)
	{
		new string[128], radius;
		if(sscanf(params, "d", radius)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /respawncars [radius]");

		if(radius < 1 || radius > 10000)
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "Radius must be higher than 0 and lower than 1000!");
			return 1;
		}
		RespawnNearbyVehicles(playerid, radius);
		format(string, sizeof(string), "You have respawned all vehicles within a radius of %d.", radius);
		SendClientMessageEx(playerid, COLOR_GREY, string);
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
	}
	return 1;
}
Reply
#6

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
Here is the command +REP if helped
Код:
		RespawnNearbyVehicles(playerid, radius);
If you don't provide that function you're not helping. Does that mean I can give you -REP (if it were still possible)?

@OP: you want to create a vehicle loop and then check the distance for each vehicle. I recommend using IsVehicleStreamedIn to only respawn those vehicles that are currently within the stream distance. I believe this will be the fastest; distance calculation is quite expensive.

PHP код:
for(new 1GetVehiclePoolSize(); <= ji++)
{
    if(
IsVehicleStreamedIn(iplayerid))
    {
        
SetVehicleToRespawn(i);
    }

Reply
#7

Thank's but i find this on other forum (i didn't know how i didn't find before posting)

This works 100%

Код:
stock 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);
}
}
}
}

Command:

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, "f", 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 %f meters.", radius);
SendClientMessage(playerid, COLOR_NICESKY, szMessage);
format(szMessage, sizeof(szMessage), "AdmCmd:{FFFFFF} %s just performed an area respawn with the radius of %f meters.", playerVariables[playerid][pAdminName], radius);
submitToAdmins(szMessage, COLOR_HOTORANGE);
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)