Get in player's vehicle as passenger
#1

dsadsadsadsa
Reply
#2

dasdasdasdasd
Reply
#3

IsPlayerInAnyVehicle??
Reply
#4

Doesn't help...
Reply
#5

https://sampwiki.blast.hk/wiki/PutPlayerInVehicle

PutPlayerInVehicle(playerid,vehicleid,seatid);

Quote:

0 - Driver
1 - Front Passenger
2 - Back left passenger
3 - Back right passenger
4+ - Passenger seats (coach etc.)

Reply
#6

sdadasdasd
Reply
#7

adfsdasdad
Reply
#8

First, you will need the following under your #includes

pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
And copy the following OnPlayerCommandText CallBack.
public OnPlayerCommandText(playerid, cmdtext[])
pawn Код:
{
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);

    if (strcmp("/cp", cmdtext, true, 10) == 0)
    {
        new targetplayer[MAX_PLAYER_NAME];
        targetplayer = strtok(cmdtext, idx);
        if(strlen(targetplayer) == 0) return SendClientMessage(playerid, -1, "USAGE: /cp [playerid]");
        if(!IsPlayerInAnyVehicle(strval(targetplayer))) return SendClientMessage(playerid, -1, "ERROR: Chosen player is not in any vehicle!");
        PutPlayerInVehicle(playerid, GetPlayerVehicleID(strval(targetplayer)), 1);
        SendClientMessage(playerid, -1, "(Info): You have successfuly teleported into a player's vehicle.");
        return 1;
    }
    return 0;
}
Should work, not tested.

NOTE: This may be buggy as it will always TP the player inside the front seat. ( Near the driver )
And if that seat is taken then..
Reply
#9

pawn Код:
LEANCMD:(seats)
{
SCM(playerid, COLOR_AO, "Carseats ID");
SCM(playerid, COLOR_AO, "0 - Driver");
SCM(playerid, COLOR_AO, "1 - Front Passenger");
SCM(playerid, COLOR_AO, "2 - Back left passenger");
SCM(playerid, COLOR_AO, "3 - Back right passenger");
return 1;
}



LEANCMD:(getin)
{
          new currentveh, id, seat;
          currentveh = GetPlayerVehicleID(playerid);
          if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid, COLOR_GREY, "You have to be inside a vehicle to teleport a player inside your car");
          if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
          if(sscanf(params, "ui", id, seat)) return SCM(playerid, COLOR_GREY, "/getin [partofname/playerid] [seat] [/seats to check seatIDs]");
          if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_GREY, "This player is not connected");
          if(IsPlayerInVehicle(id, currentveh))
          {
          RemovePlayerFromVehicle(id);
          PutPlayerInVehicle(id, currentveh, seat);
          }
          else
          {
          PutPlayerInVehicle(id, currentveh, seat);
          }
          return 1;
}


LEANCMD:(goin)
{
          new currentveh, id, seat;
          if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
          if(sscanf(params, "ui",id, seat)) return SCM(playerid, COLOR_GREY, "/goin [partofname/playerid] [seat] [/seats to check seatIDs]");
          if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_GREY, "This player is not connected");
          else
          {
          currentveh = GetPlayerVehicleID(id);
          PutPlayerInVehicle(playerid, currentveh, seat);
          }
          return 1;
}


here u go
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)