Need Help With Isplayerinvehicle
#1

Hello Guys
Here's my Code
Which is not working
Whenever i enter any of these vehicles nothing show's up

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IsPlayerInVehicle(playerid, 522))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your NRG-500!");
    }
    if(IsPlayerInVehicle(playerid, 521))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your FCR-900!");
    }
    if(IsPlayerInVehicle(playerid, 461))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your PCJ-600!");
    }
    if(IsPlayerInVehicle(playerid, 448))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Pizza-Boy!");
    }
    if(IsPlayerInVehicle(playerid, 462))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Faggio!");
    }
    if(IsPlayerInVehicle(playerid, 463))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Freeway!");
    }
    if(IsPlayerInVehicle(playerid, 468))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Sanchez!");
    }
    if(IsPlayerInVehicle(playerid, 523))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your HPV-1000!");
    }
    if(IsPlayerInVehicle(playerid, 581))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your BF-400!");
    }
    if(IsPlayerInVehicle(playerid, 586))
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Wayfarer!");
    }
   


    return 1;
}
Reply
#2

Try:
pawn Код:
public
    OnPlayerStateChange(playerid, newstate, oldstate)
{

    if(newstate == PLAYER_STATE_DRIVER)
    {      
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case 522: SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your NRG-500!");
            case 521: SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your FCR-900!");
        }
    }
    return 1;
}
Reply
#3

try this one
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 522)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your NRG-500!");
    }
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 521)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your FCR-900!");
    }
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 461)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your PCJ-600!");
    }
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Pizza-Boy!");
    }
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 462)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Faggio!");
    }
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 463)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Freeway!");
    }
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 468)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Sanchez!");
    }
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 523)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your HPV-1000!");
    }
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 581)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your BF-400!");
    }
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 586)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Wayfarer!");
    }



    return 1;
}
Reply
#4

only happens to NRG and FCR?
NOt Others?
Reply
#5

Quote:
Originally Posted by smeti
Посмотреть сообщение
Try:
pawn Код:
public
    OnPlayerStateChange(playerid, newstate, oldstate)
{

    if(newstate == PLAYER_STATE_DRIVER)
    {      
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case 522: SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your NRG-500!");
            case 521: SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your FCR-900!");
        }
    }
    return 1;
}
Yes use a switch for this.
Reply
#6

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{

    if(newstate == PLAYER_STATE_DRIVER)
    {      
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 522)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your NRG-500!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 521)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your FCR-900!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 461)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your PCJ-600!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Pizza-Boy!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 462)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Faggio!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 463)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Freeway!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 468)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Sanchez!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 523)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your HPV-1000!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 581)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your BF-400!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 586)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Wayfarer!");
    }

    }
    return 1;
}
This shall work fine either. I haven't tested it, but it's ok I think.

EDIT: Tested and working fine.
Reply
#7

Quote:
Originally Posted by Private200
Посмотреть сообщение
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{

    if(newstate == PLAYER_STATE_DRIVER)
    {      
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 522)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your NRG-500!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 521)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your FCR-900!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 461)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your PCJ-600!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Pizza-Boy!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 462)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Faggio!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 463)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Freeway!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 468)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Sanchez!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 523)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your HPV-1000!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 581)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your BF-400!");
    }
    else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 586)
    {
        SendClientMessage(playerid,0xFFFFFFFFF,"Antifall has been automatically activated on your Wayfarer!");
    }

    }
    return 1;
}
This shall work fine either. I haven't tested it, but it's ok I think.
One word - switch.
Reply
#8

Quote:
Originally Posted by Private200
Посмотреть сообщение
This shall work fine either. I haven't tested it, but it's ok I think.

EDIT: Tested and working fine.
But is inefficient and MUCH slower, so your argument is invalid.
Reply
#9

Quote:
Originally Posted by GreTex
Посмотреть сообщение
only happens to NRG and FCR?
NOt Others?
Well, to write the rest.
Reply
#10

Quote:
Originally Posted by GreTex
Посмотреть сообщение
only happens to NRG and FCR?
NOt Others?
Because those are the only two vehicles that smeti added. You can add the rest if you want.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)