How could i manage to do this?
#1

I am making something and i need a cmd to keep a player in the vehicle when someone does a cmd.

How do i manage to do this?
Thanks in advance
Reply
#2

pawn Код:
if(strcmp(cmdtext, "/command", true) == 0)
{
    new veh = GetPlayerVehicleID(playerid);
    new seat = GetPlayerSeat(playerid);
    PutPlayerInVehicle(playerid, veh, seat);
    return 1;
}
Reply
#3

Quote:
Originally Posted by Antonio [G-RP]
Посмотреть сообщение
pawn Код:
if(strcmp(cmdtext, "/command", true) == 0)
{
    new veh = GetPlayerVehicleID(playerid);
    new seat = GetPlayerSeat(playerid);
    PutPlayerInVehicle(playerid, veh, seat);
    return 1;
}
+

pawn Код:
TogglePlayerControllable(playerid, false);
Reply
#4

Quote:
Originally Posted by Lorrden
Посмотреть сообщение
+

pawn Код:
TogglePlayerControllable(playerid, false);
Not necessarily necessary.
Reply
#5

He wants to prevent someone from leaving the car, so you do in fact need TogglePlayerControllable.
Reply
#6

Well, the code You prevented only puts the player in the exact same position as he was...
It's not keeping him there, and I think he meant something like "/kidnap [id]"..


Edit:

You should learn how to use sscanf if You don't already, It's a great function for using text/numbers or w/e after Your command, ex: /keepplayerinmyvehicle 8

pawn Код:
if(strcmp(cmdtext, "/command", true) == 0)
{
    new id = 0;
    if(sscanf(cmdtext, "d", id)) return SendClientMessage(playerid, 0xFFFFFFFF, "You need to enter an ID");
    if(GetPlayerVehicleID(id) != GetPlayerVehicleID(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "The player isn't in the same vehicle.");
    if(id == playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "Can't tie yourself up");
    TogglePlayerControllable(id, false);
    new string[256], idName[MAX_PLAYER_NAME], playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    GetPlayerName(id, idName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "You where tied up by %s.", playerName);
    SendClientMessage(id, 0xFFFFFFFF, string);
    format(string, sizeof(string), "You tied %s.", idName);
    return SendClientMessage(playerid, 0xFFFFFFFF, string);
}

Untested.
Reply
#7

Quote:
Originally Posted by Krx17
Посмотреть сообщение
He wants to prevent someone from leaving the car, so you do in fact need TogglePlayerControllable.
Putting the player back in the car works the same.
Reply
#8

I would do something like this:

pawn Код:
new bool : Kidnapped[MAX_PLAYERS];

public OnPlayerExitVehicle(playerid, vehicleid)
{
     if(Kidnapped[playerid] == true)
     {
          //return 0; If returning 0 here doesn't work.
          //PutPlayerInVehicle(playerid, vehicleid, GetPlayerSeat(playerid)); Try this.
          //if none of the above works, try clearing the player animation.
     }
     return 1;
}
Reply
#9

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
I would do something like this:

pawn Код:
new bool : Kidnapped[MAX_PLAYERS];

public OnPlayerExitVehicle(playerid, vehicleid)
{
     if(Kidnapped[playerid] == true)
     {
          //return 0; If returning 0 here doesn't work.
          //PutPlayerInVehicle(playerid, vehicleid, GetPlayerSeat(playerid)); Try this.
          //if none of the above works, try clearing the player animation.
     }
     return 1;
}
IF any of these actually would work which some probably will do..
It would still look like the player left the vehicle for all the other players.

Edit: Read my edit in the other post.
Reply
#10

Quote:
Originally Posted by Lorrden
Посмотреть сообщение
IF any of these actually would work which some probably will do..
It would still look like the player left the vehicle for all the other players.

Edit: Read my edit in the other post.
Returning 0; would stop the player from updating wouldn't it ? Correct me if i'm wrong.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)