Eject surfing players
#1

Hello guys.
I was looking arround for a Eject command for players who are surfing on the car (standing on the roof).
Can someone help me with a command /eject witch drops the players from the car? Not from inside seats.

This is mine but I need one to eject and the players who stand on the car.

Код:
CMD:eject(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(IsPlayerConnected(playerid))
   	{
        new State;
        if(IsPlayerInAnyVehicle(playerid))
        {
			new id,string[128],giveplayer[25];
		 	State=GetPlayerState(playerid);
	        if(State!=PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_WHITE, "{FFB870}You can only eject people as the driver.");
			if(sscanf(params, "u",id)) return SCM(playerid,0xFFFFFFFF, "{FF9900}Scrie: {33CCFF}/eject <Name/Playerid>");
			new test;
			test = GetPlayerVehicleID(playerid);
			if(IsPlayerConnected(id))
			{
			    if(id != INVALID_PLAYER_ID)
			    {
					if(PlayerTied[id] > 0) return SendClientMessage(playerid, COLOR_WHITE, "{FFB870}Player have tie.");
			        if(id == playerid) return SendClientMessage(playerid, COLOR_WHITE, "{FFB870}You cannot eject yourself.");
			        if(IsPlayerInVehicle(id,test))
			        {
						new PName[MAX_PLAYER_NAME];
						GetPlayerName(playerid,PName,sizeof(PName));
						GetPlayerName(id, giveplayer, sizeof(giveplayer));
						format(string, sizeof(string), "* You have thrown %s out of the car!", giveplayer);
						SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
						format(string, sizeof(string), "* You have been thrown out the car by %s !", PName);
						SendClientMessage(id, COLOR_LIGHTBLUE, string);
						RemovePlayerFromVehicleEx(id);
						return 1;
					}
					else
					{
					    SendClientMessage(playerid, COLOR_WHITE, "{FFB870}That player is not in your car.");
					    return 1;
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: Player not connected.");
			}
		}
		else
		{
		    SendClientMessage(playerid, COLOR_WHITE, "{FFB870}You need to be in a vehicle to use this.");
		}
	}
	return 1;
}
Thank you so much for help!
+REP
Reply
#2

First and foremost, you can use the GetPlayerSurfingVehicleID function to check if the player is surfing on the roof. Example of checking if someone is:
1. Surfing on any car:
pawn Код:
if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID)
{
     // do things here
}
2. Surfing on a specific car
pawn Код:
if(GetPlayerSurfingVehicleID(playerid) == vehicleid)
{
     // do something here
}
Secondly, you can use the SetPlayerVelocity(or even SetPlayerPos) function to move the player off of the car. For example, you can slap the player into the air.

pawn Код:
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z + 6.0);
Reply
#3

Код:
if(IsPlayerInVehicle(id,test))
This argument won't work because if that specific player is surfing, they don't partake a seat of the vehicle.
Reply
#4

Quote:
Originally Posted by Abagail
Посмотреть сообщение
First and foremost, you can use the GetPlayerSurfingVehicleID function to check if the player is surfing on the roof. Example of checking if someone is:
1. Surfing on any car:
pawn Код:
if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID)
{
     // do things here
}
2. Surfing on a specific car
pawn Код:
if(GetPlayerSurfingVehicleID(playerid) == vehicleid)
{
     // do something here
}
Secondly, you can use the SetPlayerVelocity(or even SetPlayerPos) function to move the player off of the car. For example, you can slap the player into the air.

pawn Код:
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z + 6.0);
All this I have to put them into my /eject command? or ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)