15.04.2015, 04:20
Hello, im using a command /showdisables (means show banned players on my server)..
Those who get disabled are listed in a disable.txt file, which is shown by (/showdisables) in a dialog.
the problem is, when those players are undisabled, there name stay on .txt file? how to remove it after they got undisabled (unbanned).
here is some code:
And here's the /removedisable
Those who get disabled are listed in a disable.txt file, which is shown by (/showdisables) in a dialog.
the problem is, when those players are undisabled, there name stay on .txt file? how to remove it after they got undisabled (unbanned).
here is some code:
PHP код:
COMMAND:showdisables(playerid,parmas[])
{
new read[200],ss[1008],op[1000],bool:NextDialog = false;
if(PlayerInfo[playerid][pAdminlevel] < 1)
{
SendClientMessage(playerid,COLOR_ERROR,""ERROR_MSG"");
return 1;
}
format(op,sizeof(op),"");
new File:log = fopen("DisabledPlayers.txt",io_read);
while(fread(log,read))
{
strcat(read,"\n",200);
strcat(op,read,1000);
ln[playerid]++;
if(ln[playerid] == 110)
{
NextDialog = true;
break;
}
}
fclose(log);
if(strlen(op) <= 3)
{
SendClientMessage(playerid,-1,"{ff0000}No Players are Currently Disabled.");
return 1;
}
format(ss,sizeof(ss),""WHITE"%s",op);
if(NextDialog == false)ShowPlayerDialog(playerid, 110, DIALOG_STYLE_LIST, "Disabled Players",ss, "Select", "Cancel");
else
ShowPlayerDialog(playerid, 111, DIALOG_STYLE_LIST, "Disabled Players",ss, "Select", "Next Page");
return 1;
}
PHP код:
COMMAND:removedisable(playerid, parmas[])
{
if(PlayerInfo[playerid][pSpawned] == 1)
{
new TargetID[MAX_PLAYER_NAME];
new string[256];
new path[100];
if(PlayerInfo[playerid][pAdminlevel] < 1)
{
SendClientMessage(playerid,COLOR_ERROR,""ERROR_MSG"");
return 1;
}
if(sscanf(parmas,"s[128]",TargetID) || isnull(parmas))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /removedisable (Name)");
return 1;
}
format(path,sizeof(path),"Disables/%s.ini",TargetID);
if(!fexist(path))
{
format(string,sizeof(string),"There Is No User Named as "YELLOW"%s "RED"Disabled.",TargetID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
fremove(path);
format(string,sizeof(string),"%s's Disable Has Been Removed Sucessfully.",TargetID);
SendClientMessage(playerid,COLOR_ADMIN,string);
printf("%s's Disable Has Been Removed By %s",TargetID,PlayerInfo[playerid][pName]);
fdeleteline("DisabledPlayers.txt", TargetID); // it doesn't deletes the targetname? why??
}
else
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Use This Command While You're Dead.");
}
return 1;
}