24/03/2023 14:07
(24/03/2023 12:43)White_Blue Escreveu: Use DOF2.
Exemplo:
Código PHP:#define Banidos "/Banidos/%s.txt"
CMD:removerban(playerid, const params[]) {
new str[32];
if(sscanf(params, "s[32]", str)) return SendClientMessage(playerid, -1, "Use: /removerban [nick]");
if(strlen(str) > 32 || strlen(str) < 0) return SendClientMessage(playerid, -1, "O nick deve conter entre 0 e 32 caracteres.");
RemoveBan(playerid, str);
return 1;
}
stock RemoveBan(playerid, const nick[]) {
new string[128];
format(string, MAX_PLAYER_NAME, Banidos, nick);
if(DOF2_FileExists(string)) {
SendClientMessage(playerid, -1, "Ban inexistente");
return 1;
}
else {
DOF2_RemoveFile(string);
}
return 1;
}
Use str[MAX_PLAYER_NAME + 1] (1 = caracter nulo "\0".));
No sscanf use s[25];
no if ele fez um if redundante, o correto:
Código PHP:
stock RemoveBan(playerid, const nick[]) {
new string[128];
format(string, MAX_PLAYER_NAME + 1, Banidos, nick);
if(!DOF2_FileExists(string)) {
SendClientMessage(playerid, -1, "Banimento inexistente.");
return 1;
}
DOF2_RemoveFile(string);
SendClientMessage(playerid, -1, "Ban removido.");
return 1;
}