[Ajuda] /mecanico - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (
https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] /mecanico (
/showthread.php?tid=463564)
/mecanico -
Speedpz - 12.09.2013
Bom alguem ajuda a colocar o comando /mecanico, para o player poder digitar de 3 em 3 minutos ?
pawn Код:
COMMAND:mecanico(playerid, params[])
{
// Setup local variables
new bool:AssistOnline = false, Msg[128], Name[24];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/mecanico", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Get the player's name
GetPlayerName(playerid, Name, sizeof(Name));
// Preset the message that needs to be sent to assistance players
format(Msg, 128, "{00FF00}O Player {FFFFFF}%s{00FF00} Pediu Mecanico!", Name);
// Check if there is at least one assistance player online
for (new i; i < MAX_PLAYERS; i++)
{
// Check if this player is connected
if (IsPlayerConnected(i))
{
// Check if this player is assistance class
if (APlayerData[i][PlayerClass] == ClassAssistance)
{
// Set the flag to indicate that at least one assistance player is online
AssistOnline = true;
// Send the assistance player a message to inform him who needs assistance
SendClientMessage(i, 0xFFFFFFFF, Msg);
}
}
}
// Check if there is at least one assistance player online
if (AssistOnline == true)
{
// Set yourself as "AssistanceNeeded"
APlayerData[playerid][AssistanceNeeded] = true;
// Let the player know he called for assistance
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Voce ja Pediu Assistencia");
}
else // No assistance is online
{
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Fully repair the vehicle (damage value and bodywork)
RepairVehicle(GetPlayerVehicleID(playerid));
// Also re-fuel the vehicle
AVehicleData[GetPlayerVehicleID(playerid)][Fuel] = MaxFuel;
// Let the player pay for the repairs and refuel (default $2000)
RewardPlayer(playerid, -2000, 0);
// Let the player know he spent $2000 for auto-repair because there were no assistance players online
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Seu Veiculo Foi Auto Reparado e Reabastecido Por R$:2000");
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Porque nao tem Mecanicos Online");
}
}
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
Re: /mecanico -
Juniiro3 - 12.09.2013
SetTimerEx
Re: /mecanico -
leonardoaparecido - 12.09.2013
Код:
new TempoFaltando[MAX_PLAYERS];
new Str[256];
new Timer;
CMD:teste(playerid)
{
if(TempoFaltando[playerid] != 0)
{
format(Str, 256, "Ainda faltam %i segundos para vocк poder usar este comando novamente", TempoFaltando[playerid]);
return SendClientMessage(playerid, -1, Str);
}
// FUNЗХES DO COMANDO
TempoFaltando[playerid] = 40;
Timer = SetTimerEx("DiminuirTempo", 1000, true, "i", playerid);
return 1;
}
forward DiminuirTempo(playerid);
public DiminuirTempo(playerid)
{
TempoFaltando[playerid]--;
if(TempoFaltando[playerid] == 0) KillTimer(Timer);
return 1;
}
Re: /mecanico -
iFox - 12.09.2013
PHP код:
COMMAND:mecanico(playerid, params[])
{
// Setup local variables
new bool:AssistOnline = false, Msg[128], Name[24];
if( GetPVarInt( playerid, "TempoComando" ) > GetTickCount() ) return SendClientMessage( playerid, -1, "Aguarde 3 minutos.." );
SetPVarInt( playerid, "TempoComando", GetTickCount() + 180000 );
// Send the command to all admins so they can see it
SendAdminText(playerid, "/mecanico", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Get the player's name
GetPlayerName(playerid, Name, sizeof(Name));
// Preset the message that needs to be sent to assistance players
format(Msg, 128, "{00FF00}O Player {FFFFFF}%s{00FF00} Pediu Mecanico!", Name);
// Check if there is at least one assistance player online
for (new i; i < MAX_PLAYERS; i++)
{
// Check if this player is connected
if (IsPlayerConnected(i))
{
// Check if this player is assistance class
if (APlayerData[i][PlayerClass] == ClassAssistance)
{
// Set the flag to indicate that at least one assistance player is online
AssistOnline = true;
// Send the assistance player a message to inform him who needs assistance
SendClientMessage(i, 0xFFFFFFFF, Msg);
}
}
}
// Check if there is at least one assistance player online
if (AssistOnline == true)
{
// Set yourself as "AssistanceNeeded"
APlayerData[playerid][AssistanceNeeded] = true;
// Let the player know he called for assistance
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Voce ja Pediu Assistencia");
}
else // No assistance is online
{
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Fully repair the vehicle (damage value and bodywork)
RepairVehicle(GetPlayerVehicleID(playerid));
// Also re-fuel the vehicle
AVehicleData[GetPlayerVehicleID(playerid)][Fuel] = MaxFuel;
// Let the player pay for the repairs and refuel (default $2000)
RewardPlayer(playerid, -2000, 0);
// Let the player know he spent $2000 for auto-repair because there were no assistance players online
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Seu Veiculo Foi Auto Reparado e Reabastecido Por R$:2000");
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Porque nao tem Mecanicos Online");
}
}
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}