I'm a noob with Arrays, help? :D
#1

Alright, I want to check if he's one of these 5 cars. If he is then it sets the checkpoint. DMVCar 0 to 5.

pawn Код:
DMVcar[0] = AddStaticVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    DMVcar[1] = AddStaticVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    DMVcar[2] = AddStaticVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    DMVcar[3] = AddStaticVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
    DMVcar[4] = AddStaticVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1);
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(IsPlayerInVehicle(playerid, DMVCar[0] ??))
        {
            if(TakingDriverLicense[playerid] == true)
            {
                SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0);
            }
        }
    }
Reply
#2

Why not just do a loop, e.g.
for(new i=0; i<5; i++)
{
if(GetPlayerVehicleID(playerid) == DMVCar[i])
{
//Your code
}
}
Reply
#3

Thanks, seems logical.
Reply
#4

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        if(IsPlayerInVehicle(playerid, DMVCar[0] || IsPlayerInVehicle(playerid, DMVCar[1] || IsPlayerInVehicle(playerid, DMVCar[2] || IsPlayerInVehicle(playerid, DMVCar[3] || IsPlayerInVehicle(playerid, DMVCar[4]))
        {
            if(TakingDriverLicense[playerid] == true)
            {
                SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0);
            }
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)