ReportTime
#1

I want this report timer to get -1 every second so that the player can report again but I get errors every time.Can you help me?These are the places that I have it.

pawn Код:
new ReportTime[MAX_PLAYERS];
pawn Код:
CMD:report(playerid, params[])

{
    new string[128];
    if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
    if(PlayerInfo[playerid][pRMute] > 0) return SendClientMessage(playerid, COLOR_GREY, "You are muted from reporting.");
    if(AntiAdv(playerid, params)) return 1;
    if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128.");
    if(ReportTime[playerid] > 0)
    {
        format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", ReportTime[playerid]);
        SendClientMessage(playerid, COLOR_GREY, string);
        return 1;
    }
   
    SendReportToQue(playerid, params);
    Log("logs/reports.log", string);
    SendClientMessage(playerid, COLOR_ORANGE, "Your report have been sent to the online admins, Please be patient.");
        ReportTime[playerid] = 25;
    SetTimerEx("ReportTimer", 1000, false, "i", playerid);
    return 1;
}
Reply
#2

Use gettime instead, then you dont need any timers.
pawn Код:
if(gettime() - ReportTime[playerid] < 25) return SendClientMessage(playerid, -1, "You can only report players every 25 seconds!"); // Player has reported a player within the last 25 seconds.

ReportTime[playerid]  = gettime(); //The player has now reported a player
Reply
#3

Quote:
Originally Posted by Richie©
Посмотреть сообщение
Use gettime instead, then you dont need any timers.
pawn Код:
if(gettime() - ReportTime[playerid] < 25) return SendClientMessage(playerid, -1, "You can only report players every 25 seconds!"); // Player has reported a player within the last 25 seconds.

ReportTime[playerid]  = gettime(); //The player has now reported a player
I now did other thing.I did the foreach but now it says that I have 24 seconds.How can I make it so it goes down and down?

pawn Код:
CMD:report(playerid, params[])

{
    new string[128];
    if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
    if(PlayerInfo[playerid][pRMute] > 0) return SendClientMessage(playerid, COLOR_GREY, "You are muted from reporting.");
    if(AntiAdv(playerid, params)) return 1;
    if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128.");
    if(ReportTime[playerid] > 0)
    {
        format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", ReportTime[playerid]);
        SendClientMessage(playerid, COLOR_GREY, string);
        return 1;
    }
    SendReportToQue(playerid, params);
    Log("logs/reports.log", string);
    SendClientMessage(playerid, COLOR_ORANGE, "Your report have been sent to the online admins, Please be patient.");
    ReportTime[playerid] = 25;
    SetTimerEx("ReportTimer", 1000, false, "i", playerid);
    foreach(Player, i)
    if(ReportTime[i] > 0)
    {
        ReportTime[i]--;
    }
    return 1;
}
Reply
#4

If you want to show player how long they have to wait, try this;
pawn Код:
SetTimerEx("ReportTimer", 1000, false, "ii", playerid, 25); // In your report command, 25 secs

forward ReportTimer(playerid, seconds);
public ReportTimer(playerid, seconds)
{
    if(!IsPlayerConnected(playerid)) return 1; // If player left server, no need to keep running this timer..
    ReportTime[playerid] = seconds; // This is how many seconds player have to wait b4 report again
    if(seconds != 0) SetTimerEx("ReportTimer", 1000, false, "ii", playerid, seconds-1); // 1 sec timer, that decreases
}
Reply
#5

Why would you use a Timer for this? Richie has the right idea if your using a timer your doing it assbackwards.
Reply
#6

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Why would you use a Timer for this? Richie has the right idea if your using a timer your doing it assbackwards.
Can you tell me the full code then? Thanks
Reply
#7

I already provided the full code for this by using both timer and gettime.
Reply
#8

pawn Код:
CMD:report(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
    if(PlayerInfo[playerid][pRMute] > 0) return SendClientMessage(playerid, COLOR_GREY, "You are muted from reporting.");
    if(AntiAdv(playerid, params)) return 1;
    if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128.");
    if(gettime() - ReportTime[playerid] < 25)
    {
        format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", ReportTime[playerid]);
        SendClientMessage(playerid, COLOR_GREY, string);
    }
    else
    {
        SendReportToQue(playerid, params);
        Log("logs/reports.log", string);
        SendClientMessage(playerid, COLOR_ORANGE, "Your report have been sent to the online admins, Please be patient.");
        ReportTime[playerid] = gettime();
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
pawn Код:
CMD:report(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
    if(PlayerInfo[playerid][pRMute] > 0) return SendClientMessage(playerid, COLOR_GREY, "You are muted from reporting.");
    if(AntiAdv(playerid, params)) return 1;
    if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128.");
    if(gettime() - ReportTime[playerid] < 25)
    {
        format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", ReportTime[playerid]);
        SendClientMessage(playerid, COLOR_GREY, string);
    }
    else
    {
        SendReportToQue(playerid, params);
        Log("logs/reports.log", string);
        SendClientMessage(playerid, COLOR_ORANGE, "Your report have been sent to the online admins, Please be patient.");
        ReportTime[playerid] = gettime();
    }
    return 1;
}
It says "You need to wait 13867396 more seconds before making a report message again." Lol...Anyways thank you both I will +Rep you
Reply
#10

pawn Код:
format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", ReportTime[playerid]);
Should be:

pawn Код:
format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", 25-(gettime()-ReportTime[playerid]));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)