Little help with the /w command
#1

Код:
	if(strcmp(cmd, "/whisper", true) == 0 || strcmp(cmd, "/w", true) == 0)
	{
		if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ADMIN_RED, "USAGE: (/w)hisper [playerid/PartOfName] [whisper text]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if (IsPlayerConnected(giveplayerid))
			{
        	format(string, sizeof(string), "Admin %s whispers: %s", sendername, playerid);
					SendClientMessage(giveplayerid, YELLOW, string);
			}
			else
			{
					format(string, sizeof(string), "  %d is not an active player.", giveplayerid);
					SendClientMessage(playerid, YELLOW, string);
			}
		}
		return 1;
	}
Why does this command not work?
Reply
#2

pawn Код:
format(string, sizeof(string), "Admin %s whispers: %s", sendername, playerid);
You need to give the string which contains the whisper text instead of 'playerid'

But anyway, here's one that should work (untested) with dcmd and sscanf:
pawn Код:
// assuming you already have a 'string[128]' defined
dcmd_whisper(playerid, params[])
{
    if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid))
    {
        new
            TargetID,
            msg[128];
        if (sscanf(params, "us", TargetID, msg) != 0)
        {
            SendClientMessage(playerid, ADMIN_RED, "Usage: /whisper <Target ID or name> <text>");
            SendClientMessage(playerid, ADMIN_RED, "Alternatives: /w, /whisper");
            return 1;
        }
        if (IsPlayerConnected(TargetID))
        {
            format(string, sizeof(string), "Admin %s whispers: %s", GetPlayerName2(playerid), msg);
            SendClientMessage(TargetID, YELLOW, string);
            return 1;
        }
        else return SendClientMessage(playerid, ADMIN_RED, "Player not found!");
    }
    else SendClientMessage(playerid, ADMIN_RED, "This is a level 1 command!");
    return 1;
}
dcmd_w(playerid, params[])
{
    return dcmd_whisper(playerid, params);
}
pawn Код:
stock GetPlayerName2(playerid)
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    return pname;
}
// in case you need it
Reply
#3

Код:
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(33) : error 001: expected token: "}", but found "-identifier-"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(42) : error 010: invalid function or declaration
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(524) : error 017: undefined symbol "Cash"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(531) : error 017: undefined symbol "Cash"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(533) : error 017: undefined symbol "Warns"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(535) : error 017: undefined symbol "WarnReason1"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(537) : error 017: undefined symbol "WarnReason2"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(539) : error 017: undefined symbol "WarnReason3"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(555) : error 017: undefined symbol "Logged"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(563) : error 017: undefined symbol "Cash"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(570) : error 017: undefined symbol "Cash"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(572) : error 017: undefined symbol "Warns"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(574) : error 017: undefined symbol "WarnReason1"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(576) : error 017: undefined symbol "WarnReason2"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(578) : error 017: undefined symbol "WarnReason3"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(580) : error 017: undefined symbol "IP"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(620) : error 017: undefined symbol "Cash"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(625) : error 017: undefined symbol "Warns"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(630) : error 017: undefined symbol "WarnReason1"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(635) : error 017: undefined symbol "WarnReason2"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(640) : error 017: undefined symbol "WarnReason3"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(644) : error 017: undefined symbol "Logged"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(652) : error 017: undefined symbol "Cash"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(697) : error 017: undefined symbol "Jail"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(699) : error 017: undefined symbol "Warns"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(700) : error 017: undefined symbol "Logged"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


26 Errors.
Reply
#4

You must have missed a bracket somewhere (check lines 22 and 23, there is the error).
If you used my code, do you have dcmd and sscanf defined?
Reply
#5

Hereґs the correct one -

Код:
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2499) : error 017: undefined symbol "dcmd_whisper"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2506) : error 017: undefined symbol "sscanf"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2523) : warning 225: unreachable code
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2523) : error 017: undefined symbol "dcmd_w"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2525) : error 017: undefined symbol "dcmd_whisper"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2527) : warning 225: unreachable code
Reply
#6

Make sure you have sscanf defined in your script. Click here!
Reply
#7

Код:
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2499) : error 017: undefined symbol "dcmd_whisper"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2506) : error 017: undefined symbol "params"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2523) : warning 225: unreachable code
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2523) : error 017: undefined symbol "dcmd_w"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2525) : error 017: undefined symbol "dcmd_whisper"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(2527) : warning 225: unreachable code
Reply
#8

You have dcmd defined, right?
Make sure you added these lines to OnPlayerCommandText:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(whisper, 7, cmdtext);
    dcmd(w, 1, cmdtext);
}
Didn't you put the dcmd_whisper and dcmd_w in the OnPlayerCommandText callback? If so, you need to put them to the bottom of your script (or at least out of that callback).
Reply
#9

Iґve added the dcmds at the bottom and defined dcmd

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[128];
	new tmp[128];
	new idx;
	new giveplayername[MAX_PLAYER_NAME];
	new sendername[MAX_PLAYER_NAME];
	new string[128];
	dcmd(whisper, 7, cmdtext);
	dcmd(w, 1, cmdtext);
	cmd = strtok(cmdtext,idx);
But still:
Код:
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(807) : error 017: undefined symbol "dcmd"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(808) : error 017: undefined symbol "dcmd"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(3307) : warning 203: symbol is never used: "dcmd_w"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\admin.pwn(3307) : warning 203: symbol is never used: "dcmd_whisper"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#10

I don't think it's defined, add the following line to the top of your script.
pawn Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)