SA-MP Forums Archive
Need Help With Isplayerinvehicle - 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)
+--- Thread: Need Help With Isplayerinvehicle (/showthread.php?tid=436219)



Need Help With Isplayerinvehicle - GreTex - 10.05.2013

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



Re: Need Help With Isplayerinvehicle - smeti - 10.05.2013

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



Re: Need Help With Isplayerinvehicle - IceBilizard - 10.05.2013

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



Re: Need Help With Isplayerinvehicle - GreTex - 10.05.2013

only happens to NRG and FCR?
NOt Others?


Re: Need Help With Isplayerinvehicle - dannyk0ed - 10.05.2013

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.


Re: Need Help With Isplayerinvehicle - Private200 - 10.05.2013

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.


Re: Need Help With Isplayerinvehicle - RajatPawar - 10.05.2013

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.


Re: Need Help With Isplayerinvehicle - Vince - 10.05.2013

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.


Re: Need Help With Isplayerinvehicle - smeti - 10.05.2013

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


Re: Need Help With Isplayerinvehicle - RiChArD_A - 10.05.2013

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.