[Help] SetTimer
#1

Can some of you lovely people
help me out make a timer on this Newbie chat

pawn Код:
if(strcmp(cmd, "/newbie", true) == 0 || strcmp(cmd, "/n", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet !");
                return 1;
            }
            if(PlayerInfo[playerid][pTut] == 0)
            {
                Kick(playerid);
                return 1;
            }
            if((nonewbie) && PlayerInfo[playerid][pAdmin] < 3)
            {
                SendClientMessage(playerid, COLOR_GREY, "   The Newbie channel has been disabled by an Admin !");
                return 1;
            }
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are banned from speaking in that channel !");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[96];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/n)ewbie [newbie chat]");
                return 1;
            }
            if(PlayerInfo[playerid][pLevel] > 1 && PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][pHelper] <= 0) format(string, sizeof(string), "** [Player] %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pAdmin] >= 2) format(string, sizeof(string), "** [Admin] %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pHelper] >= 2) format(string, sizeof(string), "** [VIP Gold] %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pDonateRank] >= 1) format(string, sizeof(string), "** [VIP Silver] ** %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pHelper] == 1) format(string, sizeof(string), "** [Helper] %s: %s", sendername, result);
            else format(string, sizeof(string), "** Newbie %s: %s", sendername, result);
            ABroadCast(TEAM_BLUE_COLOR, string, 5);
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
            format(string, sizeof(string), "[%d/%d/%d](%d:%d:%d) %s (newbie): (%s)",d,m,y,h,mi,s, sendername, result);
        }
        return 1;
    }
Reply
#2

Why do you need a timer for this? Assuming you're talking about limiting the amount of times you can use the command? Just use GetTickCount, for example:

pawn Код:
new iNewbieTick[MAX_PLAYERS]; // Outside of functions/callbacks, top of script for example

if(strcmp(cmd, "/newbie", true) == 0 || strcmp(cmd, "/n", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if((GetTickCount() - iNewbieTick[playerid]) < 60000) return SendClientMessage(playerid, COLOR_GREY, "You have to wait 60 seconds before using that again!");
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet !");
                return 1;
            }
            if(PlayerInfo[playerid][pTut] == 0)
            {
                Kick(playerid);
                return 1;
            }
            if((nonewbie) && PlayerInfo[playerid][pAdmin] < 3)
            {
                SendClientMessage(playerid, COLOR_GREY, "   The Newbie channel has been disabled by an Admin !");
                return 1;
            }
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are banned from speaking in that channel !");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[96];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/n)ewbie [newbie chat]");
                return 1;
            }
            if(PlayerInfo[playerid][pLevel] > 1 && PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][pHelper] <= 0) format(string, sizeof(string), "** [Player] %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pAdmin] >= 2) format(string, sizeof(string), "** [Admin] %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pHelper] >= 2) format(string, sizeof(string), "** [VIP Gold] %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pDonateRank] >= 1) format(string, sizeof(string), "** [VIP Silver] ** %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pHelper] == 1) format(string, sizeof(string), "** [Helper] %s: %s", sendername, result);
            else format(string, sizeof(string), "** Newbie %s: %s", sendername, result);
            ABroadCast(TEAM_BLUE_COLOR, string, 5);
            iNewbieTick[playerid] = GetTickCount();
            new y, m, d;
            new h,mi,s;
            getdate(y,m,d);
            gettime(h,mi,s);
            format(string, sizeof(string), "[%d/%d/%d](%d:%d:%d) %s (newbie): (%s)",d,m,y,h,mi,s, sendername, result);
        }
        return 1;
    }
Reply
#3

Oh very nice it works great
is there a way i can do so

pHelper
pAdmin

can go passed this TickCounter
so theres no wait time for Helpers and Admin at all its just for a faster answer for the players.

EDIT: Or do i need a Timer for this?
Reply
#4

Why would you need a timer for that, you seem to think you need a timer for everything!

Just add to the if statement for your pHelper and pAdmin variables, for example:

pawn Код:
if((PlayerInfo[playerid][pAdmin] == 0 || PlayerInfo[playerid][pAdmin] == 0) && (GetTickCount() - iNewbieTick[playerid]) < 60000) return SendClientMessage(playerid, COLOR_GREY, "You have to wait 60 seconds before using that again!");
Reply
#5

Haha well i thought a timer was the solution ^^
Admins & Helpers goes through the counter now

But now Newbies cant even write in /n
it tells them You have to wait 60 seconds before using that again!
even after the 60 seconds it keeps sayin that.
Reply
#6

I see....try this:

pawn Код:
if((PlayerInfo[playerid][pAdmin] == 0 && PlayerInfo[playerid][pHelper] == 0) && ((GetTickCount() - iNewbieTick[playerid]) < 60000)) return SendClientMessage(playerid, COLOR_GREY, "You have to wait 60 seconds before using that again!");
Reply
#7

yes i tried that already, unfortunately Newbs still cant write in it.
Reply
#8

Okay i tried to use a Timer this time
it works perfectly with Helper and Admin

But when i try to use /n as a Newbie
when i write /n "text" its like the message tries to get through but i cant see it
then when i write /n "text" ones again the message shows up with "You have to wait 50 seconds"

So its like the message gets through but its invisble
what can this be its very wierd hope someone can help out here i been trying now 2 days looking all places i just cant make it work would be very thankfull iff someone could help me with this.

EDIT: When the OOC chat is on it works the newbie message goes through but iff its off it don't :S


pawn Код:
if(strcmp(cmd, "/newbie", true) == 0 || strcmp(cmd, "/n", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet !");
                return 1;
            }
            if(PlayerInfo[playerid][pTut] == 0)
            {
                Kick(playerid);
                return 1;
            }
            if((nonewbie) && PlayerInfo[playerid][pAdmin] < 3)
            {
                SendClientMessage(playerid, COLOR_GREY, "   The Newbie channel has been disabled by an Admin !");
                return 1;
            }
            if(PlayerInfo[playerid][pNewbieMuted] == 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are banned from speaking in that channel !");
                return 1;
            }
            if(UseNewbieTimer[playerid]) return SendClientMessage(playerid,COLOR_GREY,"  You must wait 50 seconds before speaking in that channel !");
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
            for (new i = 0; i < MAX_PLAYER_NAME; i++)
            if (sendername[i] == '_')
            sendername[i] = ' ';
            new offset = idx;
            new result[96];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/n)ewbie [newbie chat]");
                return 1;
            }
            if(PlayerInfo[playerid][pLevel] > 1 && PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][phelper] <= 0) format(string, sizeof(string), "** Player %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pAdmin] >= 2) format(string, sizeof(string), "** Admin %s: %s", sendername, result);
            else if(PlayerInfo[playerid][phelper] >= 3) format(string, sizeof(string), "** Head helper %s: %s", sendername, result);
            else if(PlayerInfo[playerid][pVip] == 1 || PlayerInfo[playerid][pVip] == 2 || PlayerInfo[playerid][pVip] == 3) format(string, sizeof(string), "** VIP ** %s: %s", sendername, result);
            else if(PlayerInfo[playerid][phelper] == 2) format(string, sizeof(string), "** helper %s: %s", sendername, result);
            else if(PlayerInfo[playerid][phelper] == 1) format(string, sizeof(string), "** helper %s: %s", sendername, result);
            else format(string, sizeof(string), "** Newbie %s: %s", sendername, result);
            OOCNewbie(NEWBIE_COLOR,string);
            if(PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][phelper] <= 0) { UseNewbieTimer[playerid] = true; SetTimerEx("UseNewbie",50*1000,0,"i",playerid); }
        }
    }



Real Chat OOC

pawn Код:
if(realchat)
    {
        if(gPlayerLogged[playerid] == 0)
        {
            return 0;
        }
        else if(PlayerInfo[playerid][pMask] == 1)
        {
            if(strcmp(Accent[playerid],"none",true,3))
            {
                format(string, sizeof(string), "(%s Accent) Stranger says: %s",Accent[playerid],text);
            }
            else
            {
                format(string, sizeof(string), "Stranger says: %s",text);
            }
        }
        else
        {
            if(strcmp(Accent[playerid],"none",true,3))
            {
                format(string, sizeof(string), "(%s Accent) %s says: %s",Accent[playerid],PlayerName(playerid),text);
            }
            else
            {
                format(string, sizeof(string), "%s says: %s",PlayerName(playerid),text);
            }
        }
        ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        return 0;
    }
    return 1;
}
SOLVED

i didnt notice
new realchat = 0;

changed it to
new realchat = 1;

works now
Reply
#9

Whats the iNewbTick thing? It gives me an error about it, what do i change it to?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)