Using ! or # as a command?
#1

I've been on servers that have had # for the admin chat, but no amount of searching is helping me out with using characters sasdf such as !, @, or # to send commands. I'm using ZCMD.
Reply
#2

PHP код:
public OnPlayerText(playeridtext[])
{
    if(
text[0] == '#')
    {
        
strdel(text01);
        foreach(
Playeri)
        {
            if(!
IsPlayerAdmin(i)) continue;
            
SendClientMessage(i, -1text);
            return 
0;
        }
    }
    return 
1;

Reply
#3

Zcmd won't help you in that case, use OnPlayerText as Kasichok did above.
Reply
#4

Great, thank you!
Reply
#5

Posting here to prevent another thread. Lines highlighed.
(19456) : error 017: undefined symbol "params"
(19467) : error 017: undefined symbol "params"
Код:
if(text[0] == '#')
    {
        // Setup local variables
	new Name[24], Msg[128], Message[128];

	// Send the command to all admins so they can see it
	SendAdminText(playerid, "#", params);

	// Get the player's name
	GetPlayerName(playerid, Name, sizeof(Name));

	// Check if the player has logged in
	if (APlayerData[playerid][LoggedIn] == true)
	{
		// Check if the player is an admin
		if (APlayerData[playerid][PlayerLevel] > 0)
		{
			if (sscanf(params, "s[128]", Message)) SendClientMessage(playerid, 0xFF0000AA, "[SERVER] Usage: \"# <Your Message>\"");
			else
			{
				// Loop through all players
				for (new i; i < MAX_PLAYERS; i++)
				{
				    // Check if the player is logged in
					if (APlayerData[i][LoggedIn] == true)
					{
					    // Check if the other player is also an admin
					    if (APlayerData[i][PlayerLevel] > 0)
					    {
							format(Msg, 128, "[ADMIN CHAT] {faff00}%s: {faff00}%s", Name, Message);
							SendClientMessage(i, 0xfaff00FF, Msg);
					    }
					}
				}
			}
		}
		else
		    return 0;
	}
	else
	    return 0;

	// Let the server know that this was a valid command
	return 1;
    }
Code is working fine for the old admin command, but throwing these errors while making the new command which is for the most part just copy and pasted.
Reply
#6

It tells you the problem
Код:
(19456) : error 017: undefined symbol "params"
(19467) : error 017: undefined symbol "params"
OnPlayerText(playerid, text[])
pawn Код:
if(text[0] == '#') {
   strdel(text, 0, 1);
   strins(text, "[ADMIN CHAT]: ", 0);
   // Your message is in 'text'
}
Reply
#7

oh right, my bad lmao. So its sending the admin chat but also sends it to the public chat now.
Reply
#8

https://sampwiki.blast.hk/wiki/OnPlayerText
Quote:

Return Values:
Returning 0 in this callback will stop the text from being sent to all players.
It is always called first in filterscripts so returning 0 there blocks other scripts from seeing it.

Reply
#9

Alright fixed that issue, one last thing, lmao
Example: when I send #test it appears [ADMIN CHAT] Player: #test
How would I go about getting rid of that redundant #?
Reply
#10

Use the code I provided earlier as a baseline. The message resides in 'text'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)