DeleteUnusedCars cmd?
#1

hello

the thread name says it all. I tried to make an "deleteallcars" command but it dont works

Код:
if(strcmp(cmd, "/deleteallcars", true) == 0 || strcmp(cmd, "/dac", true) == 0)
{
 	if(IsPlayerConnected(playerid))
  	{
	  	if(PlayerInfo[playerid][Level] >= 4)
		{
			new bool:unwanted[128];
			for(new player=0; player<MAX_PLAYERS; player++)
	   		{
	      	if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
	   		}
			for(new car = 91; car >= 90; car++)
			{
				if(!unwanted[car]) DestroyVehicle(car);
			}
			new pname[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
			format(string, sizeof(string), "SERVER: All unused cars deleted by %s.", pname);
			SendClientMessageToAll(COLOR_WHITE,string);
		}
		else
		{
		 	SendClientMessage(playerid, red, "you are not authorized to use this command!");
		  	return 1;
		}
	}
	return 1;
}
can somebody say me what I did wrong? or can somebody make me an working script?
Reply
#2

pawn Код:
if(strcmp(cmd, "/deleteallcars", true) == 0 || strcmp(cmd, "/dac", true) == 0)
{
    if(PlayerInfo[playerid][Level] >= 4)
    {
        for(new veh=1; veh<MAX_VEHICLES; veh++)
            if(GetVehicleModel(veh))
                for(new player; player<MAX_PLAYERS; player++)
                    if(IsPlayerConnected(player))
                        if(!IsPlayerInVehicle(player,veh))
                            DestroyVehicle(veh);
        new pname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
        format(string, sizeof(string), "SERVER: All unused cars deleted by %s.",pname);
        SendClientMessageToAll(COLOR_WHITE,string);
    }else SendClientMessage(playerid, red, "you are not authorized to use this command!");
    return 1;
}
Reply
#3

thanks it works but I wanted to delete all cars ID 91+
should i just change the veh=1 to veh=91 or something?

/edit: i tried it, now it works very well thanks mate
Reply
#4

Use MAX_VEHICLES?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)