Remove unoccupied Cars
#1

This is the code i use and when i do /deletevehicles its not deleting the cars

HELP ME FIX IT PLEASE :P

Код:
CMD:deletecars(playerid, params[])
{
	if(PlayerInfo[playerid][AdminLevel] >= 1)
	{
	    for(new v=0;v<MAX_VEHICLES;v++) if(!VehicleOccupied(v)) EraseVeh(v);
		SendClientMessage(playerid, COLOR_GREY, "All Unoccipied Vehicles Deleted!");
	}
	else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin Level 1 to use this command");
	return 1;
}
forward EraseVeh(vehicleid);
public EraseVeh(vehicleid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
	{
        new Float:X,Float:Y,Float:Z;
    	if(IsPlayerInAnyVehicle(i))
		{
  		RemovePlayerFromVehicle(i);
  		GetPlayerPos(i,X,Y,Z);
 		SetPlayerPos(i,X,Y+3,Z);
	    }
	    SetVehicleParamsForPlayer(vehicleid,i,0,1);
	}
    SetTimerEx("VehRes",1500,0,"i",vehicleid);
}
and i meant if you can create me one , thanks
Reply
#2

Код:
for(new i=0;i<MAX_PLAYERS;i++)
   {
     if(IsPlayerInVehicle(i,GetPlayerVehicleID(i)) == 0)
      {
        //your delete code here
       }
    }
Reply
#3

Quote:
Originally Posted by Rittik
Посмотреть сообщение
Код:
for(new i=0;i<MAX_PLAYERS;i++)
   {
     if(IsPlayerInVehicle(i,GetPlayerVehicleID(i)) == 0)
      {
        //your delete code here
       }
    }
This is the code i use and when i do /deletevehicles its not deleting the cars

Код:
CMD:deletecars(playerid, params[])
{
	if(PlayerInfo[playerid][AdminLevel] >= 1)
	{
	    for(new v=0;v<MAX_VEHICLES;v++) if(!VehicleOccupied(v)) EraseVeh(v);
		SendClientMessage(playerid, COLOR_GREY, "All Unoccipied Vehicles Deleted!");
	}
	else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin Level 1 to use this command");
	return 1;
}
forward EraseVeh(vehicleid);
public EraseVeh(vehicleid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
	{
        new Float:X,Float:Y,Float:Z;
    	if(IsPlayerInAnyVehicle(i))
		{
  		RemovePlayerFromVehicle(i);
  		GetPlayerPos(i,X,Y,Z);
 		SetPlayerPos(i,X,Y+3,Z);
	    }
	    SetVehicleParamsForPlayer(vehicleid,i,0,1);
	}
    SetTimerEx("VehRes",1500,0,"i",vehicleid);
}
and i meant if you can create me one , thanks
Reply
#4

Please anybody?
Reply
#5

here you go.
pawn Код:
CMD:deletecars(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 1)
    {
        new Iterator:UnoccupiedVehicles<MAX_VEHICLES>;
        foreach(new i : Player) Iter_Add(UnoccupiedVehicles, GetPlayerVehicleID(i));
        {
          for(new v = 0; v < MAX_VEHICLES; v++)
          {
             if(!Iter_Contains(UnoccupiedVehicles, v))
             {
               DestroyVehicle(v);
               SendClientMessage(playerid, COLOR_GREY, "All Unoccipied Vehicles Deleted!");
             }
          }
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin Level 1 to use this command");
    return 1;
}
Reply
#6

Quote:
Originally Posted by xGamerFx
Посмотреть сообщение
here you go.
pawn Код:
CMD:deletecars(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 1)
    {
        new Iterator:UnoccupiedVehicles<MAX_VEHICLES>;
        foreach(new i : Player) Iter_Add(UnoccupiedVehicles, GetPlayerVehicleID(i));
        {
          for(new v = 0; v < MAX_VEHICLES; v++)
          {
             if(!Iter_Contains(UnoccupiedVehicles, v))
             {
               DestroyVehicle(v);
               SendClientMessage(playerid, COLOR_GREY, "All Unoccipied Vehicles Deleted!");
             }
          }
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin Level 1 to use this command");
    return 1;
}
Thanks alot ! ) +REP

but , it spams "Vehicle deleted" like 200 times (for each vehicle that removed)
Reply
#7

pawn Код:
CMD:deletecars(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 1)
    {
        new Iterator:UnoccupiedVehicles<MAX_VEHICLES>;
        foreach(new i : Player) Iter_Add(UnoccupiedVehicles, GetPlayerVehicleID(i));
        {
          for(new v = 0; v < MAX_VEHICLES; v++)
          {
             if(!Iter_Contains(UnoccupiedVehicles, v))
             {
               DestroyVehicle(v);
             }
          }
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin Level 1 to use this command");
    SendClientMessage(playerid, COLOR_GREY, "All Unoccipied Vehicles Deleted!");
    return 1;
}
sorry and thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)