Is my command will work
#1

hello, is my command will work ? if any wrong please help me

PHP код:
CMD:removeucar(playerid,params[])
{
    if(
PlayerInfo[playerid][pAdmin] < && !IsPlayerAdmin(playerid)) return SendClientMessageplayerid, -1"You Must Be Higher Level To To Use This Command");
    {
       for(new 
0MAX_VEHICLEvv++)
       {
          for(new 
0MAX_PLAYERSi++)
          {
             if(!
IsPlayerInVehicle(iivv))
             {
               
DestroyVehicle(vv);
             }
          }
       }
    }
    return 
1;

Reply
#2

There are many issues with it. Having "i" twice and increasing "vv" and then using "ii" which are both undefined symbols.

It will also remove (if you fix those I mentioned above) the vehicle if the player with ID 0 is not in that vehicle.

Vehicles starts from 1, not 0 and you should use foreach to reduce the times the loop for the players gets called.

pawn Код:
CMD:removeucar(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage( playerid, -1, "You Must Be Higher Level To To Use This Command");
    for (new v = 1; v < MAX_VEHICLES; v++)
    {
        if (!GetVehicleModel(v)) continue; // vehicle does not exist, skip the players loop
        if (!IsVehicleOccupied(v)) DestroyVehicle(v);
    }
    return 1;
}

IsVehicleOccupied(vehicleid)
{
    foreach(new i : Player)
    {
        if (IsPlayerInVehicle(i, vehicleid)) return 1;
    }
    return 0;
}
Reply
#3

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)