Problem OnPlayerEnterVehicle
#1

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
Reply
#2

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.
Reply
#3

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;
}
Reply
#4

Thanks you very much , it work
Reply
#5

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.
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)