Put player in random vehicle
#1

hey,

I made a function to spawn a random vehicle and place the player into it when they spawn but it dosent work. It spawns the player normally.

Anyone know why?:


pawn Код:
new Vehicleid[MAX_PLAYERS];
forward RandomVeh(playerid);
pawn Код:
public OnPlayerSpawn(playerid)
{
   PutPlayerInVehicle(playerid,RandomVeh(playerid), 0);
}
pawn Код:
public RandomVeh(playerid)
{
   new boobies = random(26);
   switch (boobies)
   {
    case 0:
        {
            Vehicleid[playerid] = CreateVehicle(411,-469.5962,2521.1050,125.3134,249.1143,1,1,3);
        }
        case 1:
        {
            Vehicleid[playerid] = CreateVehicle(411,-457.8935,2502.9167,124.5608,313.4709,1,1, 3);
        }
        case 2:
        {
            Vehicleid[playerid] = CreateVehicle(411,-451.8622,2478.0981,124.5602,313.1304,1,1,3);
        }
        case 3:
        {
            Vehicleid[playerid] = CreateVehicle(411,-442.2229,2465.4006,125.1623,351.5787,1,1,3);
        }
        case 4:
        {
            Vehicleid[playerid] = CreateVehicle(411,-429.3552,2471.1995,124.5606,358.3449,1,1,3);
        }
        case 5:
        {
            Vehicleid[playerid] = CreateVehicle(411,-420.8778,2473.8040,124.5606,16.8619,1,1,3);
        }
        case 6:
        {
            Vehicleid[playerid] = CreateVehicle(411,-412.7175,2476.7532,124.5605,38.1082,1,1,3);
        }
        case 7:
        {
         Vehicleid[playerid] = CreateVehicle(411,-407.1301,2483.1860,124.5606,44.7799,1,1,3);
        }
        case 8:
        {
            Vehicleid[playerid] = CreateVehicle(411,-409.7662,2478.5032,124.5606,34.5996,1,1,3);
        }
        case 9:
        {
            Vehicleid[playerid] = CreateVehicle(411,-403.0266,2487.0828,124.5606,59.4878,1,1,3);
        }
        case 10:
        {
             Vehicleid[playerid] = CreateVehicle(411,-393.8206,2481.6499,125.4139,60.2315,1,1,3);
        }
        case 11:
        {
             Vehicleid[playerid] = CreateVehicle(411,-396.7999,2498.3989,124.5676,71.8159,1,1,3);
        }
        case 12:
        {
            Vehicleid[playerid] = CreateVehicle(402,-397.7116,2493.0679,124.6653,59.9376,30,30,3);
        }
        case 13:
        {
            Vehicleid[playerid] = CreateVehicle(411,-395.7661,2505.6760,124.5624,83.5602,1,1,3);
        }
        case 14:
        {
              Vehicleid[playerid] = CreateVehicle(411,-394.9870,2516.2319,124.5658,105.0108,1,1,3);
        }
        case 15:
         {
             Vehicleid[playerid] = CreateVehicle(411,-401.3512,2527.6692,124.5607,130.6372,1,1,3);
        }
        case 16:
         {
             Vehicleid[playerid] = CreateVehicle(411,-405.9416,2532.2637,124.5621,137.6030,1,1,3);
        }
        case 17:
        {
            Vehicleid[playerid] = CreateVehicle(411,-412.3807,2536.5315,124.5606,150.5883,1,1,3);
        }
        case 18:
         {
            Vehicleid[playerid] = CreateVehicle(411,-416.6055,2546.7832,125.4737,168.9043,1,1,3);
        }
        case 19:
        {
            Vehicleid[playerid] = CreateVehicle(411,-428.0785,2538.7432,124.5606,178.3819,1,1,3);
        }
        case 20:
        {
            Vehicleid[playerid] = CreateVehicle(411,-437.1469,2541.4150,124.5606,191.6602,1,1,3);
        }
        case 21:
        {
            Vehicleid[playerid] = CreateVehicle(411,-443.0573,2536.9937,124.5623,201.8283,1,1,3);
        }
        case 22:
         {
             Vehicleid[playerid] = CreateVehicle(411,-454.0745,2531.2119,124.5641,218.1948,1,1,3);
        }
        case 23:
        {
        Vehicleid[playerid] = CreateVehicle(411,-460.4201,2523.6321,124.5606,240.4058,1,1,3);
        }
        case 24:
        {
            Vehicleid[playerid] = CreateVehicle(411,-460.8127,2517.9548,124.5606,252.3343,1,1,3);
        }
        case 25:
        {
          Vehicleid[playerid] = CreateVehicle(411,-471.4390,2521.2908,125.9707,252.6282,1,4,3);
        }
    }
}
Reply
#2

Add this on the last line:
Код:
return Vehicleid[playerid];
Reply
#3

Thanks!

works now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)