Command help :)
#1

All i need is when a player uses one of these 2 commands,to stop them from using them for the next 5minutes or less so they cant exploit score and money.Tnx in advance who helps
Код:
// 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;
Reply
#2

Alright i'll give you few ideas..
first , on top :
PHP код:
new cmdpossible[MAX_PLAYERS
OnGameModeInit()
PHP код:
cmdpossible[playerid] = 1
OnPlayerConnect :
PHP код:
cmdpossible[playerid] = 1
Now when the player types the command, you need to add this :
PHP код:
if(cmdpossible[playerid] == 1)
{
// your codes here etc.. then add the following :
cmdpossible[playerid] = 0;
SetTimerEx("waittimer"300000false"i"playerid); //here i made it for you 5minutes you can change it.
}
else
{
SendClientMessage(playeridCOLOR_RED"You need to wait 5 minutes before using this command again." 
Now somewhere but not under any callback :
PHP код:
forward waittimer(playerid);
public 
waittimer(playerid)
{
   
cmdpossible[playerid] = 1;

Just edit it if needed, i just gave few ideas on how to make it. Good luck!
Reply
#3

[I]On the top of your scripts :

PHP код:
new CommandAntiAbus[MAX_PLAYERS]; 
Under OnPlayerDeath :

PHP код:
CommandAntiAbus[playerid] =0//Reset the variable 
Add this to your commands :

PHP код:
if(CommandAntiAbus[playerid] >= 1)
    {
        
SendClientMessage(playerid,-1,"You should wait before using this command again.");
        return 
1;
    }
CommandAntiAbus[playerid] =300// 300 secondes = 5 minutes. 
Then :

PHP код:
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


Hope this helps ^^

KillerDVX,
Reply
#4

Tnx guys,REP +1
Reply
#5

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение
[I]On the top of your scripts :

PHP код:
new CommandAntiAbus[MAX_PLAYERS]; 
Under OnPlayerDeath :

PHP код:
CommandAntiAbus[playerid] =0//Reset the variable 
Add this to your commands :

PHP код:
if(CommandAntiAbus[playerid] >= 1)
    {
        
SendClientMessage(playerid,-1,"You should wait before using this command again.");
        return 
1;
    }
CommandAntiAbus[playerid] =300// 300 secondes = 5 minutes. 
Then :

PHP код:
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


Hope this helps ^^

KillerDVX,
PHP код:
 // This command allows the player to call for assistance
COMMAND:mehanicar(playeridparams[])
{
    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 falseMsg[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(playeridNamesizeof(Name));
        
// Preset the Message that needs to be sent to assistance players
        
format(Msg128"{00FF00}Igrac {FFFF00}%s{00FF00} treba popravak, idi i pomogni mu"Name);
        
// Check if there is at least one assistance player online
        
for (new iMAX_PLAYERSi++)
        {
            
// 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(i0xFFFFFFFFMsg);
                }
            }
        }
        
// 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(playerid0xFFFFFFFF"{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, -20000);
                
// Let the player know he spent $2000 for auto-repair because there were no assistance players online
                
SendClientMessage(playerid0xFFFFFFFF"{FF0000}Tvoje vozilo je napunjeno i popravljeno za $2000");
                
SendClientMessage(playerid0xFFFFFFFF"{FF0000}jer trenutno nema mehanicara online");
            }
        }
    }
    else
        return 
0;
    
// Let the server know that this was a valid command
    
return 1;

Where exactly should I add this?
PHP код:
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
Reply
#6

On the bottom of your scripts.

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)