SA-MP Forums Archive
Make Stock - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Make Stock (/showthread.php?tid=662518)



Make Stock - zZzTGTzZz - 03.01.2019

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;
}



Re: Make Stock - BlackBank - 03.01.2019

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.


Re: Make Stock - zZzTGTzZz - 04.01.2019

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


Re: Make Stock - GRiMMREAPER - 04.01.2019

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;
}



Re: Make Stock - CherryMond - 04.01.2019

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