08.07.2011, 08:50
I made a repair command wich cost 14500 but how to make it when i type /vehrepair the car repairs but i want after 2 minutes to type again with timer.How to do that!!
new
gVehDelay[ playerid ] = { -1, ... }
;
COMMAND:vehrepair( playerid, params[ ] )
{
if ( !IsPlayerInAnyVehicle( playerid ) )
return SendClientMessage( playerid, -1, "Silly boy, you are not in any vehicle." );
if ( gVehDelay[ playerid ] != -1 )
return SendClientMessage( playerid, -1, "Please wait before using the command again! Or pedobear will ate you." );
if ( GetPlayerMoney( playerid ) < 14500 )
return SendClientMessage( playerid, -1, "Not enough money. Kill a pedobear for money!" );
RepairVehicle( GetPlayerVehicleID( playerid ) );
gVehDelay[ playerid ] = 10;
SetTimerEx( "useRepairAgain", 120000, false, "i", playerid );
return 1;
}
forward useRepairAgain( playerid ); public useRepairAgain( playerid )
{
gVehDelay[ playerid ] = -1;
SendClientMessage( playerid, -1, "Now you can /repairveh your car again!" );
return 1;
}
forward repair(playerid);
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/vehrepair", true))
{
if(GetPVarInt(playerid, "repair") == 1) return SendClientMessage(playerid, 0x008000FF, "You repaired in the last two minutes!");
//.......
SetPVarInt(playerid, "repair", 1);
SetTimerEx("repair", 120000, false, "i", playerid);
return 1;
}
return 0;
}
public repair(playerid)
{
SetPVarInt(playerid, "repair", 0);
return 1;
}
new
gVehDelay[ playerid ] = { -1, ... }
;
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
if ( !strcmp( cmdtext, "/vehrepair", true ) )
{
if ( !IsPlayerInAnyVehicle( playerid ) )
return SendClientMessage( playerid, -1, "Silly boy, you are not in any vehicle." );
if ( gVehDelay[ playerid ] != -1 )
return SendClientMessage( playerid, -1, "Please wait before using the command again! Or pedobear will ate you." );
if ( GetPlayerMoney( playerid ) < 14500 )
return SendClientMessage( playerid, -1, "Not enough money. Kill a pedobear for money!" );
RepairVehicle( GetPlayerVehicleID( playerid ) );
gVehDelay[ playerid ] = 10;
SetTimerEx( "useRepairAgain", 120000, false, "i", playerid );
return 1;
}
return 0;
} // Ye I know, indentation sucks :D
forward useRepairAgain( playerid ); public useRepairAgain( playerid )
{
gVehDelay[ playerid ] = -1;
SendClientMessage( playerid, -1, "Now you can /repairveh your car again!" );
return 1;
}