SA-MP Forums Archive
OnPlayerEnterVehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerEnterVehicle (/showthread.php?tid=193665)



OnPlayerEnterVehicle - AcId n RaPiD - 27.11.2010

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.


Re: OnPlayerEnterVehicle - Ruffles. - 27.11.2010

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.




Re: OnPlayerEnterVehicle - AcId n RaPiD - 27.11.2010

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?


Re: OnPlayerEnterVehicle - Kitten - 27.11.2010

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;
}



Re: OnPlayerEnterVehicle - Fj0rtizFredde - 27.11.2010

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;
}



Re: OnPlayerEnterVehicle - SuperS82 - 27.11.2010

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;
}



Re: OnPlayerEnterVehicle - AcId n RaPiD - 27.11.2010

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