Forbidname [help] - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Forbidname [help] (
/showthread.php?tid=340864)
Forbidname [help] -
Kudoz - 08.05.2012
I want to remove forbidden names i have added. here is the script:
(from LuxAdmin)
pawn Код:
dcmd_forbidname(playerid,params[])
{
if(AccInfo[playerid][Level] >= 4)
{
if(!strlen(params)) return
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /forbidname [Name]") &&
SendClientMessage(playerid, orange, "Function: Will block a specified Name");
new File:BLfile, string[128];
BLfile = fopen("LuxAdmin/Config/ForbiddenNames.cfg",io_append);
format(string,sizeof(string),"%s\r\n",params[1]);
fwrite(BLfile,string);
fclose(BLfile);
UpdateConfig();
SendCommandToAdmins(playerid,"ForbidName");
format(string, sizeof(string), "|- |Admin| ( \"%s\" ) has added the Name ( \"%s\" ) to the BLACKLIST", pName(playerid), params);
return MessageToAdmins(green,string);
}
else return ErrorMessages(playerid, 5);
}
I want a cmd /allowname or something to remove it from the forbiddennamelist.. How can I do that?
Re: Forbidname [help] -
warcodes_ - 08.05.2012
Use a ini system and name the files with the players name, then simply remove there files when you like.
Re: Forbidname [help] -
Infinity90 - 08.05.2012
Or you can just go in the scriptfiles where the ForbinNames are located then delete the name.....
Re: Forbidname [help] -
Kudoz - 08.05.2012
Yea, but I want a command for it ingame, and i dont know a sh*t about scriptfiles-locations..
Re: Forbidname [help] -
warcodes_ - 08.05.2012
I am pretty sure you can read the file, and delete a specific line with a string on it with default functions, which is what your using.
Re: Forbidname [help] -
ReneG - 08.05.2012
Rough example
pawn Код:
CMD:forbidname(playerid, params[])
{
new
name[24], // The name to write
string[28] // The string we will be writing.
;
if(isnull(params)) // If they didn't type a name.
{
return SendClientMessage(playerid, -1, "USAGE: /forbidname [name]");
}
else
{
File:names = fopen("forbidden_names.txt",io_append); // Opens the file for writing.
format(string, 28, "%s\r\n", name); // Formats the string for file format. "\r\n" starts a new line each time.
fwrite(names, string); // write the formatted string to the file
fclose(names); // and close it!
}
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
new
name[24], // name of the player
string[28] // the string that we will read from the file
;
GetPlayerName(playerid, name, 24); // Get the player's name
if(!fexist("forbidden_names.txt"))
{
// if the file does not exist, then stop running the code.
// because reading a file that doesn't exist crashes the server
print("File [forbidden_names.txt] does not exist");
return 1;
}
new File:names = fopen("forbidden_names.txt", io_read); // open the file for reading.
while(fread(names,string)) // while there is text in a line read it and store in the string
{
if(!strcmp(name, string, true)) // if the player's name matches any name in the file
{
SendClientMessage(playerid, -1, "That is an invalid name");
Kick(playerid); // it kicks them
}
}
return 1;
}
EDIT: didn't read that you needed a /remove name command