Make Stock
#1

Good, I need to create a stock to detect me if the user is in the vehicle, I did this but it does not work for me.

Код:
stock Vehicle_ID(playerid)
{
    new VehicleGetID = GetPlayerVehicleID(playerid);
    return VehicleGetID ;
}

stock Trucker(playerid)
{
     for (new t = 0; t <sizeof (Vehicle_Trucker); t ++)
     {
          if (Vehicle_ID (playerid) == Vehicle_Trucker[t]) return 1;
          break;
      }
      return 0;
}
Reply
#2

Because it will break (stop) the loop after one iterate.

You should remove the break in your for-loop, also 'return' does already 'break' the loop, so no need for any extra break.
Reply
#3

Quote:
Originally Posted by BlackBank
Посмотреть сообщение
Because it will break (stop) the loop after one iterate.

You should remove the break in your for-loop, also 'return' does already 'break' the loop, so no need for any extra break.
Nope
Reply
#4

pawn Код:
stock Vehicle_ID(playerid)
{
    new VehicleGetID = GetPlayerVehicleID(playerid);
    return VehicleGetID ;
}

stock Trucker(playerid)
{
        for (new t = 0; t <sizeof (Vehicle_Trucker); t ++)
        {
            if (Vehicle_ID (playerid) == Vehicle_Trucker[t]) {
                return 1;
            }
        }
     
        return 0;
}
Reply
#5

https://sampwiki.blast.hk/wiki/IsPlayerInVehicle you can use
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)