SA-MP Forums Archive
Problem 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: Problem OnPlayerEnterVehicle (/showthread.php?tid=238680)



Problem OnPlayerEnterVehicle - Sn4ke - 12.03.2011

Hello, I have a little problem with this :

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(GetVehicleModel(vehicleid) == 425) {
        if(pRank[playerid] >= 3) {
        {
        SendClientMessage(playerid,COLOR_GREEN,"Welcome To The Hunter!");
        }
        }
        else SendClientMessage(playerid,COLOR_RED,"You must be a rank 3 or higher to drive this vehicle);
        GetPlayerVehicleID(playerid);
        ClearAnimations(playerid);
    }
        return 1;
When I try to enter in the hunter it say "You are not ..." , it's ok
But when I m rank 5 for example, it say "Welcome ..." but I can not enter in the hunter, it play "clear animation"

How can I solve this ? plz


Re: Problem OnPlayerEnterVehicle - antonio112 - 12.03.2011

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(GetVehicleModel(vehicleid) == 425)
        {
              if(pRank[playerid] >= 3) {
              {
                      SendClientMessage( playerid, COLOR_GREEN, "Welcome To The Hunter!" );
                      return 1;
              }
              else
              {
                      SendClientMessage( playerid, COLOR_RED, "You must be a rank 3 or higher to drive this vehicle." );
                      ClearAnimations( playerid );
              }
       
         }
         return 1;
Try it like this.


Re: Problem OnPlayerEnterVehicle - iMonk3y - 12.03.2011

What for was the GetPlayerVehicleID(playerid);

Anyways, this code shall work.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 425) {
        if(pRank[playerid] >= 3) SendClientMessage(playerid,COLOR_GREEN,"Welcome To The Hunter!");
        else {
            SendClientMessage(playerid,COLOR_RED,"You must be a rank 3 or higher to drive this vehicle");
            ClearAnimations(playerid);
        }
    }
    return 1;
}



Re : Problem OnPlayerEnterVehicle - Sn4ke - 12.03.2011

Thanks you very much , it work


Re: Problem OnPlayerEnterVehicle - Sasino97 - 12.03.2011

Quote:
Originally Posted by antonio112
Посмотреть сообщение
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(GetVehicleModel(vehicleid) == 425)
        {
              if(pRank[playerid] >= 3) {
              {
                      SendClientMessage( playerid, COLOR_GREEN, "Welcome To The Hunter!" );
                      return 1;
              }
              else
              {
                      SendClientMessage( playerid, COLOR_RED, "You must be a rank 3 or higher to drive this vehicle." );
                      RemovePlayerFromVehicle( playerid );
              }
       
         }
         return 1;
Try it like this.
RemovePlayerFromVehicle only works when a player is already in it, but OnPlayerEnterVehicle it's called when he performs the animation, so RemovePlayerFromVehicles won't work, I recommend ClearAnimations, that clears the Vehicle-entering animation, so players can't enter.


Re: Problem OnPlayerEnterVehicle - antonio112 - 12.03.2011

Oh yea, never tought about that. Thank you for clarification.