28.01.2010, 11:18
I am using timers in an auto repair script and am wondering if it is best to have a timer running constantly presuming there will be at least 1 player in a car at all times?
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
if((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
RepairVehicle(vehicleid);
SendClientMessage(playerid,COLOR_GREEN, "Your vehicle has been repaired.");
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_RED,"You're not the driver of this vehicle!");
return 1;
}
if(IsPlayerInAnyVehicle(playerid) != PLAYER_STATE_DRIVER )
{
SendClientMessage(playerid,COLOR_RED, "You're not in a vehicle!");
return 1;
}
}
}
}
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
if((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
{
if( !IsPlayerInAnyVehicle ( playerid ) )
{
SendClientMessage(playerid,COLOR_RED, "You're not in a vehicle!");
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
RepairVehicle(vehicleid);
SendClientMessage(playerid,COLOR_GREEN, "Your vehicle has been repaired.");
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_RED,"You're not the driver of this vehicle!");
return 1;
}
}
}
return 1;
}
Originally Posted by WrathOfGenesis
He wants a script that autorepairs without the need for a key press for stunt servers etc
Also biltong, try this pawn Код:
|