Raised This Month: $ Target: $400
 0% 

Help with in-game admin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joecaprini
Junior Member
Join Date: Jul 2004
Location: In a blackhole
Old 03-07-2005 , 21:28   Help with in-game admin
Reply With Quote #1

Does anyone know what is wrong with this code?

Code:
/* Admin Access by JoeCaprini Add access by amx_addadmin <steamid> <levels> To do: + Add remove function */ #include <amxmodx> new gFileLocation = "addons/amxmodx/configs/users.ini" new gTextName public plugin_init() {     register_plugin("Admin Access","1.1","JoeCaprini")     register_clcmd("amx_addadmin","addadmin",ADMIN_BAN,"- Adds an admin") } public addadmin(id) {     new adminid[32]     new accesslvls[32]     if(read_argc() == 0)     {         client_print(id,print_console,"Usage: amx_addadmin <steamid> <access levels>")         return PLUGIN_HANDLED     }     if(read_argc() < 2)     {         client_print(id,print_console,"[AMX] Must have an ID and the ACCESS LEVELS!")         return PLUGIN_HANDLED     }     read_argv(1,adminid,31)     read_argv(2,accesslvls,31)     if(containi(gFileLocation,adminid)     {         client_print(id,print_console,"[AMX] User is already an admin")         return PLUGIN_HANDLED     }     format(gTextName,"^"%s^" ^"^" ^"%s^"",adminid,accesslvls)     write_file(gFileLocation,gTextName,-1)     return PLUGIN_CONTINUE } public removeadmin(id) {     new adminremove[32]     new getline     new adminlook[32]     read_argv(1,adminremove,31)     if(read_argc() == 0)     {         client_print(id,print_console,"[AMX] Must specify a user")         return PLUGIN_HANDLED     }     format(gTextName,";")     read_file(gFileLocation,getline,adminlook,31)     if(adminlook == adminremove)     {         write_file(gFileLocation,gTextName,getline)         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE }

I know there is already a plugin like this but I'm trying to learn how to do it.
__________________
-JOECAPRINI-
joecaprini is offline
Send a message via AIM to joecaprini
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 03-08-2005 , 13:12  
Reply With Quote #2

Your using clcmd... Now everyone on your server can add and remove admins
XunTric is offline
joecaprini
Junior Member
Join Date: Jul 2004
Location: In a blackhole
Old 03-08-2005 , 15:11  
Reply With Quote #3

Code:
register_clcmd("amx_addadmin","addadmin",ADMIN_BAN,"- Adds an admin")

Only people with ban access can
__________________
-JOECAPRINI-
joecaprini is offline
Send a message via AIM to joecaprini
XunTric
BANNED
Join Date: Jan 2005
Location: Norway/Norge
Old 03-08-2005 , 15:14  
Reply With Quote #4

Ops sorry... my eyes...

And show us the errors when you compile, or explain whats wrong with it...?

EDIT:
You forgot } at the end of the plugin...
XunTric is offline
joecaprini
Junior Member
Join Date: Jul 2004
Location: In a blackhole
Old 03-08-2005 , 15:56  
Reply With Quote #5

Code:
//// addadmin.sma
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(38) : error 035: argument type mismatch (argument 1)
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(43) : error 035: argument type mismatch (argument 1)
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(44) : error 035: argument type mismatch (argument 1)
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(59) : error 035: argument type mismatch (argument 1)
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(60) : error 035: argument type mismatch (argument 1)
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(61) : error 033: array must be indexed (variable "adminlo
ok")
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(63) : error 035: argument type mismatch (argument 1)
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(67) : warning 203: symbol is never used: "getline"
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(67) : warning 203: symbol is never used: "gFileLocation"
// C:\Valve\Steam\SteamApps\juggernaut817\dedicated server\czero\addons\amxmodx\
scripting\addadmin.sma(67) : warning 203: symbol is never used: "gTextName"
//
// 7 Errors.
// Could not locate output file compiled\addadmin.amx (compile failed).
//
// Compilation Time: 0.3 sec
// ----------------------------------------

Press enter to exit ...
Yea I have the } at the end I just accidentally fogot it in the post.
__________________
-JOECAPRINI-
joecaprini is offline
Send a message via AIM to joecaprini
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 03-08-2005 , 16:50  
Reply With Quote #6

Yes Actually, anyone could run that command, because you forgot to restrict it with:
Code:
if( !cmd_access( id, lvl, cid, 2 ) )     return PLUGIN_HANDLED

And you forgot to register a client command to remove admins (you have the function for it)..

And the following just wont work, you need to read the file contents line by line, and compare each line.. not the file name..
Code:
if(containi(gFileLocation,adminid)

You have alot of errors, both syntax and logic, and you need to think it through alot more... mainly your file access commands and logic.. look at some examples from other plugins which do this...

I could fix you plugin for you, but that basically means rewriting the entire thing myself, and that would spoil the fun for you.. Keep trying tho, and study!!


Edit: here, I removed the syntax errors, but the logic is still wrong, and I can GUARANTEE this wont work still even tho it compiles fine.. it is logically incorrect...
Code:
#include <amxmodx> #include <amxmisc> new gFileLocation[] = "addons/amxmodx/configs/users.ini" new gTextName[32] public plugin_init() {     register_plugin("Admin Access","1.1","JoeCaprini")     register_clcmd("amx_addadmin","addadmin",ADMIN_BAN," <steamid> <access levels>") } public addadmin(id,lvl,cid) {     if( !cmd_access( id, lvl, cid, 2 ) )         return PLUGIN_HANDLED     new adminid[32]     new accesslvls[32]     read_argv(1,adminid,31)     read_argv(2,accesslvls,31)     if( containi(gFileLocation,adminid) > -1 )     {         client_print(id,print_console,"[AMX] User is already an admin")         return PLUGIN_HANDLED     }     format(gTextName,31,"^"%s^" ^"^" ^"%s^"",adminid,accesslvls)     write_file(gFileLocation,gTextName,-1)     return PLUGIN_CONTINUE } public removeadmin(id) {     new adminremove[32]     new len, getline = 0     new adminlook[32]     read_argv(1,adminremove,31)     if(read_argc() == 0)     {         client_print(id,print_console,"[AMX] Must specify a user")         return PLUGIN_HANDLED     }     format(gTextName,31,";")     read_file(gFileLocation,getline,adminlook,31,len)     if(equali(adminlook,adminremove))     {         write_file(gFileLocation,gTextName,getline)         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE }
xeroblood is offline
Send a message via MSN to xeroblood
MrSlatu
New Member
Join Date: Nov 2005
Location: Houston, Texas
Old 11-20-2005 , 13:00   if you ever finish
Reply With Quote #7

If you ever get that removeadmin code to work post it!!! I know lots of people who would love you for that code including myself, since it is a pain for me to edit my users.ini with the way I have my server set up.
MrSlatu is offline
Send a message via AIM to MrSlatu Send a message via MSN to MrSlatu
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 14:12.


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