SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 05/01/2011, 11:22 PM   #1
]B4E[kengston
Little Clucker
 
Join Date: Sep 2010
Posts: 45
Reputation: 0
Default Admin Chat



Code:
    if(!strcmp(strget(cmdtext,0),"/c"))
	{
	if(Spieler[playerid][AdminLevel] >=2)
	{
	if(!strlen(strget(cmdtext,1)))
	return
	SendClientMessage(playerid,COLOR_GREY,"Use: /c [Text]");
	new string[256];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));
 	format(string,sizeof(string), "Server - AdminChat [%d] %s: %s",playerid, name, cmdtext);
	print(string);
	{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	if(Spieler[i][AdminLevel] >=2)
	{
	PlayerPlaySound(i,1057 ,0,0,0);
 	SendClientMessage(i,COLOR_LIGHTGREEN,string);
	}}}}
	return 1;
}
This is my Admin Chat. But when we Chat in the Chat We see always the command for writing ( /c ). I ask you how to improve this. I hope you can help me =)

]B4E[kengston
]B4E[kengston is offline  
Old 05/01/2011, 11:24 PM   #2
Kaylux
Banned
 
Join Date: Dec 2010
Posts: 99
Reputation: 0
Default Re: Admin Chat

I know this is said alot but if you use a better command processor such as zcmd, you wouldn't have this problem.
Kaylux is offline  
Old 05/01/2011, 11:26 PM   #3
]B4E[kengston
Little Clucker
 
Join Date: Sep 2010
Posts: 45
Reputation: 0
Default AW: Admin Chat

I also made this command with
Code:
new text1[128]; 
text1 = strval(strget(cmdtext,1);
. But this is not good.
]B4E[kengston is offline  
Old 05/01/2011, 11:31 PM   #4
John_F
Huge Clucker
 
John_F's Avatar
 
Join Date: Jul 2010
Posts: 244
Reputation: 0
Default Re: Admin Chat

Use ZCMD and sscanf:
pawn Code:
COMMAND:c(playerid, params[])
{
  new chat[100], name[MAX_PLAYER_NAME];
  if(/PlayerInfo[playerid][pAdminLevel] >=2)
  {
    if(sscanf(params, "s", chat)) SendClientMessage(playerid, COLOR_GREY, "Use: /c [text]");
    GetPlayerName(playerid,name,sizeof(name));
    format(chat,sizeof(chat), "Server - AdminChat [%d] %s: %s",playerid, name, chat);
    print(chat);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Spieler[i][AdminLevel] >=2)
        {
            PlayerPlaySound(i,1057 ,0,0,0);
            SendClientMessage(i,COLOR_LIGHTGREEN,chat);
        }
    }
  }
  return 1;
}
untested but it should work afaik
__________________

**New COD server!**
Hosted list!
64.120.47.67:7777
Forum: www.cod-dm.com

Need scripting support or a person to script for you? PM me.
John_F is offline  
Old 05/01/2011, 11:32 PM   #5
Kaylux
Banned
 
Join Date: Dec 2010
Posts: 99
Reputation: 0
Default Re: Admin Chat

I suggest you use zmcd but if you must use strcmp alone then...

pawn Code:
if(strcmp(cmd, "/admin", true) == 0 || strcmp(cmd, "/c", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: (/c) [admin chat]");
                return 1;
            }
            format(string, sizeof(string), "*%d Admin %s: %s", PlayerInfo[playerid][pAdmin], sendername, result);
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if (PlayerInfo[i][pAdmin] >= 1)
                {
                    SendAdminMessage(i, COLOR_LIGHTGREEN, string);
                }
            }
                                 format(string,sizeof(string), "Server - AdminChat [%d] %s: %s",playerid, sendername, result);
        }
        return 1;
    }

Edit: Damn got ninja'd
Kaylux is offline  
Old 05/01/2011, 11:35 PM   #6
]B4E[kengston
Little Clucker
 
Join Date: Sep 2010
Posts: 45
Reputation: 0
Default AW: Admin Chat

Thanks =)
]B4E[kengston is offline  
Old 06/01/2011, 06:44 AM   #7
iggy1
High-roller
 
iggy1's Avatar
 
Join Date: Mar 2009
Location: One past the end.
Posts: 2,421
Reputation: 273
Default Re: Admin Chat

Even better, don't use commands for admin chat use OnPlayerText like this,
pawn Code:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '#' && Spieler[playerid][AdminLevel] > 0)
    {
        new
            pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid,pName , MAX_PLAYER_NAME);
        format(text,128 ,"|ADMIN CHAT| %s: %s", pName, text[1]);
        for(new i; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(i))continue;
            if(Spieler[i][AdminLevel] > 0)
                SendClientMessage(i, COLOR_LIGHTGREEN, text);
        }
        return 0;
    }
    return 1;
}
Most admin systems use this method. Anything typed after '#' will be sent to admins.
iggy1 is offline  
Old 06/01/2011, 07:16 AM   #8
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,594
Reputation: 379
Default Re: Admin Chat

pawn Code:
//In OnPlayerCommandText
    if(!strcmp(cmdtext,"/c",true))
    {
        if(Spieler[playerid][AdminLevel] <2)return SendClientMessage(playerid,COLOR_GREY,"You're cannot use this command");
        GetPlayerName(playerid,string,24);
        if(!cmdtext[3])return SendClientMessage(playerid,COLOR_GREY,"Use: /c [Text]");
        format(string,sizeof(string), "Server - AdminChat [%d] %s: %s",playerid, string, cmdtext[3]);
        print(string);
        for(new player;player<MAX_PLAYERS;player++)
        {
            if(!IsPlayerConnected(player))continue;
            if(Spieler[playerid][AdminLevel] <2)continue;
            PlayerPlaySound(player,1057 ,0,0,0);
            SendClientMessage(player,COLOR_LIGHTGREEN,string);
        }
        return 1;
    }
Joe Staff is offline  
 

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
Admin Chat < Admins can't see chat or my text, but I can see their chat Andy_McKinley Help Archive 37 17/05/2011 08:26 PM
admin chat Gh0sT_ Help Archive 16 28/09/2010 11:47 AM
[Help] Admin Chat help. johnnyc Help Archive 1 17/05/2010 01:53 PM
Admin Chat Puzi Help Archive 4 26/06/2009 05:43 PM


All times are GMT. The time now is 11:02 PM.


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