Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new _fileData[256][11][256]
- new _fileCount
- public plugin_init()
- {
- register_plugin( PLUGIN, VERSION, AUTHOR )
- _loadFile("cmdtext.txt")
- }
- public _loadFile(filename[64])
- {
- new config[64], file
- get_configsdir(config, charsmax(config))
- format(filename, charsmax(filename), "%s/%s", config, filename)
- if(!file_exists(filename))
- {
- write_file(filename, "; This file has been created automatically")
- write_file(filename, "; ")
- write_file(filename, "; Example: ^"command_name^" ^"acces required (ex: d)^", s:arg1, s:arg2, n:arg3, n:arg4, f:arg5, f:arg6, s:arg7, ^"Text you want to print on chat^"")
- write_file(filename, "; Replace args with targetname to get the name of target")
- write_file(filename, "; Replace args with adminname to get the name of admin")
- write_file(filename, "; s: = string; n: = num; f: = float")
- }
- file = fopen(filename,"r")
- if (file)
- {
- while (!feof(file))
- {
- fgets(file,_fileData[_fileCount][0],charsmax(_fileData[][]))
- trim(_fileData[_fileCount][0])
- if (_fileData[_fileCount][0][0] != '"')
- continue;
- if (parse(_fileData[_fileCount][0],
- _fileData[_fileCount][1],charsmax(_fileData[][]), // command
- _fileData[_fileCount][2],charsmax(_fileData[][]), // access required
- _fileData[_fileCount][3],charsmax(_fileData[][]), // argument 1
- _fileData[_fileCount][4],charsmax(_fileData[][]), // argument 2
- _fileData[_fileCount][5],charsmax(_fileData[][]), // argument 3
- _fileData[_fileCount][6],charsmax(_fileData[][]), // argument 4
- _fileData[_fileCount][7],charsmax(_fileData[][]), // argument 5
- _fileData[_fileCount][8],charsmax(_fileData[][]), // argument 6
- _fileData[_fileCount][9],charsmax(_fileData[][]), // argument 7
- _fileData[_fileCount][10],charsmax(_fileData[][])) < 2) // text format
- {
- log_amx("[err] Line %d is wrong formatted!", _fileCount)
- continue;
- }
- log_amx("[debug] #%d: %s", _fileCount, _fileData[_fileCount][0])
- log_amx("[debug] #%d: %s %s %s %s %s %s %s %s %s %s", _fileCount,
- _fileData[_fileCount][1],
- _fileData[_fileCount][2],
- _fileData[_fileCount][3],
- _fileData[_fileCount][4],
- _fileData[_fileCount][5],
- _fileData[_fileCount][6],
- _fileData[_fileCount][7],
- _fileData[_fileCount][8],
- _fileData[_fileCount][9],
- _fileData[_fileCount][10])
- _fileCount++;
- if(_fileCount > 255)
- {
- log_amx("[err] Too many lines in the file, max allowed are 256 lines!")
- break;
- }
- }
- fclose(file);
- }
- server_print("[AMXX] Loaded %d command%s from file.", _fileCount, _fileCount == 1 ? "" : "s")
- return PLUGIN_HANDLED
- }
- public client_command(id)
- {
- new command[32], argument = 1, paramsplit[11][5][64], message[192], count = 0, Float:floatmsg
- read_argv(0, command, charsmax(command))
- if(get_cvar_num("amx_show_activity") == 0)
- {
- for(new i; i < _fileCount; i++)
- {
- if(equali(command, _fileData[i][1]))
- {
- log_amx("[debug] Command '%s' detected", _fileData[i][1])
- if(get_user_flags(id) & read_flags(_fileData[i][2]))
- {
- log_amx("[debug] Access '%s' detected", _fileData[i][2])
- for(new a; a < 11; a++)
- {
- if(_fileData[i][a][1] == ':')
- {
- log_amx("[debug] Delimiter ':' detected")
- paramsplit[a][4][0] = -1
- split(_fileData[i][a], paramsplit[a][0], 63, paramsplit[a][1], 63, ":")
- log_amx("[debug] String splited into '%s' and '%s'", paramsplit[a][0], paramsplit[a][1])
- if(paramsplit[a][0][0] == 's') // string
- paramsplit[a][4][0] = 1
- else if(paramsplit[a][0][0] == 'n') // integer (num)
- paramsplit[a][4][0] = 2
- else if(paramsplit[a][0][0] == 'f') // float
- paramsplit[a][4][0] = 3
- if(equali(paramsplit[a][1], "targetname"))
- {
- read_argv(argument, paramsplit[a][1], charsmax(paramsplit[][]))
- paramsplit[a][3][0] = cmd_target(id, paramsplit[a][1], CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)
- get_user_name(paramsplit[a][3][0], paramsplit[a][0], charsmax(paramsplit[][]))
- argument++;
- log_amx("[debug] A target name has been found")
- log_amx("[debug] Name returned: '%s'", paramsplit[a][0])
- }
- else if(equali(paramsplit[a][1], "adminname"))
- {
- log_amx("[debug] An admin name has been found")
- get_user_name(id, paramsplit[a][0], charsmax(paramsplit[][]))
- log_amx("[debug] Name returned: '%s'", paramsplit[a][0])
- }
- else
- {
- log_amx("[debug] Argument %s has been found !", paramsplit[a][1])
- read_argv(argument, paramsplit[a][1], charsmax(paramsplit[][]))
- formatex(paramsplit[a][0], charsmax(paramsplit[][]), "%s", paramsplit[a][1])
- argument++;
- log_amx("[debug] Message returned: '%s'", paramsplit[a][0])
- }
- if(paramsplit[a][4][0] == 2)
- paramsplit[a][0][0] = str_to_num(paramsplit[a][1])
- else if(paramsplit[a][4][0] == 3)
- floatmsg = str_to_float(paramsplit[a][1])
- count++;
- }
- }
- log_amx("[debug] Loop stopped at %d arguments!", count)
- switch(count)
- {
- case 1:
- {
- formatex(message, charsmax(message), _fileData[i][10],
- (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0])
- log_amx("[debug] Message '%s' has been formatted!", message)
- }
- case 2:
- { formatex(message, charsmax(message), _fileData[i][10],
- (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],
- (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0])
- log_amx("[debug] Message '%s' has been formatted!", message)
- }
- case 3:
- {
- formatex(message, charsmax(message), _fileData[i][10],
- (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],
- (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],
- (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0])
- log_amx("[debug] Message '%s' has been formatted!", message)
- }
- case 4:
- {
- formatex(message, charsmax(message), _fileData[i][10],
- (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],
- (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],
- (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0],
- (paramsplit[6][4][0] == 3) ? floatmsg : paramsplit[6][0])
- log_amx("[debug] Message '%s' has been formatted!", message)
- }
- case 5:
- {
- formatex(message, charsmax(message), _fileData[i][10],
- (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],
- (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],
- (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0],
- (paramsplit[6][4][0] == 3) ? floatmsg : paramsplit[6][0],
- (paramsplit[7][4][0] == 3) ? floatmsg : paramsplit[7][0])
- log_amx("[debug] Message '%s' has been formatted!", message)
- }
- case 6:
- {
- formatex(message, charsmax(message), _fileData[i][10],
- (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],
- (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],
- (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0],
- (paramsplit[6][4][0] == 3) ? floatmsg : paramsplit[6][0],
- (paramsplit[7][4][0] == 3) ? floatmsg : paramsplit[7][0],
- (paramsplit[8][4][0] == 3) ? floatmsg : paramsplit[8][0])
- log_amx("[debug] Message '%s' has been formatted!", message)
- }
- case 7:
- {
- formatex(message, charsmax(message), _fileData[i][10],
- (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],
- (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],
- (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0],
- (paramsplit[6][4][0] == 3) ? floatmsg : paramsplit[6][0],
- (paramsplit[7][4][0] == 3) ? floatmsg : paramsplit[7][0],
- (paramsplit[8][4][0] == 3) ? floatmsg : paramsplit[8][0],
- (paramsplit[9][4][0] == 3) ? floatmsg : paramsplit[9][0])
- log_amx("[debug] Message '%s' has been formatted!", message)
- }
- }
- client_print(0, print_chat, "%s", message, paramsplit[3][0], paramsplit[4][0])
- log_amx("[debug] Message '%s' has been printed into chat", message, paramsplit[3][0], paramsplit[4][0])
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement