Create a variable to track the last time the player drove the vehicle:
pawn Код:
new lastDriveTime[MAX_PLAYERS];
And then when the player successfully enters the vehicle (for the first time), update the variable to the current time:
pawn Код:
lastDriveTime[playerid] = gettime();
Then you have to check the time that has passed to determine whether or not the player should be allowed to enter the vehicle: (5*60 -> 60 seconds * 5 = 5 minutes)
pawn Код:
new timeSinceLastDrive = gettime() - lastDriveTime[playerid];
if(timeSinceLastDrive < (5*60)) ...
So to integrate into your code, something like the following...
pawn Код:
if ( newstate == PLAYER_STATE_DRIVER )
{
if ( PlayerInfo[ playerid ] [ rVip] == 0 )
{
if ( GetVehicleModel( GetPlayerVehicleID ( playerid ) ) == 447 )
{
RemovePlayerFromVehicle(playerid);
Announce( playerid, "~r~~h~You need to be R.Vip to use this car!", 3000, 4 );
}
}
// Check last drive time. We have to check if lastDriveTime is equal to 0, too, because it will be if the player has joined and hasn't driven the car yet.
new timeSinceLastDrive = gettime() - lastDriveTime[playerid];
if(timeSinceLastDrive < (5*60) || lastDriveTime[playerid] == 0) {
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid , COLOR_ULTRARED, "You need to wait 5 minutes before drive this car again");
}
}
// When the player has exited the vehicle, update their lastDriveTime
else if(oldstate == PLAYER_STATE_DRIVER) {
if ( GetVehicleModel( GetPlayerVehicleID ( playerid ) ) == 447 ) {
lastDriveTime[playerid] = gettime();
}
}