SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/09/2018, 06:12 PM   #1
CrystalMethod
Big Clucker
 
CrystalMethod's Avatar
 
Join Date: Dec 2011
Location: Michigan
Posts: 114
Reputation: 23
Default Using ! or # as a command? + undefined params

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.
__________________

WEBSITE | FORUMS | YOUTUBE | DISCORD
Address: play.thepilotslife.com:7777
Version: 0.3.7-R2


Last edited by CrystalMethod; 17/09/2018 at 10:27 PM.
CrystalMethod is offline   Reply With Quote
Old 17/09/2018, 06:23 PM   #2
Kasichok
Big Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 64
Reputation: 24
Default Re: Using ! or # as a command?

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

__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote
Old 17/09/2018, 06:40 PM   #3
iLearner
Gangsta
 
iLearner's Avatar
 
Join Date: Apr 2017
Posts: 577
Reputation: 134
Default Re: Using ! or # as a command?

Zcmd won't help you in that case, use OnPlayerText as Kasichok did above.
iLearner is offline   Reply With Quote
Old 17/09/2018, 09:26 PM   #4
CrystalMethod
Big Clucker
 
CrystalMethod's Avatar
 
Join Date: Dec 2011
Location: Michigan
Posts: 114
Reputation: 23
Default Re: Using ! or # as a command?

Great, thank you!
__________________

WEBSITE | FORUMS | YOUTUBE | DISCORD
Address: play.thepilotslife.com:7777
Version: 0.3.7-R2

CrystalMethod is offline   Reply With Quote
Old 17/09/2018, 10:25 PM   #5
CrystalMethod
Big Clucker
 
CrystalMethod's Avatar
 
Join Date: Dec 2011
Location: Michigan
Posts: 114
Reputation: 23
Default Re: Using ! or # as a command?

Posting here to prevent another thread. Lines highlighed.
(19456) : error 017: undefined symbol "params"
(19467) : error 017: undefined symbol "params"
Code:
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.
__________________

WEBSITE | FORUMS | YOUTUBE | DISCORD
Address: play.thepilotslife.com:7777
Version: 0.3.7-R2

CrystalMethod is offline   Reply With Quote
Old 17/09/2018, 10:30 PM   #6
Grim_
High-roller
 
Grim_'s Avatar
 
Join Date: Sep 2008
Location: United States
Posts: 2,862
Reputation: 118
Default Re: Using ! or # as a command?

It tells you the problem
Code:
(19456) : error 017: undefined symbol "params"
(19467) : error 017: undefined symbol "params"
OnPlayerText(playerid, text[])
pawn Code:
if(text[0] == '#') {
   strdel(text, 0, 1);
   strins(text, "[ADMIN CHAT]: ", 0);
   // Your message is in 'text'
}
Grim_ is offline   Reply With Quote
Old 17/09/2018, 10:38 PM   #7
CrystalMethod
Big Clucker
 
CrystalMethod's Avatar
 
Join Date: Dec 2011
Location: Michigan
Posts: 114
Reputation: 23
Default Re: Using ! or # as a command?

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

WEBSITE | FORUMS | YOUTUBE | DISCORD
Address: play.thepilotslife.com:7777
Version: 0.3.7-R2

CrystalMethod is offline   Reply With Quote
Old 17/09/2018, 10:40 PM   #8
Grim_
High-roller
 
Grim_'s Avatar
 
Join Date: Sep 2008
Location: United States
Posts: 2,862
Reputation: 118
Default Re: Using ! or # as a command?

http://wiki.sa-mp.com/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.
Grim_ is offline   Reply With Quote
Old 17/09/2018, 10:47 PM   #9
CrystalMethod
Big Clucker
 
CrystalMethod's Avatar
 
Join Date: Dec 2011
Location: Michigan
Posts: 114
Reputation: 23
Default Re: Using ! or # as a command?

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 #?
__________________

WEBSITE | FORUMS | YOUTUBE | DISCORD
Address: play.thepilotslife.com:7777
Version: 0.3.7-R2

CrystalMethod is offline   Reply With Quote
Old 17/09/2018, 11:24 PM   #10
Grim_
High-roller
 
Grim_'s Avatar
 
Join Date: Sep 2008
Location: United States
Posts: 2,862
Reputation: 118
Default Re: Using ! or # as a command?

Use the code I provided earlier as a baseline. The message resides in 'text'
Grim_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with YCMD proces command and problem with "Server:Unknown command JoDe Scripting Help 1 20/04/2018 01:12 PM
[Plugin] mcmd Command Engine - Plugin based command processing Mellnik Plugin Development 108 08/05/2016 02:55 PM
i had this command in my gamemode, when i type this in game,it tells server unknow command? Chrisli520 Scripting Help 3 24/11/2013 11:02 AM
Executed ZCMD command returns SERVER: Unknown Command SexTourist Scripting Help 12 03/01/2012 04:38 PM
Slap command returns an Unknown Command when player is not connected HydraX Help Archive 16 01/08/2011 06:19 AM


All times are GMT. The time now is 03:27 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.