How do I make this?
#1

When a player enters a car for the first time, I want it to give them a wanted level. If they exit then enter the same car again, it shouldn't give any wanted level, and same if they enter a new vehicle and not the same, it gives a wanted level etc...

How do I do it?
Reply
#2

You could just use a basic variable to save the players last car. I take it you are doing this for a police car and a civilian is entering it for the second time.

pawn Код:
new lastvehicle[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    lastvehicle[playerid] = -1;
    return 1;
}

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == 2)
    {
        if(lastvehicle[playerid] == GetPlayerVehicleID(playerid))
        {
            //Same vehicle
        }
        if(lastvehicle[playerid] != GetPlayerVehicleID(playerid))
        {
            //Different vehicle.
            lastvehicle[playerid] = GetPlayerVehicleID(playerid);
            if(GetVehicleModel(GetPlayerVehicleID(playerid) == /*Certain vehicle model*/)
            {
                //Set the player's wanted level!
            }
        }
    }
    return 1;
}
Reply
#3

Thanks, and yes it is for the cop cars, but I want it for all and any vehicle, not just one.
Reply
#4

pawn Код:
new lastvehicle[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    lastvehicle[playerid] = -1;
    return 1;
}

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == 2)
    {
      // WANTED LEVEL here.
    }
    return 1;
}
Edited from the post above, modified for your request.
Reply
#5

That won't work, it still gives the wanted level each time the same vehicle is entered.
Reply
#6

pawn Код:
new lastvehicle[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    lastvehicle[playerid] = -1;
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger) lastvehicle[playerid] = vehicleid;
}

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == 2)
    {
        if(lastvehicle[playerid] != GetPlayerVehicleID(playerid))
        {
            //Different vehicle. do code here
           
        }
    }
    return 1;
}
Quote:
Originally Posted by Deskoft
Посмотреть сообщение
Edited from the post above, modified for your request.
You made it worst.
Reply
#7

I forgot to add the setting of the variable.
pawn Код:
new lastvehicle[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    lastvehicle[playerid] = -1;
    return 1;
}

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == 2)
    {
        if(lastvehicle[playerid] != GetPlayerVehicleID(playerid))
        {
            lastvehicle[playerid] = GetPlayerVehicleID(playerid);
            //Different vehicle
           
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)