Raised This Month: $ Target: $400
 0% 

write to file from amx menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nobuddy
Junior Member
Join Date: Jan 2007
Old 01-17-2007 , 14:06   write to file from amx menu
Reply With Quote #1

hello
i write a little plugin to check players nick and password.
nicks and pass is in file nicks.txt
i want to add new users whitout openning this file but from amx menu or from CS console.
unfortunetly i dont know how it do :\

please give me some clue.

sory for my english ;)
nobuddy is offline
s p l i t
Senior Member
Join Date: May 2006
Location: US, NC
Old 01-17-2007 , 15:48   Re: write to file from amx menu
Reply With Quote #2

http://www.amxmodx.org/funcwiki.php?go=func&id=88
s p l i t is offline
Send a message via AIM to s p l i t Send a message via MSN to s p l i t
nobuddy
Junior Member
Join Date: Jan 2007
Old 01-18-2007 , 11:48   Re: write to file from amx menu
Reply With Quote #3

ok i explain

i know that command
write_file("addons/amxmodx/nicks.txt","nick pass",1)
add a new line at the end of file nicks.txt
but i cant use this command froma CS console

question :
what to do to use this command froma CS console ????
or
how to add a line to file nicks.txt from CS console ????

[of coz i'm an admin ;)]

PS : i know my english is poor :]
nobuddy is offline
Salepate
Junior Member
Join Date: Jan 2007
Old 01-18-2007 , 12:20   Re: write to file from amx menu
Reply With Quote #4

In your plugin you have to use :
Code:
register_clcmd();
To register a command like amx_filewrite <text>
retrieve arg with
Code:
read_argv();
in the function executed by
Code:
register_clcmd();
and you finish with
Code:
write_file("dir/file.txt",string,-1);
Where :
dir = file directory
file.txt = filename
string = variable where is set the retrieved argument
and -1 if you want to add the line to the end.

I've just given you syntax command but not how to do it, if you need some help I will be glad to help you (not to make the code)

You can check how those functions work by reading .inc files or reading other plugins or checking the doc on this website.

For example - From amxmodx.inc :
Code:
/* Registers function which will be called from client console. */ native register_clcmd(const client_cmd[],const function[],flags=-1, info[]="");
Salepate is offline
nobuddy
Junior Member
Join Date: Jan 2007
Old 01-18-2007 , 13:05   Re: write to file from amx menu
Reply With Quote #5

ok I write somthing like that. please somebody check this form me
i'm beginner :]

public plugin_init()
{
register_clcmd("amx_adduser","newuseradd")

return PLUGIN_CONTINUE
}


public newuseradd(id)
{
if(!is_user_admin(id))
{
client_print(id,print_console,"You are not an administrator. Please refrain from using this command!")
return PLUGIN_HANDLED
}
new player[50],pass[50]
read_argv(1,player,49)
read_argv(2,pass,49)
new whattowrite[100]
format(whattowrite,99,"%s","%s",player,pass)
new target=cmd_target(id,player,9)
write_file("addons/amxmodx/nicks.txt",whattowrite,-1)
client_print(id,print_console,"User %s, password %s wrote to file.",player,pass)
return PLUGIN_HANDLED
}

Last edited by nobuddy; 01-18-2007 at 13:19.
nobuddy is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 01-18-2007 , 16:00   Re: write to file from amx menu
Reply With Quote #6

Almost. Remember you can post code in [small][/small] tags.
Minor changes:
Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("plugin name", "1.00", "plugin author")     register_clcmd("amx_adduser", "newuseradd") } public newuseradd(id) {     if ( ! is_user_admin(id) ) {         client_print(id, print_console, "You are not an administrator. Please refrain from using this command!")         return PLUGIN_HANDLED     }         new whattowrite[64], player[32], pass[28]         read_argv(1, player, 31)     read_argv(2, pass, 27)         new target = cmd_target(id, player, 9)     get_user_name(target, player, 31)         format(whattowrite, 63, "^"%s^" ^"%s^"", player, pass)     write_file("addons/amxmodx/nicks.txt", whattowrite)         client_print(id, print_console, "User %s, password %s wrote to file.", player, pass)         return PLUGIN_HANDLED }
[ --<-@ ] Black Rose is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode