How could i manage to do this? -
[NRP]Blade - 03.03.2011
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
Re: How could i manage to do this? -
Antonio [G-RP] - 03.03.2011
pawn Код:
if(strcmp(cmdtext, "/command", true) == 0)
{
new veh = GetPlayerVehicleID(playerid);
new seat = GetPlayerSeat(playerid);
PutPlayerInVehicle(playerid, veh, seat);
return 1;
}
Re: How could i manage to do this? -
Lorrden - 03.03.2011
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);
Re: How could i manage to do this? -
Antonio [G-RP] - 03.03.2011
Quote:
Originally Posted by Lorrden
+
pawn Код:
TogglePlayerControllable(playerid, false);
|
Not necessarily necessary.
Re: How could i manage to do this? -
Krx17 - 03.03.2011
He wants to prevent someone from leaving the car, so you do in fact need TogglePlayerControllable.
Re: How could i manage to do this? -
Lorrden - 03.03.2011
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.
Re: How could i manage to do this? -
Antonio [G-RP] - 03.03.2011
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.
Re: How could i manage to do this? -
Cameltoe - 03.03.2011
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;
}
Re: How could i manage to do this? -
Lorrden - 03.03.2011
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.
Re: How could i manage to do this? -
Cameltoe - 03.03.2011
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.