Team Vehicles
#1

Hi,

How would i make it if a player entered a vehicle and they were in "gTeam A", but the Vehicle is in "gTeam PD", how would i make the Player Exit the vehicle?

I have this code but i dont know why it doesnt work... And what call back would i place it in?
Код:
    if(IsPlayerInVehicle(playerid, PDcar || PDcar1 || PDcar2 || PDcar3 || PDcar4 || PDcar5 ||PDcar6))
	{
 		if(gTeam[playerid] == PD)
 		{
 			SendClientMessage(playerid, 0x0000FFAA, "You are driving a police vehicle");
 			return 1;
 		}
 		else
		{
			RemovePlayerFromVehicle(playerid);
			SendClientMessage(playerid, 0xFF0000AA, "Join the police faction to drive this vehicle");
			return 1;
		}
	}
Reply
#2

What Error You Get?
Reply
#3

i dont get any error it just doesnt work ingame... If i enter the vehicle with a player in a gTeam other then PD it doesnt remove them from the vehicle or send the message, and if i enter with a player in gTeam PD it doesnt send the message to them...

I just need to know if that is the right way to make the function and what call back to put it in
Reply
#4

Try:

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
    {
        new v = GetPlayerVehicleID(playerid);
        if(v==PDcar || v==PDcar1 || v==PDcar2 || v==PDcar3 || v==PDcar4 || v==PDcar5 ||v==PDcar6)
        {
            if(gTeam[playerid] == PD)
            {
                SendClientMessage(playerid, 0x0000FFAA, "You are driving a police vehicle");
                return 1;
            }
            else
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, 0xFF0000AA, "Join the police faction to drive this vehicle");
                return 1;
            }
        }
    }
Reply
#5

Where do i put that? What Callback?
Reply
#6

pawn Код:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( newstate == PLAYER_STATE_DRIVER )
    {
        new veh = GetPlayerVehicleID( playerid );
       
        if( veh == PDcar1 || veh == PDcar2 || veh == PDcar3 || veh == PDcar4 || veh == PDcar5 || veh == PDcar6 )
        {
            if( gTeam[ playerid ] != PD ) // Guessing that PD defined as the team number.
            {
                RemovePlayerFromVehicle( playerid );
                SendClientMessage( playerid, 0xFF0000AA, "Join the police faction to drive this vehicle" );
            }
        }
    }
    return 1;
}
Untested. It would be better to put the PD cars in an array, then loop through it to check if 'veh' equals any of them.
Reply
#7

that doesnt work
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)