Raised This Month: $ Target: $400
 0% 

Name Checker


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 03-05-2006 , 18:33   Name Checker
Reply With Quote #1

Okay, I just scripted this plugin and it will not complie without errors, here is the code and errors. Please help.
Code:
//------------------------ //  Amx Mod X Script //------------------------ // //    Name Checker //       -- Checks a clients name if they were added to the file, changes there name to the one in the file. // //------------------------ // //    Names Stored In: //       --/addons/amxmodx/configs/name_checker.ini // //       This file is created automatically when the plugin is run for the first time. //       The names are loaded on map change. // //------------------------ // //    Cvars: // //       nc_enable < 0=off | 1=on > //              --Enables/Disables map objective showing // // //------------------------ // //    Commands: // //       nc_add <steamid> <name> //              --Adds client to the name checker list. // //       nc_del <steamid> //              --Deletes client from the name checker list. // //------------------------ // //    Changelog: // //        v1.0 - Initial Build // //------------------------ #include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("Name Checker","v1.0","Fire")     register_cvar("nc_enable","1")     register_concmd("nc_add","nc_add",ADMIN_IMMUNITY,"Adds a Name To Be Checked -- nc_add <steamid> <name>")     register_concmd("nc_del","nc_del",ADMIN_IMMUNITY,"Deletes a Name That Is Being Checked -- nc_del <steamid>") } public nc_add(id, level, cid) {     if(get_cvar_num("nc_enable") == 0)         return PLUGIN_HANDLED             if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED     new Arg1[32]     new Arg2[32]         read_argv(1, Arg1, 31)     read_argv(2, Arg2, 31)             new szConfigsdir[200]     get_configsdir(szConfigsdir, 199)         new szConfigfile[200]     format(szConfigfile, 199, "%s/name_checker.ini", szConfigsdir)         new iLine, szLinestr[256], iLen     while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {         if(szLinestr[0] == ';' || iLen <= 1 || equal(Arg1, szLinestr)) {         console_print(id,"%s's name is all ready being checked!", Arg2)             } else {         write_file("szConfigfile", "^"%s^" ^"%s^"", -1, Arg1, Arg2)             }         }     return PLUGIN_HANDLED } public nc_del(id, level, cid) {     if(get_cvar_num("nc_enable") == 0)         return PLUGIN_HANDLED             if (!cmd_access(id, level, cid, 2))         return PLUGIN_HANDLED     new Arg1[32]     read_argv(1, Arg1, 31)     new szConfigsdir[200]     get_configsdir(szConfigsdir, 199)         new szConfigfile[200]     format(szConfigfile, 199, "%s/name_checker.ini", szConfigsdir)         new iLine, szLinestr[256], iLen     while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {         if(szLinestr[0] == ';' || iLen <= 1 || equal(Arg1, szLinestr)) {         write_file("szConfigfile", "", iLine)         }     }     return PLUGIN_HANDLED } public client_authorized(id) {     if(get_cvar_num("nc_enable") == 0)         return PLUGIN_HANDLED             new szConfigsdir[200]     get_configsdir(szConfigsdir, 199)         new szConfigfile[200]     add(szConfigsdir, 199, "/name_checker.ini")     if(!file_exists(szConfigsdir)) {         write_file(szConfigfile, "; Name Checker -- By: Fire")         write_file(szConfigfile, "; -- Do Not Edit This --")     }         format(szConfigfile, 199, "%s/name_checker.ini", szConfigsdir)         new szSteamid[35]     get_user_authid(id, szSteamid, 34)         new iLine, szLinestr[256], iLen         new szName[35], szStoredSteamid[35]         while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {         if(szLinestr[0] == ';' || !iLen) continue         parse(szLinestr, szStoredSteamid, 34, szName, 34)         if(equal(szSteamid, szStoredSteamid)) {             client_cmd("name %s", szName)         }     }     return PLUGIN_HANDLED }
Code:
/home/users/amxmodx/tmp3/phpXzBHPF.sma(78) : error 088: number of arguments does not match definition
/home/users/amxmodx/tmp3/phpXzBHPF.sma(143) : error 035: argument type mismatch (argument 1)
Please Help +karma
Attached Files
File Type: sma Get Plugin or Get Source (name_checker.sma - 110 views - 3.5 KB)
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 03-05-2006 , 18:45  
Reply With Quote #2

compiles without error, but no warrenty if it works
Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init() {
	register_plugin("Name Checker","v1.0","Fire")
	register_cvar("nc_enable","1") 
	register_concmd("nc_add","nc_add",ADMIN_IMMUNITY,"Adds a Name To Be Checked -- nc_add <steamid> <name>")
	register_concmd("nc_del","nc_del",ADMIN_IMMUNITY,"Deletes a Name That Is Being Checked -- nc_del <steamid>")
}

public nc_add(id, level, cid) {

	if(get_cvar_num("nc_enable") == 0)
		return PLUGIN_HANDLED
		
	if (!cmd_access(id, level, cid, 3))
		return PLUGIN_HANDLED

	new Arg1[32]
	new Arg2[32]
	
	read_argv(1, Arg1, 31)
	read_argv(2, Arg2, 31)
		
	new szConfigsdir[200]
	get_configsdir(szConfigsdir, 199)
	
	new szConfigfile[200]
	format(szConfigfile, 199, "%s/name_checker.ini", szConfigsdir)
	
	new iLine, szLinestr[256], iLen
	while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {
	
		if(szLinestr[0] == ';' || iLen <= 1 || equal(Arg1, szLinestr)) {
			console_print(id,"%s's name is all ready being checked!", Arg2)
		} else {
			new temp_str[71]
			format(temp_str, 70, "^"%s^" ^"%s^"", Arg1, Arg2)
			write_file(szConfigfile, temp_str, -1)
		}
	}
	return PLUGIN_HANDLED
}


public nc_del(id, level, cid) {

	if(get_cvar_num("nc_enable") == 0)
		return PLUGIN_HANDLED
		
	if (!cmd_access(id, level, cid, 2))
		return PLUGIN_HANDLED

	new Arg1[32]
	read_argv(1, Arg1, 31)

	new szConfigsdir[200]
	get_configsdir(szConfigsdir, 199)
	
	new szConfigfile[200]
	format(szConfigfile, 199, "%s/name_checker.ini", szConfigsdir)
	
	new iLine, szLinestr[256], iLen
	while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {
	
		if(szLinestr[0] == ';' || iLen <= 1 || equal(Arg1, szLinestr)) {
			write_file(szConfigfile, "", iLine)
		}
	}
	return PLUGIN_HANDLED
}

public client_authorized(id) {

	if(get_cvar_num("nc_enable") == 0)
		return PLUGIN_HANDLED
		
	new szConfigsdir[200]
	get_configsdir(szConfigsdir, 199)
	
	new szConfigfile[200]
	add(szConfigsdir, 199, "/name_checker.ini")

	if(!file_exists(szConfigsdir)) {
		write_file(szConfigfile, "; Name Checker -- By: Fire")
		write_file(szConfigfile, "; -- Do Not Edit This --")
	}
	
	format(szConfigfile, 199, "%s/name_checker.ini", szConfigsdir)
	
	new szSteamid[35]
	get_user_authid(id, szSteamid, 34)
    
	new iLine, szLinestr[256], iLen
	
	new szName[35], szStoredSteamid[35]
	
	while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {
		if(szLinestr[0] == ';' || !iLen) continue

		parse(szLinestr, szStoredSteamid, 34, szName, 34)

		if(equal(szSteamid, szStoredSteamid)) {
			client_cmd(id, "name %s", szName)
		}
	}
	return PLUGIN_HANDLED
}
do not pass strings as a word to write_file ( eg: szConfigfile must be szConfigfile and NOT "szConfigfile")
write_file does not support fomating ( as you did : write_file(szConfigfile, "^"%s^" ^"%s^"", -1, Arg1, Arg2) ), only file , text, linenum
__________________
alias White Panther
karlos is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-05-2006 , 18:49  
Reply With Quote #3

Bad indentation, but whatever.

Did you really write this? It looks like you grabbed some code from one of the scripts I wrote. I'm like the only person that ever uses the variable name "szLinestr".

Anyways, here:

EDIT: Oh, karlos got to it first, oh well.

Code:
//------------------------ //  Amx Mod X Script //------------------------ // //    Name Checker //       -- Checks a clients name if they were added to the file, changes there name to the one in the file. // //------------------------ // //    Names Stored In: //       --/addons/amxmodx/configs/name_checker.ini // //       This file is created automatically when the plugin is run for the first time. //       The names are loaded on map change. // //------------------------ // //    Cvars: // //       nc_enable < 0=off | 1=on > //              --Enables/Disables map objective showing // // //------------------------ // //    Commands: // //       nc_add <steamid> <name> //              --Adds client to the name checker list. // //       nc_del <steamid> //              --Deletes client from the name checker list. // //------------------------ // //    Changelog: // //        v1.0 - Initial Build // //------------------------ #include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("Name Checker","v1.0","Fire")     register_cvar("nc_enable","1")     register_concmd("nc_add","nc_add",ADMIN_IMMUNITY,"Adds a Name To Be Checked -- nc_add <steamid> <name>")     register_concmd("nc_del","nc_del",ADMIN_IMMUNITY,"Deletes a Name That Is Being Checked -- nc_del <steamid>") } public nc_add(id, level, cid) {     if(get_cvar_num("nc_enable") == 0)         return PLUGIN_HANDLED             if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED     new Arg1[32]     new Arg2[32]         read_argv(1, Arg1, 31)     read_argv(2, Arg2, 31)             new szConfigsdir[200]     get_configsdir(szConfigsdir, 199)         new szConfigfile[200]     format(szConfigfile, 199, "%s/name_checker.ini", szConfigsdir)         new iLine, szLinestr[256], iLen     while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {         if(szLinestr[0] == ';' || iLen <= 1 || equal(Arg1, szLinestr)) {         console_print(id,"%s's name is all ready being checked!", Arg2)             } else {                     new szWrite[62]         format(szWrite,61,"^"%s^" ^"%s^"",Arg1,Arg2)         write_file(szConfigfile,szWrite, -1)             }         }     return PLUGIN_HANDLED } public nc_del(id, level, cid) {     if(get_cvar_num("nc_enable") == 0)         return PLUGIN_HANDLED             if (!cmd_access(id, level, cid, 2))         return PLUGIN_HANDLED     new Arg1[32]     read_argv(1, Arg1, 31)     new szConfigsdir[200]     get_configsdir(szConfigsdir, 199)         new szConfigfile[200]     format(szConfigfile, 199, "%s/name_checker.ini", szConfigsdir)         new iLine, szLinestr[256], iLen     while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {         if(szLinestr[0] == ';' || iLen <= 1 || equal(Arg1, szLinestr)) {         write_file(szConfigfile, "", iLine)         }     }     return PLUGIN_HANDLED } public client_authorized(id) {     if(get_cvar_num("nc_enable") == 0)         return PLUGIN_HANDLED             new szConfigsdir[200]     get_configsdir(szConfigsdir, 199)         new szConfigfile[200]     add(szConfigsdir, 199, "/name_checker.ini")     if(!file_exists(szConfigsdir)) {         write_file(szConfigfile, "; Name Checker -- By: Fire")         write_file(szConfigfile, "; -- Do Not Edit This --")     }         format(szConfigfile, 199, "%s/name_checker.ini", szConfigsdir)         new szSteamid[35]     get_user_authid(id, szSteamid, 34)         new iLine, szLinestr[256], iLen         new szName[35], szStoredSteamid[35]         while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {         if(szLinestr[0] == ';' || !iLen) continue         parse(szLinestr, szStoredSteamid, 34, szName, 34)         if(equal(szSteamid, szStoredSteamid)) {             client_cmd(id,"name %s", szName)         }     }     return PLUGIN_HANDLED }
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 03-05-2006 , 19:52  
Reply With Quote #4

I saw it in some of suicid3's scripts and questioned it... he told me why he wrote like that and im picking it up, i guess btw thanks
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 03-05-2006 , 20:27  
Reply With Quote #5

hmmm.... still not working right, it dose not creat the file
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-05-2006 , 20:36  
Reply With Quote #6

Quote:
Originally Posted by onfirenburnin420
hmmm.... still not working right, it dose not creat the file
You need to do an "if(!file_exists(<file>)) { write_file(...)" to create it.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 03-05-2006 , 21:06  
Reply With Quote #7

i have that:
Code:
    if(!file_exists(szConfigfile)) {         write_file(szConfigfile, "; Name Checker -- By: Fire")         write_file(szConfigfile, "; -- Do Not Edit This --")     }
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 03-05-2006 , 21:33  
Reply With Quote #8

this right here is horrible.
Code:
    while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {         if(szLinestr[0] == ';' || iLen <= 1 || equal(Arg1, szLinestr)) {         console_print(id,"%s's name is all ready being checked!", Arg2)             } else {                     new szWrite[62]         format(szWrite,61,"^"%s^" ^"%s^"",Arg1,Arg2)         write_file(szConfigfile,szWrite, -1)             }         }

make a "new szWrite" every iteration of the loop. and makes no sense. (On every line read, if it is a comment of if the line is empty or it is the person say name is already being check. Else make a new line.) So every line it reads that is not the player add the player?

Hawk im disappointed in you for not catching that. P.S: Since when are you the only one who codes like that? (Never)
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 03-05-2006 , 21:43  
Reply With Quote #9

so if i just do this it sould work?
Code:
    new iLine, szLinestr[256], iLen     while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen)) {         if(szLinestr[0] == ';' || iLen <= 1 || !equal(Arg1, szLinestr)) {             new szWrite[62]         format(szWrite,61,"^"%s^" ^"%s^"",Arg1,Arg2)         write_file(szConfigfile,szWrite, -1)                 console_print(id,"%s was added to the check list.", Arg2)                   }         }
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 03-05-2006 , 22:04  
Reply With Quote #10

Code:
    new iLine, szLinestr[256], iLen     new bool:boolWrite = true     while(read_file(szConfigfile, iLine++, szLinestr, 255, iLen))     {         if(szLinestr[0] == ';' || !iLen) continue;         if(equal(Arg1, szLinestr))         {             boolWrite = false             break;              }     }     if(boolWrite)     {         new szWrite[62]         format(szWrite,61,"^"%s^" ^"%s^"",Arg1,Arg2)         write_file(szConfigfile,szWrite, -1)         console_print(id,"%s was added to the check list.", Arg2)     }     else         console_print(id,"%s was already in file. o_O" , Arg2)     return PLUGIN_HANDLED
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
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 06:18.


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