SA-MP Forums Archive
How to add a reason? - 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)
+--- Thread: How to add a reason? (/showthread.php?tid=435635)



How to add a reason? - NoahF - 07.05.2013

How would I add a reason for slapping to this command?

Код:
CMD:slap(playerid,params[])
{
	if(pInfo[playerid][pAdminLevel] >= 2 || IsPlayerAdmin(playerid))
	{
	    new targetid,string[256];
		if(sscanf(params, "u", targetid)) return  SendClientMessage(playerid,-1,""chat" /slap [playerid]");
		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");

		new Float:posxx[3];
		GetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]);
		SetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]+20);

		if(IsPlayerAdmin(playerid))
		{
	   		format(string, sizeof(string), ""chat" RCON Admin has slapped %s",PlayerName(targetid));
			SendClientMessageToAll(-1,string);
		}
		else
		{
			format(string, sizeof(string), ""chat""COL_RED" %s %s has slapped %s",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid));
			SendClientMessageToAll(-1,string);
		}
	}
	else {
		SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
	}
	return 1;
}



Re: How to add a reason? - BigGroter - 07.05.2013

pawn Код:
CMD:slap(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 2 || IsPlayerAdmin(playerid))
    {
        new targetid, reason[128], string[256];
        if(sscanf(params, "us[128]", targetid,reason)) return  SendClientMessage(playerid,-1,""chat" /slap [playerid] [reason]"); //after this, do whatever you want to with the reason.
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");

        new Float:posxx[3];
        GetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]);
        SetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]+20);

        if(IsPlayerAdmin(playerid))
        {
            format(string, sizeof(string), ""chat" RCON Admin has slapped %s",PlayerName(targetid));
            SendClientMessageToAll(-1,string);
        }
        else
        {
            format(string, sizeof(string), ""chat""COL_RED" %s %s has slapped %s",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid));
            SendClientMessageToAll(-1,string);
        }
    }
    else {
        SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
    }
    return 1;
}



Re: How to add a reason? - NoahF - 07.05.2013

Doesn't work.


Re: How to add a reason? - BigGroter - 07.05.2013

What's the issue?


Re: How to add a reason? - BenTaylorUK - 07.05.2013

Код:
CMD:slap(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 2 || IsPlayerAdmin(playerid))
    {
        new targetid, reason[128], string[256];
        if(sscanf(params, "us[128]", targetid,reason)) return  SendClientMessage(playerid,-1,""chat" /slap [playerid] [reason]"); //after this, do whatever you want to with the reason.
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");

        new Float:posxx[3];
        GetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]);
        SetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]+20);

        if(IsPlayerAdmin(playerid))
        {
            format(string, sizeof(string), ""chat" RCON Admin has slapped %s for %s",PlayerName(targetid), reason);
            SendClientMessageToAll(-1,string);
        }
        else
        {
            format(string, sizeof(string), ""chat""COL_RED" %s %s has slapped %s for %s",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid), reason);
            SendClientMessageToAll(-1,string);
        }
    }
    else {
        SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
    }
Like this maybe?


Re: How to add a reason? - RevolutionaryGaming - 07.05.2013

You forgot to include the reason in the message sent.

pawn Код:
CMD:slap(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 2 || IsPlayerAdmin(playerid))
    {
        new targetid, reason[128], string[256];
        if(sscanf(params, "us[128]", targetid,reason)) return  SendClientMessage(playerid,-1,""chat" /slap [playerid] [reason]"); //after this, do whatever you want to with the reason.
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");

        new Float:posxx[3];
        GetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]);
        SetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]+20);

        if(IsPlayerAdmin(playerid))
        {
            format(string, sizeof(string), ""chat" RCON Admin has slapped %s for reason: %s",PlayerName(targetid), reason);
            SendClientMessageToAll(-1,string);
        }
        else
        {
            format(string, sizeof(string), ""chat""COL_RED" %s %s has slapped %s, reason: %s",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid), reason);
            SendClientMessageToAll(-1,string);
        }
    }
    else {
        SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
    }
    return 1;
}