SA-MP Forums Archive
OnPlayerEnterVehicle. - 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: OnPlayerEnterVehicle. (/showthread.php?tid=436393)



OnPlayerEnterVehicle. - Hand-Scripter - 11.05.2013

Hello, I made a command that if the player enters the vehicle, a red marker shows up. But I want it to happen 1 time. So when I step out and step back in, I get the message again.

How can I make that it will be shown only once?

Here is my code:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    SendClientMessage(playerid, COLOR_LAVENDER, "Your GPS has added a red marker on your mini map.");
    SendClientMessage(playerid, COLOR_LAVENDER, "Go to the red marker.");
    SetPlayerCheckpoint(playerid, 2583.0303,1041.4889,10.8203, 5.0);
    return 1;
}
- Hand.


AW: OnPlayerEnterVehicle. - [AK]Nazgul - 11.05.2013

Create a new array
pawn Код:
new shown[MAX_PLAYERS];
When you enter the first time:
pawn Код:
shown[playerid] = 1;
Now everytime you enter check if it is 0 or one, so
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(shown[playerid] == 0)
{
    SendClientMessage(playerid, COLOR_LAVENDER, "Your GPS has added a red marker on your mini map.");
    SendClientMessage(playerid, COLOR_LAVENDER, "Go to the red marker.");
    SetPlayerCheckpoint(playerid, 2583.0303,1041.4889,10.8203, 5.0);
    return 1;
}
}