How to make command like /Command ID
#1

So i have this basic(yes, REALLY Basic, to ban people that use REALLY lame cheats) function here:

Код:
stock AntiHPhackCheck( )
{
	new Thehealth[10]
	GetPlayerHealth(playerid,Thehealth);
	if Thehealth >100
	{
		BanEx(playerid,Health Hacking);
	}
	
	return 1;
	
}
And i want to make a /CheckHpHack [ID] command for it, but i have no idea of how to do the [ID] part of the command.

Help?
Reply
#2

pawn Код:
COMMAND:chh(playerid, params[])
{
    new targetid = strval(params);
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /chh [ID]");
    else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "Player not found!");
    {
        new Float:Health;
        GetPlayerHealth(targetid, Health);
        if(Health > 100.0)
        {
            BanEx(strval(params), "Health Hacks");
        }
    }
    return 1;
}
Reply
#3

so,

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/CMD HERE", cmdtext, true, 10) == 0)

        //do sumthin here
doesnt work with params? damn XD.

Thanks bro.

Unknown Command -.-

EDIT1:it also gives a warning saying the CMD is never used, but shouldnt it use it when you type /Commandhere?

Hold on ima experiment some stuff.

EDIT2:

using this

Код:
COMMAND:CheckHH(playerid, params[])
{
    new targetid = strval(params);
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /CheckHH [ID]");
    else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "Bad Player ID");
    {
        new Float:playerHealth;
        GetPlayerHealth(targetid, playerHealth);
        if(Health > 100.0)
        {
            BanEx(strval(params), "Health Hacks");
        }
		else if(Health < 101.0) return SendClientMessage(playerid,0x01FF0A, "Player doesnt HP hax(or does he?)";
    }
    return 1;
}
Anything wrong or missing? when i compile it still says its not used, and i tried putting it in OnGameModeInit and it gave me some serious errors.
Reply
#4

Don't put zcmd in any function.
Reply
#5

You need to drop down ZCMD command's under in your script. You can use strcmp inside OnPlayerCommand.
Show your current code.
Reply
#6

The current code is

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	
	if (strcmp("/Restartserver", cmdtext, true, 10) == 0)
  	if(IsPlayerAdmin(playerid))
    SendRconCommand("gmx");
	
	
	else if (strcmp("/Checkhh", cmdtext, true, 10) == 0)
	{
	new params;
	    new targetid = strval(params);
    	if(isnull(params)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /CheckHH [ID]");
    	else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "Bad Player ID");
   	 	{
        	new Float:playerHealth;
        	GetPlayerHealth(targetid, playerHealth);
        	if(Health > 100.0)
    		{
            BanEx(strval(params), "Health Hacks");
        	}
		else if(Health < 101.0) return SendClientMessage(playerid,0x01FF0A, "Player doesnt HP hax(or does he?)";
	}
		}
i know most is really wrong right now because i overewrote my code with the code that guy gave and it didnt work,
to be clear i wanna do a /Checkhh [ID] command which checks if the health is more than 100, if it is, it will ban the player.
Reply
#7

pawn Код:
CMD:checkhh(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /CheckHH [ID]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000FF, "Bad Player ID");
    new Float:playerHealth;
    GetPlayerHealth(targetid, playerHealth);
    if(playerHealth > 100.0)
    {
        BanEx(targetid, "Health Hacks");
    }
    else
    {
        SendClientMessage(playerid,0x01FF0AFF, "Player doesnt HP hax(or does he?)";
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/Restartserver", cmdtext, true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            SendRconCommand("gmx");
            return 1;
        }
    }
Reply
#8

Trying it now.

EDIT:The same Warning thing on compile(CheckHH symbol never used) and server says unknown command.
Reply
#9

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
pawn Код:
CMD:checkhh(playerid, params[])
{
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /CheckHH [ID]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000FF, "Bad Player ID");
    new Float:playerHealth;
    GetPlayerHealth(targetid, playerHealth);
    if(playerHealth > 100.0)
    {
        BanEx(targetid, "Health Hacks");
    }
    else
    {
        SendClientMessage(playerid,0x01FF0AFF, "Player doesnt HP hax(or does he?)";
    }
    return 1;
}
@above = good
But it's ZCMD OR stcmp so you may not use OnPlayerCommandText()

So it's this: + the code above ^^
pawn Код:
CMD:restartserver(playerid,params[])
    {
        if(IsPlayerAdmin(playerid)) SendRconCommand("gmx");
        return 1;
    }
Reply
#10

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[64], params[128];
    sscanf(cmdtext, "s[64]s[128]", cmd, params);
   
    if (strcmp("/Restartserver", cmdtext, true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            SendRconCommand("gmx");
            return 1;
        }
    }
   
    if (strcmp("/checkhh", cmd, true) == 0)
    {
        new targetid;
        if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /CheckHH [ID]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000FF, "Bad Player ID");
        new Float:playerHealth;
        GetPlayerHealth(targetid, playerHealth);
        if(playerHealth > 100.0)
        {
            BanEx(targetid, "Health Hacks");
        }
        else
        {
            SendClientMessage(playerid,0x01FF0AFF, "Player doesnt HP hax(or does he?)";
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)