[HELP-SOLVED]Some /advertise timer problems !
#1

Hello,I have a Godfather edit server, and I have made the /ad(vertise) to work if you wait 1 minute betwen your adds, but recently the timer doesnt work properly, it says to player that didn't use /ad that they must wait 1 minute. Example: I enter the server and I dont give any adds (/advertise) but when I want to make one it says that I must wait 1 minute, but I didnt use it !

The timer is beeing used on my server for weeks, and I dont know why it started to make problems

Here is the code(its the server original code but the timer set to 60000 secs):

pawn Код:
forward AddsOn();
pawn Код:
new addtimer = 60000;
pawn Код:
//----------------------------------[advertise]-----------------------------------------------
    if(strcmp(cmd, "/advertise", true) == 0 || strcmp(cmd, "/ad", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            if(PlayerInfo[playerid][pLevel] >= 3)
            {
        if(gPlayerLogged[playerid] == 0)
        {
          SendClientMessage(playerid, COLOR_GREY, "  You havent logged in yet !");
          return 1;
        }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[264];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/ad)vertise [advert text]");
                return 1;
            }
            if ((!adds) && (PlayerInfo[playerid][pAdmin] < 1))
            {
                format(string, sizeof(string), "  Please try again later, %d minute between Advertisements !", (addtimer/60000));
                SendClientMessage(playerid, COLOR_GRAD2, string);
                return 1;

            }
            new payout = idx * 25;
            if(GetPlayerCash(playerid) < payout)
        {
          format(string, sizeof(string), "* You used %d characters which cost $%d, you don't have enough.", offset, payout);
          SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
          return 1;
        }
            GivePlayerCash(playerid, - payout);
            SBizzInfo[7][sbTill] += payout;
            ExtortionSBiz(7, payout);
            format(string, sizeof(string), "Advertisement: %s, Contact: %s Ph: %d", result, sendername,PlayerInfo[playerid][pPnumber]);
            OOCNews(TEAM_GROVE_COLOR,string);
            format(string, sizeof(string), "~r~Paid $%d~n~~w~Message contained: %d Characters", payout, idx);
            GameTextForPlayer(playerid, string, 5000, 5);
            if (PlayerInfo[playerid][pAdmin] < 1){SetTimer("AddsOn", addtimer, 0);adds = 0;}
            }
            else
            {
             SendClientMessage(playerid,COLOR_GREY,"You are not level 3 !");
            }
        }
        return 1;
    }
pawn Код:
public AddsOn()
{
    adds=1;
    return 1;
}
Can someone tell me why did the bug appear?
Reply
#2

I didn't understood the code completly. But it looks okey. Maybe OnPlayerConnect() stop the timer to be sure and make it availble the player to make an advert
Reply
#3

'adds' will always be 1, since the timer will never be executed to be 0
pawn Код:
if(PlayerInfo[playerid][pLevel] >= 3)
            {
                ...
                if ((!adds) && (PlayerInfo[playerid][pAdmin] < 1))
                {
                    format(string, sizeof(string), "  Please try again later, %d minute between Advertisements !", (addtimer/60000));
                    SendClientMessage(playerid, COLOR_GRAD2, string);
                    return 1;

                }
                ...
                if (PlayerInfo[playerid][pAdmin] < 1)
                {
                    SetTimer("AddsOn", addtimer, 0);adds = 0;
                }
            }
For the code to get to the check, the player needs to be admin 3 or more, but for the timer to execute, he needs to be lower then 1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)