18.02.2011, 10:05
Here is a better way:
GameModeInit:
About SetTimerEx, it's crazy because every one will run that timer.
And OnPlayerConnect will be the same, because SetTimer sets a GLOBAL timer, and SetTimerEx sets a timer for only one playerid. Use that code, it's gonna loop through all players and REPAIR the vehicle, not just set the HP to 1000.
GameModeInit:
pawn Код:
SetTimer( "VehicleHealth", 3000, true );
pawn Код:
forward VehicleHealth( );
public VehicleHealth( )
{
for( new i = 0; i < MAX_PLAYERS; i++ )
{
if( IsPlayerConnected( i ) )
{
if( IsPlayerInAnyVehicle( i ) )
{
new vehicleid = GetPlayerVehicleID( i );
RepairVehicle( vehicleid );
}
}
}
return 1;
}
And OnPlayerConnect will be the same, because SetTimer sets a GLOBAL timer, and SetTimerEx sets a timer for only one playerid. Use that code, it's gonna loop through all players and REPAIR the vehicle, not just set the HP to 1000.