SA-MP Forums Archive
How to make command like /Command ID - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to make command like /Command ID (/showthread.php?tid=276002)



How to make command like /Command ID - henry jiggy - 12.08.2011

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?


Re: How to make command like /Command ID - Laronic - 12.08.2011

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;
}



- henry jiggy - 12.08.2011

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.


Re: How to make command like /Command ID - =WoR=Varth - 12.08.2011

Don't put zcmd in any function.


Re: How to make command like /Command ID - Kingunit - 12.08.2011

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


Re: How to make command like /Command ID - henry jiggy - 12.08.2011

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.


Re: How to make command like /Command ID - MadeMan - 12.08.2011

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;
        }
    }



Re: How to make command like /Command ID - henry jiggy - 12.08.2011

Trying it now.

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


Re: How to make command like /Command ID - Michael@Belgium - 12.08.2011

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;
    }



Re: How to make command like /Command ID - MadeMan - 12.08.2011

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;
    }