SA-MP Forums Archive
How do I make this? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How do I make this? (/showthread.php?tid=270600)



How do I make this? - grand.Theft.Otto - 21.07.2011

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?


Re: How do I make this? - [HiC]TheKiller - 21.07.2011

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



Re: How do I make this? - grand.Theft.Otto - 21.07.2011

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


Re: How do I make this? - Deskoft - 21.07.2011

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.


Re: How do I make this? - grand.Theft.Otto - 21.07.2011

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


Re: How do I make this? - Donya - 21.07.2011

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.


Re: How do I make this? - [HiC]TheKiller - 21.07.2011

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