About /n chat
#1

Hi, I made a /n chat but I would like to know how to make a timer per person like 60 sec before re asking in this chat, I did a timer but its for everyone.... If I talk in this chat, nobody will be able to speak everyone will have to wait 60 sec.. I want make that only for each person who talk, thanks !
Reply
#2

Well, lets see your attempt at doing it first, then we can work on improving it so that it works for each person individually.
Reply
#3

Код HTML:
if(strcmp(cmd, "/n", true) == 0 || strcmp(cmd, "/newbie", true) == 0)
	{
	    if(newbietimer != 0) return SendClientMessage(playerid, COLOR_GREY," Please wait 60 seconds before using the newbie chat!");
	    {
			if(IsPlayerConnected(playerid))
			{
				if(gPlayerLogged[playerid] == 0)
				{
					SendClientMessage(playerid, COLOR_GREEN, "  You havent logged in yet !");
					return 1;
				}
				if ((noooc) && PlayerInfo[playerid][pAdmin] < 1)
				{
					SendClientMessage(playerid, COLOR_GREEN, "  The Newbie Chat has been disabled by an Admin !");
					return 1;
				}
				if(PlayerInfo[playerid][pMuted] == 1)
				{
					SendClientMessage(playerid, COLOR_GREEN, "  You can't speak, you have been silenced !");
					return 1;
				}
				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_GREEN, "USAGE: (/n)ewbie [Newbie Chat, Ask Questions]");
					return 1;
				}
				format(string, sizeof(string), " *** Newbie *** %s: %s ", sendername, result);
				OOCOff(COLOR_GREEN,string);
				printf("%s", string);
				newbietimer = 1;
				SetTimer("ResetNewbieTimer",60000, false);
			}
		}
		return 1;
	}

This is the /n command... do you need public ResetNewbieTimer blalba or...?
Reply
#4

pawn Код:
// @ top of the script.

new newbietimer[MAX_PLAYERS];

// @ OnPlayerCommandText.

if(strcmp(cmd, "/n", true) == 0 || strcmp(cmd, "/newbie", true) == 0)
    {
        if(newbietimer[playerid] != 0) return SendClientMessage(playerid, COLOR_GREY," Please wait 60 seconds before using the newbie chat!");
        {
            if(IsPlayerConnected(playerid))
            {
                if(gPlayerLogged[playerid] == 0)
                {
                    SendClientMessage(playerid, COLOR_GREEN, "  You havent logged in yet !");
                    return 1;
                }
                if ((noooc) && PlayerInfo[playerid][pAdmin] < 1)
                {
                    SendClientMessage(playerid, COLOR_GREEN, "  The Newbie Chat has been disabled by an Admin !");
                    return 1;
                }
                if(PlayerInfo[playerid][pMuted] == 1)
                {
                    SendClientMessage(playerid, COLOR_GREEN, "  You can't speak, you have been silenced !");
                    return 1;
                }
                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_GREEN, "USAGE: (/n)ewbie [Newbie Chat, Ask Questions]");
                    return 1;
                }
                format(string, sizeof(string), " *** Newbie *** %s: %s ", sendername, result);
                OOCOff(COLOR_GREEN,string);
                printf("%s", string);
                newbietimer[playerid] = 1;
                SetTimer("ResetNewbieTimer",60000, false);
            }
        }
        return 1;
    }
EDIT:

You need change the variable in the ' ResetNewbieTimer ' function aswell.
Reply
#5

change by what ? and I have this error:



C:\Users\Vernz\Desktop\BB-RP last GM\gamemodes\BB-RL.pwn(44139) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#6

Show me your ' ResetNewbieTimer ' function.
Reply
#7

Код:
public ResetNewbieTimer()
{
	newbietimer[playerid] = 0;
	return 1;
}
Reply
#8

pawn Код:
public ResetNewbieTimer()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {      
        newbietimer[playerid] = 0;
        return 1;
    }
}
But you need some more variables if you want it to work better.
Reply
#9

Like what ? and ive try this one and it work thanks ! but how it could be better
Reply
#10

Quote:
Originally Posted by vernz
Посмотреть сообщение
Like what ? and ive try this one and it work thanks ! but how it could be better
Well yes, it works but I think it won't work good with more than 1 player.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)