OnPlayerEnterVehicle
#1

How can I make it so that when I put in

pawn Код:
SendClientMessage(playerid, WHITE, "You have entered a car!");
in OnPlayerEnterVehicle, it'll only show for cars you enter, but not bikes.
Reply
#2

You have to define every car ID then like 400, 597, etc. I don't know how though, sorry. I'm more of a mapper than a scripter...

Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 34 seconds.

Reply
#3

Quote:
Originally Posted by Stuntkillas
Посмотреть сообщение
You have to define every car ID then like 400, 597, etc. I don't know how though, sorry. I'm more of a mapper than a scripter...
I know, but is there an example of the code?
Reply
#4

not sure might work
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == bikeid || vehicleid == bikeid || vehicleid == bikeid /*keep going untill ur dont */ )
    {
        SendClientMessage(playerid,COLOR,"You enter a bike");
    }
    return 1;
}
Reply
#5

You could use this function I found here at the forums
pawn Код:
IsBike(playerid,vehicleid) // Credits to the creator!
{
    #define MAX_BIKEZ 13

    new IsBikeA[MAX_BIKEZ] =
    {
        581,523,462,521,463,522,461,448,468,586
    };

    vehicleid = GetPlayerVehicleID(playerid);

    if(IsPlayerInVehicle(playerid,vehicleid))
    {
        for(new i = 0; i < MAX_BIKEZ; i++)
        {
            if(GetVehicleModel(vehicleid) == IsBikeA[i])
            {
                return true;
            }
        }
    }
    return false;
}
Then you could use it like:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{    
    if(!IsBike(playerid,vehicleid))    
    {        
        SendClientMessage(playerid,WHITE,"You have entered a car");        
    }    
    return 1;
}
Reply
#6

Or Alternatively you can use:
pawn Код:
public IsABike(carid)
{
    if(carid == 509||carid == 481||carid == 510||carid == 462||carid == 448||carid == 581||carid == 522||carid == 461||carid == 521||carid == 523||carid == 463||carid == 586||carid == 468||carid == 471)
    {
        return 1;
    }
    return 0;
}
And use it like this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(!IsABike(playerid,vehicleid))
        {
                SendClientMessage(playerid,WHITE,"You have entered a car");
        }
        return 1;
}
Reply
#7

Thank you everyone for your wise help . I appreciate it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)