// This command allows the player to call for assistance COMMAND:mehanicar(playerid, params[]) { if((GetTickCount() - Asisteri[playerid]) < 10){ return SendClientMessage(playerid, 0xFFFFFF, "[ANTI-SPAM]Nemozes koristit kommandu /mehanicar, moras malo sacekati"); } else{ Asisteri[playerid] = GetTickCount(); } // Setup local variables new bool:AssistOnline = false, Msg[128], Name[24]; // Send the command to all admins so they can see it SendAdminText(playerid, "/mehanicar", 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}Igrac {FFFF00}%s{00FF00} treba popravak, idi i pomogni mu", 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, "{00FF00}Pozvao si mehanicara"); } 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, "{FF0000}Tvoje vozilo je napunjeno i popravljeno za $2000"); SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}jer trenutno nema mehanicara online"); } } } else return 0; // Let the server know that this was a valid command return 1; }
//MEDIC COMMAND:zivot(playerid, params[]) { if((GetTickCount() - Mediceri[playerid]) < 10){ return SendClientMessage(playerid, 0xFFFFFF, "[ANTI-SPAM]Kommandu /zivot mozes Komandat nakon nekog vremena"); } else{ Mediceri[playerid] = GetTickCount(); } // Setup local variables new bool:MedicOnline = false, Msg[128], Name[24]; // Send the command to all admins so they can see it SendAdminText(playerid, "/zivot", 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}Igrac {FFFF00}%s{00FF00} treba pomoc, idi i izlijeci ga", 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] == ClassMedic) { // Set the flag to indicate that at least one assistance player is online MedicOnline = 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 (MedicOnline == true) { // Set yourself as "AssistanceNeeded" APlayerData[playerid][MedicNeeded] = true; // Let the player know he called for assistance SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Pozvao si liječnika"); } else // No assistance is online { SetPlayerHealth(playerid, 100); SetPlayerDrunkLevel(playerid, 0); // Also re-fuel the vehicle RewardPlayer(playerid, -1000, 0); // Let the player know he spent $2000 for auto-repair because there were no assistance players online SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Automatski si izliječen za $1000 jer nema niti jednog bolničara online"); } } else return 0;
new cmdpossible[MAX_PLAYERS]
cmdpossible[playerid] = 1;
cmdpossible[playerid] = 1;
if(cmdpossible[playerid] == 1)
{
// your codes here etc.. then add the following :
cmdpossible[playerid] = 0;
SetTimerEx("waittimer", 300000, false, "i", playerid); //here i made it for you 5minutes you can change it.
}
else
{
SendClientMessage(playerid, COLOR_RED, "You need to wait 5 minutes before using this command again."
forward waittimer(playerid);
public waittimer(playerid)
{
cmdpossible[playerid] = 1;
}
new CommandAntiAbus[MAX_PLAYERS];
CommandAntiAbus[playerid] =0; //Reset the variable
if(CommandAntiAbus[playerid] >= 1)
{
SendClientMessage(playerid,-1,"You should wait before using this command again.");
return 1;
}
CommandAntiAbus[playerid] =300; // 300 secondes = 5 minutes.
forward PlayerOneSecondVariables();
public PlayerOneSecondVariables()
{
foreach(new i:Player) //Loop through all players
{
//The time you set (5 minutes) will start to decrease
if(CommandAntiAbus[i] >= 1)
{
CommandAntiAbus[i] --;
}
return 1;
}[/i]
[I]On the top of your scripts :
PHP код:
PHP код:
PHP код:
PHP код:
Hope this helps ^^ KillerDVX, |
// This command allows the player to call for assistance
COMMAND:mehanicar(playerid, params[])
{
if(CommandAntiAbus[playerid] >= 1)
{
SendClientMessage(playerid,-1,"You should wait before using this command again.");
return 1;
}
CommandAntiAbus[playerid] =300; // 300 secondes = 5 minutes.
// Setup local variables
new bool:AssistOnline = false, Msg[128], Name[24];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/mehanicar", 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}Igrac {FFFF00}%s{00FF00} treba popravak, idi i pomogni mu", 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, "{00FF00}Pozvao si mehanicara");
}
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, "{FF0000}Tvoje vozilo je napunjeno i popravljeno za $2000");
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}jer trenutno nema mehanicara online");
}
}
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
forward PlayerOneSecondVariables();
public PlayerOneSecondVariables()
{
foreach(new i:Player) //Loop through all players
{
//The time you set (5 minutes) will start to decrease
if(CommandAntiAbus[i] >= 1)
{
CommandAntiAbus[i] --;
}
return 1;
}[/i]