Nu sunteti conectat. Conectati-va sau inregistrati-va

Vezi subiectul anterior Vezi subiectul urmator In jos Mesaj [Pagina 1 din 1]

1 Sistem de report la data de Dum Mar 11, 2018 10:42 pm

Pitiku

avatar

Salut , cu ajutorul acestui tutorial playerii pot cere ajutor adminilor sau pentru a reporta anumiti jucatori.

Pentru inceput avem nevoie de urmatoarele include-uri: sscanf2 & zcmd.

Variabile


Adaugam acest cod la inceputul gamemode-ului.
Cod:

#define MAX_REPORTS 1000
#define INVALID_REPORT_ID -1

forward Heartbeat();
new JustReported[MAX_PLAYERS];

enum rInfo
{
 rReportFrom[MAX_PLAYER_NAME],  
 rReporterID, 
 rReport[128], 
 rReplyTimer,
 rChecker,
 rBeingUsed
}
new Report[MAX_REPORTS][rInfo];

Functii


La OnGameModeInit adaugam:
Cod:

SetTimer("Heartbeat", 1000, 1);

Mai jos adaugam:
Cod:

public Heartbeat()
{
 for(new i = 0; i < MAX_PLAYERS; i++)
 {
    if(JustReported[i] > 0)
 JustReported--;
 }
 return 1;
}


La OnPlayerConnect adaugam:
Cod:

JustReported[playerid] = 0;

La OnPlayerDisconnect adaugam:
Cod:

for(new i = 0; i < MAX_REPORTS; i++)
 {
 if(Report[i][rReporterID] == playerid && Report[i][rChecker] != INVALID_PLAYER_ID)
 {
 Report[i][rReporterID] = INVALID_PLAYER_ID;
 Report[i][rChecker] = INVALID_PLAYER_ID;
 Report[i][rReporterID] = INVALID_PLAYER_ID;
 format(Report[i][rReport], 128, "None");
 format(Report[i][rReportFrom], 128, "None");
 Report[i][rChecker] = INVALID_PLAYER_ID;
 KillTimer(Report[i][rReplyTimer]);
 }
 }

La sfarsitul gamemode-ului adaugam:
Cod:

stock SendReportToAdmin(rid, reportfrom, report[])
{
 Report[rid][rReporterID] = reportfrom;
 new string[128], name[MAX_PLAYER_NAME];
 Report[rid][rBeingUsed] = 1;
 GetPlayerName(reportfrom, name, sizeof(name));
 format(Report[rid][rReport], 128, "%s", report);
 format(Report[rid][rReportFrom], 128, "%s", name);
 for(new i = 0; i < MAX_PLAYERS; i++)
 {
    if(IsPlayerAdmin(i))
    {
        format(string, sizeof(string), "Report from: %s (RID: %d): %s", name, rid, report);
 SendClientMessage(i, -1, string);
 }
 }
}

Comenzile sunt urmatoarele:
Cod:

CMD:report(playerid, params[])
{
 new string[128];
 if(!isnull(params))
 {
    if(JustReported[playerid] > 0)
 {
 format(string, sizeof(string), "You already have a report. Please wait %d seconds more.", JustReported[playerid]);
    SendClientMessage(playerid, -1, string);
 return 1;
 }
 
        if(strlen(params) > 50)
     return SendClientMessage(playerid, -1, "Your message is too long - the limit is 50 characters.");
 
 
 new name[MAX_PLAYER_NAME];
 GetPlayerName(playerid, name, sizeof(name));
 
 new reportid;
 for(new i = 0; i < MAX_REPORTS; i++)
 {
    if(Report[i][rBeingUsed] == 0)
    {
 reportid = i;
 break;
 }
 }
 
 JustReported[playerid] = 25;
 
 SendReportToAdmin(reportid, playerid, params);
 SendClientMessage(playerid, -1, "You report has been sent to admins online.");
 }
 else
 {
 SendClientMessage(playerid, -1, "USAGE: /report [reporttext]");
 }
 return 1;
}

CMD:reports(playerid, params[])
{
 if(IsPlayerAdmin(playerid))
 {
 new string[1000];
 SendClientMessage(playerid, -1, "___________________________________________________________");
 SendClientMessage(playerid, -1, "REPORTS:");
 for(new r = 0; r < MAX_REPORTS; r++)
 {
    if(Report[r][rBeingUsed] == 1)
    {
        format(string, sizeof(string), "Report from %s (RID: %d): %s", Report[r][rReportFrom], r, Report[r][rReport]);
 }
 }
 SendClientMessage(playerid, -1, string);
 SendClientMessage(playerid, -1, "___________________________________________________________");
 }
 else
 {
 SendClientMessage(playerid, -1, "You are not an admin.");
 }
 return 1;
}

forward ReplyTimer(reportid);
public ReplyTimer(reportid)
{
 Report[reportid][rReporterID] = INVALID_PLAYER_ID;
 Report[reportid][rChecker] = INVALID_PLAYER_ID;
 format(Report[reportid][rReport], 128, "None");
 format(Report[reportid][rReportFrom], 128, "None");
 Report[reportid][rChecker] = INVALID_PLAYER_ID;
 Report[reportid][rBeingUsed] = 0;
 KillTimer(Report[reportid][rReplyTimer]);
 return 1;
}

CMD:reply(playerid, params[])
{
 new string[128];
 new reportid = INVALID_REPORT_ID;
 for(new i = 0; i < MAX_REPORTS; i++)
 {
 if(Report[i][rReporterID] == playerid && Report[i][rChecker] != INVALID_PLAYER_ID)
 {
 reportid = i;
 }
 }
 if(reportid == INVALID_REPORT_ID)
 {
 SendClientMessage(playerid, -1, "You don't have any reports being reviewed at the moment.");
 return 1;
 }
 if(IsPlayerConnected(Report[reportid][rChecker]))
 {
    new name[MAX_PLAYER_NAME], checkername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(playerid, checkername, MAX_PLAYER_NAME);
 format(string, sizeof(string), "%s(ID: %d) replies: %s", name, playerid, params);
 SendClientMessage(Report[reportid][rChecker], -1, string);

 format(string, sizeof(string), "Reply sent to %s: %s", checkername, params);
 SendClientMessage(playerid,  -1, string);
 }
 else SendClientMessage(playerid, -1, "Player not connected.");
 return 1;
}

CMD:acceptreport(playerid, params[])
{
 if(IsPlayerAdmin(playerid))
 {
 new string[128], id;
 if(sscanf(params, "d", id)) return SendClientMessage(playerid, -1, "USAGE: /acceptreport [reportid]");
 
 if(Report[id][rBeingUsed] == 0)
 {
 SendClientMessage(playerid, -1, "That report is not being used!");
 return 1;
 }
 
 new playername[MAX_PLAYER_NAME];
 GetPlayerName(playerid, playername, sizeof(playername));
 format(string, sizeof(string), "Admin %s has accepted your report, you have 1 minute to talk to him via /reply", playername);
 SendClientMessage(Report[id][rReporterID], -1, string);
 format(string, sizeof(string), "You had accepted %s's report.", Report[id][rReportFrom]);
 SendClientMessage(playerid, -1, string);
 
 Report[id][rChecker] = playerid;
 Report[id][rBeingUsed] = 0;
 Report[id][rReplyTimer] = SetTimerEx("ReplyTimer", 60000, false, "d", id);
 }
 else
 {
    SendClientMessage(playerid, -1, "You are not an admin.");
 }
 return 1;
}

Robotelul cu reclame


Robot reclame
5€= 1 saptamana
10€= 1 luna
15€= 6 luni
Data de inregistrare: 15/02/2013
Reclama ta aici!

Mesaj de scris aici

Vezi subiectul anterior Vezi subiectul urmator Sus Mesaj [Pagina 1 din 1]

Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum