Add A Reason
#1

How would I add a reason to this command?

Код:
CMD:wslap(playerid,params[])
{
	if(pInfo[playerid][pAdminLevel] >= 1)
	{
	    new targetid,string[256];
		if(sscanf(params, "u", targetid)) return  SendClientMessage(playerid,-1,""chat" /wslap [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]+4);

		format(string, sizeof(string), ""chat""COL_LIGHTBLUE" %s %s has warned 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;
}
Reply
#2

change to this :

pawn Код:
CMD:wslap(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 1)
    {
        new targetid,string[256],reason[32];
        if(sscanf(params, "us[32]", targetid)) return  SendClientMessage(playerid,-1,""chat" /wslap [playerid] [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]+4);

        format(string, sizeof(string), ""chat""COL_LIGHTBLUE" %s %s has warned 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;
}
thats very basic ..
Reply
#3

Quote:
Originally Posted by SMW
Посмотреть сообщение
change to this :

pawn Код:
CMD:wslap(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 1)
    {
        new targetid,string[256],reason[32];
        if(sscanf(params, "us[32]", targetid)) return  SendClientMessage(playerid,-1,""chat" /wslap [playerid] [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]+4);

        format(string, sizeof(string), ""chat""COL_LIGHTBLUE" %s %s has warned 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;
}
thats very basic ..
Pretty sure this wouldn't work, since you didn't include the reason in the sscanf, so it wouldn't recognize (I think) what reason is for and leave it at the default value.

Try this, though:

pawn Код:
CMD:wslap(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 1)
    {
        new targetid,string[256], reason[40];
        if(sscanf(params, "u", targetid)) return  SendClientMessage(playerid,-1,""chat" /wslap [playerid]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");
        if(strlen(reason) > 40 || strlen(reason) < 5) return SendClientMessage(playerid, -1, ""chat" Reason must be between 5 and 40 characters");

        new Float:posxx[3];

        GetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]);
        SetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]+4);

        format(string, sizeof(string), ""chat""COL_LIGHTBLUE" %s %s has warned 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;
}
This adds the reason to the command, and makes it so the reason must be between 5 and 40 (you MUST have a reason).
Reply
#4

Kindred with your script, I changed it to 2 and 60 characters, but this is what it says when i have less than 60 characters and more than 2:

Reply
#5

pawn Код:
CMD:wslap(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 1)
    {
        new targetid,string[256],reason[32];
        if(sscanf(params, "us[32]", targetid,reason)) return  SendClientMessage(playerid,-1,""chat" /wslap [playerid] [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]+4);

        format(string, sizeof(string), ""chat""COL_LIGHTBLUE" %s %s has warned 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;
}
try this, i've add reason to sscanf.. it should work than his code
Reply
#6

pawn Код:
CMD:wslap(playerid,params[])
{
    new targetid,reason[120];
    if(pInfo[playerid][pAdminLevel] < 1) SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
    else if(sscanf(params, "uS(None)[120]", targetid, reason))  SendClientMessage(playerid,-1,""chat" /wslap [playerid] [reason]");
    else if(!IsPlayerConnected(targetid)) SendClientMessage(playerid,-1,""chat" Player is not online");
    else{
        new
            string[128],
            Float:posxx[3];

        GetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]);
        SetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]+4);

        format(string, sizeof(string), ""chat""COL_LIGHTBLUE" %s %s has warned slapped %s",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid));
        SendClientMessageToAll(-1,string);
        if(strcmp(reason,"None") != 0)
        {
            format(string, sizeof(string), ""chat""COL_LIGHTBLUE" Reason: %s",reason);
            SendClientMessageToAll(-1,string);
        }
    }
    return 1;
}
Reply
#7

You must have put them in the wrong order. Try this:

pawn Код:
CMD:wslap(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 1)
    {
        new targetid,string[256], reason[60];
        if(sscanf(params, "u", targetid)) return  SendClientMessage(playerid,-1,""chat" /wslap [playerid]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");
        if(strlen(reason) > 60 || strlen(reason) < 2) return SendClientMessage(playerid, -1, ""chat" Reason must be between 2 and 60 characters");

        new Float:posxx[3];

        GetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]);
        SetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]+4);

        format(string, sizeof(string), ""chat""COL_LIGHTBLUE" %s %s has warned 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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)