SA-MP Forums Archive
Bug in script but don't know what. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Bug in script but don't know what. (/showthread.php?tid=121642)



Bug in script but don't know what. - `FuTuRe- - 17.01.2010

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[256];
    if(text[0] == '@')
    {
        format(string, sizeof(string), "[Team Admin Chat] %s[%i]: %s", pInfo[playerid][name], playerid, text[1]);

      for(new j = 0; j < MAX_PLAYERS; j++)
        {
            if(IsPlayerConnected(j) && pInfo[j][level] > 0) SendClientMessage(j, COLOR_NOTICE, string);
        }
        return 0;
    }
If normal players type @message all admins can read it. But the players can't. How to get it that they can't talk in the admin chat?


Re: Bug in script but don't know what. - AiVAMAN - 17.01.2010

I don't know if it works, but try this:

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[256];
    if(text[0] == '@')
    {
        format(string, sizeof(string), "[Team Admin Chat] %s[%i]: %s", pInfo[playerid][name], playerid, text[1]);

        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && pInfo[i][level] > 0) return SendClientMessage(i, COLOR_NOTICE, string);
        }
    }    
    return 0;
}



Re: Bug in script but don't know what. - AiVAMAN - 17.01.2010

Quote:
Originally Posted by Seif_
Add IsPlayerAdmin.
He uses
pawn Код:
pInfo[i][level]
instead of
pawn Код:
IsPlayerAdmin



Re: Bug in script but don't know what. - Burridge - 17.01.2010

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[256];
    if(text[0] == '@' && pInfo[j][level] > 0) //Won't let the next part happen, unless the person's "level" is more than 0
    {
        format(string, sizeof(string), "[Team Admin Chat] %s[%i]: %s", pInfo[playerid][name], playerid, text[1]);

      for(new j = 0; j < MAX_PLAYERS; j++)
        {
            if(IsPlayerConnected(j) && pInfo[j][level] > 0) SendClientMessage(j, COLOR_NOTICE, string);
        }
        return 0;
    }
Try that, Sorry if it doesn't work, I haven't done much Pawn coding recently.


Re: Bug in script but don't know what. - GTAguillaume - 17.01.2010

Oops, EDIT:
Код:
public OnPlayerText(playerid, text[])
{
	new string[256];
	if(text[0] == '@')
	{
		if(pInfo[playerid][level] >= 1) return SendClientMessage(playerid,0xFF0000AA, "You cant talk here...");
  		format(string, sizeof(string), "[Team Admin Chat] %s[%i]: %s", pInfo[playerid][name], playerid, text[1]);

	  for(new j = 0; j < MAX_PLAYERS; j++)
		{
			if(IsPlayerConnected(j) && pInfo[j][level] > 0) SendClientMessage(j, COLOR_NOTICE, string);
	 	}
	 	return 0;
	}



Re: Bug in script but don't know what. - AiVAMAN - 17.01.2010

Quote:
Originally Posted by GTAguillaume
Код:
public OnPlayerText(playerid, text[])
{
	new string[256];
	if(text[0] == '@')
	{
  		format(string, sizeof(string), "[Team Admin Chat] %s[%i]: %s", pInfo[playerid][name], playerid, text[1]);

	  for(new j = 0; j < MAX_PLAYERS; j++)
		{
			if(IsPlayerConnected(j) && pInfo[j][level] > 0) SendClientMessage(j, COLOR_NOTICE, string);
	 	}
	 	SendClientMessage(playerid,string); //:P
	 	return 0;
	}
if(IsPlayerConnected(j) && pInfo[j][level] > 0) SendClientMessage(j, COLOR_NOTICE, string);

-.-



Re: Bug in script but don't know what. - AiVAMAN - 17.01.2010

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by AivaMan
Quote:
Originally Posted by Seif_
Add IsPlayerAdmin.
He uses
pawn Код:
pInfo[i][level]
instead of
pawn Код:
IsPlayerAdmin
Obviously not. Read his code.
Okay, then try this:

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[256];
    if(text[0] == '@')
    {
        format(string, sizeof(string), "[Team Admin Chat] %s[%i]: %s", pInfo[playerid][name], playerid, text[1]);

        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && IsPlayerAdmin(i)) return SendClientMessage(i, COLOR_NOTICE, string);
        }
    }    
    return 0;
}
But then the message will be only visible to RCON Admins.