Armazenar SOS -
ThuuGLif3 - 08.02.2017
Meu servidor possui um sistema de SOS, porйm, aparece os pedidos de ajuda apenas para os admins que tгo em modo trabalho. Desejava que armazenasse os SOS enviados quando estava sem administradores ou nгo tivesse trabalhando, sendo assim o admin digitava /versos e apareciam todos que nгo foram atendidos lб. Como posso fazer?
Respuesta: Armazenar SOS -
SammyJ - 08.02.2017
Nгo posso esboзar um cуdigo funcional, pфs estou no trabalho. Mas vou dar uma dica.
Vocк pode criar uma variбvel, bidimensional, para armazenar informaзгo que vocк julgar importantes.
Exe:
PHP код:
#define MAX_REPORTES (25)
enum r_info
{
texto[128],
jogadorId,
}
new Reporte[MAX_REPORTES][r_info];
stock RegistrarReporte(playerid, const rTexto[])
{
for(new i; i < sizeof(Reporte); i++)
{
if(!Reporte[i][reporteAtivo])
{
Reporte[i][reporteAtivo] = true;
format(Reporte[i][texto], 128, rTexto);
Reporte[i][jogadorId] = playerid;
break;
}
}
}
depois й sу vocк trabalhar com loops, salvando as informaзхes. Quando eu tiver tempo esboзarei um cуdigo melhor neste post dando edit.
Re: Armazenar SOS -
ThuuGLif3 - 08.02.2017
Poderia especificar mais? No caso, as loops. Fico no aguardo.
Re: Armazenar SOS -
ipsLuan - 08.02.2017
Use fwrite e escreva os reportes utilizando a quebra de linha para ficarem um abaixo do outro.
Apуs isso, crie um comando (de preferкncia em zcmd) que percorra esse arquivo listando todos os reportes.
Obs.: Use o loop com o fread para ler os reportes e logo apуs formate a string e use-a.
Re: Armazenar SOS -
ThuuGLif3 - 08.02.2017
Cara. Eu sou novato nessas paradas. Poderiam me dar um exemplo, ou explicando passo-a-passo?
Re: Armazenar SOS -
1sbedx - 08.02.2017
PHP код:
#include <a_samp>
#include <zcmd>
#define MAX_REPORTS (25)
enum reportData {
reportExists,
reportPlayer,
reportText[128]
};
new Report[MAX_REPORTS][reportData];
public OnFilterScriptInit()
{
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
stock ReportAdd(playerid, text[])
{
new reportid = GetFreeReportID();
if (reportid != -1)
{
Report[reportid][reportExists] = true;
Report[reportid][reportPlayer] = playerid;
format(Report[reportid][reportText], 128, text);
return reportid;
}
return -1;
}
stock GetFreeReportID()
{
for (new i = 0; i != MAX_REPORTS; i ++) if (!Report[i][reportExists])
return i;
return -1;
}
CMD:report(playerid, params[])
{
new reportid = ReportAdd(playerid, params);
if (reportid != -1)
{
for (new i = 0; i < MAX_PLAYERS; i ++) if (IsPlayerAdmin(i)) {
SendClientMessage(i, -1, "Foi recebido um relatуrio.");
}
SendClientMessage(playerid, -1, "Seu relatуrio foi enviado para todos os administradores on-line.");
}
else {
SendClientMessage(playerid, -1, "A lista de relatуrios estб cheia. Por favor, espere um pouco.");
}
return 1;
}
CMD:reports(playerid, params[])
{
new count, string[128];
if (!IsPlayerAdmin(playerid))
return 0;
for (new i = 0; i != MAX_REPORTS; i ++) if (Report[i][reportExists])
{
format(string, sizeof(string), "%i - %s [%i] relatou: %s", i, GetName(Report[i][reportPlayer]), Report[i][reportPlayer], Report[i][reportText]);
SendClientMessage(playerid, -1, string);
count++;
}
if (!count)
return SendClientMessage(playerid, -1, "Nгo hб relatуrios ativos a serem exibidos.");
return 1;
}
stock GetName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
CMD:ar(playerid, params[])
{
new reportid = strval(params), string[128];
if (!IsPlayerAdmin(playerid))
return 0;
format(string, sizeof(string), "%s aceitou o seu relatуrio.", GetName(playerid));
SendClientMessage(Report[reportid][reportPlayer], -1, string);
Report[reportid][reportExists] = false;
Report[reportid][reportPlayer] = INVALID_PLAYER_ID;
Report[reportid][reportText] = '\0';
return 1;
}
Re: Armazenar SOS -
ThuuGLif3 - 08.02.2017
Nгo desejo filterscript. Desejo fazer um cуdigo para meu GM, poderia adaptar? Sim. Porйm o cуdigo estб com erros, ao digitar /reports, nгo aparece nada. Fico grato pela tentativa.
Re: Armazenar SOS -
1sbedx - 08.02.2017
Quote:
Originally Posted by ThuuGLif3
Nгo desejo filterscript. Desejo fazer um cуdigo para meu GM, poderia adaptar? Sim. Porйm o cуdigo estб com erros, ao digitar /reports, nгo aparece nada. Fico grato pela tentativa.
|
Quote:
Originally Posted by 1sbedx
PHP код:
#include <a_samp>
#include <zcmd>
#define MAX_REPORTS (25)
enum reportData {
reportExists,
reportPlayer,
reportText[128]
};
new Report[MAX_REPORTS][reportData];
public OnFilterScriptInit()
{
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
stock ReportAdd(playerid, text[])
{
new reportid = GetFreeReportID();
if (reportid != -1)
{
Report[reportid][reportExists] = true;
Report[reportid][reportPlayer] = playerid;
format(Report[reportid][reportText], 128, text);
return reportid;
}
return -1;
}
stock GetFreeReportID()
{
for (new i = 0; i != MAX_REPORTS; i ++) if (!Report[i][reportExists])
return i;
return -1;
}
CMD:report(playerid, params[])
{
new reportid = ReportAdd(playerid, params);
if (reportid != -1)
{
for (new i = 0; i < MAX_PLAYERS; i ++) if (IsPlayerAdmin(i)) {
SendClientMessage(i, -1, "Foi recebido um relatуrio.");
}
SendClientMessage(playerid, -1, "Seu relatуrio foi enviado para todos os administradores on-line.");
}
else {
SendClientMessage(playerid, -1, "A lista de relatуrios estб cheia. Por favor, espere um pouco.");
}
return 1;
}
CMD:reports(playerid, params[])
{
new count, string[128];
if (!IsPlayerAdmin(playerid))
return 0;
for (new i = 0; i != MAX_REPORTS; i ++) if (Report[i][reportExists])
{
format(string, sizeof(string), "%i - %s [%i] relatou: %s", i, GetName(Report[i][reportPlayer]), Report[i][reportPlayer], Report[i][reportText]);
SendClientMessage(playerid, -1, string);
count++;
}
if (!count)
return SendClientMessage(playerid, -1, "Nгo hб relatуrios ativos a serem exibidos.");
return 1;
}
stock GetName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
CMD:ar(playerid, params[])
{
new reportid = strval(params), string[128];
if (!IsPlayerAdmin(playerid))
return 0;
format(string, sizeof(string), "%s aceitou o seu relatуrio.", GetName(playerid));
SendClientMessage(Report[reportid][reportPlayer], -1, string);
Report[reportid][reportExists] = false;
Report[reportid][reportPlayer] = INVALID_PLAYER_ID;
Report[reportid][reportText] = '\0';
return 1;
}
|
Re: Armazenar SOS -
ipsLuan - 08.02.2017
Quote:
Originally Posted by ThuuGLif3
Nгo desejo filterscript. Desejo fazer um cуdigo para meu GM, poderia adaptar? Sim. Porйm o cуdigo estб com erros, ao digitar /reports, nгo aparece nada. Fico grato pela tentativa.
|
Vocк entrou como administrador RCON?
Re: Armazenar SOS -
lucas_mdr1235 - 08.02.2017
vcs sгo fodas ele disse que possui o sistema ja no GM dele e vcs postando comandos e funзхes para serem adaptados ! Simples poste o CMD de /versos e o CMD usando pra enviar o SOS !