Raised This Month: $ Target: $400
 0% 

Simple plugin not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 05-29-2007 , 01:25   Simple plugin not working
Reply With Quote #1

This isn't working - I just wrote it today with some referencing to other plugins/documentation so I bet there are a few mistakes I overlooked but I usually don't detect them until I stop looking at them for weeks :-). But, you can probably find them b/c you haven't looked at them before :-).

Slmclarengt

P.S. Function is to "list all available maps on the server --> client"
Attached Files
File Type: sma Get Plugin or Get Source (listmaps.sma - 598 views - 1.8 KB)
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-29-2007 , 07:55   Re: Simple plugin not working
Reply With Quote #2

You shouldn't make it this way. It's not a good idea to give rcon password to players, but anyway this is how to fix this plugin:

PHP Code:
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say""check_say")    //check say this way
    
register_clcmd("say_team""check_say")   //check say_team this way
    
register_clcmd("amx_maps""cmdListMaps", -1"Lists ALL available maps - * or blank for all otherwise <prefix> (eg: surf)")
}


public 
check_say(id)
{
    new 
said[32]
    new 
arg1[32]
    new 
arg2[32]

    
read_args(said31)
    
remove_quotes(said)
    
strbreak(saidarg131arg231)    //split string
    //check if first arg. equals desired command
    
if (equali(arg1"/maps") || equali(arg1"maps"))  
        
executeListMaps(idarg2)    //send prefix or empty string as an arg.
}

public 
cmdListMaps(id)
{
    new 
arg1[17]
    
read_argv(1arg116)
    
executeListMaps(idarg1)
}

public 
executeListMaps(idparam[])
{
    new 
maps_cmd[33]
    new 
prefix_to_send[16]
    
    new 
arg1[17]
    
copy(arg116param)

    new 
password[64]
    
get_cvar_string("rcon_password"password63)
    if (!
arg1[0])
    {
        
format(prefix_to_send1"*")
        
format(maps_cmd32"maps %s"prefix_to_send)
        
client_cmd(id"rcon_password %s"password)
        
client_cmd(id"rcon %s"maps_cmd)
    }
    else
    {
        
remove_quotes(arg1)
        
copy(prefix_to_send16arg1)
        
format(maps_cmd32"maps %s"prefix_to_send)
        
client_cmd(id"rcon_password %s"password)
        
client_cmd(id"rcon %s"maps_cmd)
    }
    return 
PLUGIN_HANDLED

__________________
Impossible is Nothing
Sylwester is offline
anssik
Senior Member
Join Date: May 2006
Location: Suomi Finland Perkele
Old 05-29-2007 , 08:20   Re: Simple plugin not working
Reply With Quote #3

This is actually a really good idea! I made some extra protection in it which should make it much more secure.
Code:
new g_oldpass[64] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say", "check_say")    //check say this way     register_clcmd("say_team", "check_say")   //check say_team this way     register_clcmd("amx_maps", "cmdListMaps", -1, "Lists ALL available maps - * or blank for all otherwise <prefix> (eg: surf)")     get_cvar_string("rcon_password", g_oldpass, 63) } public check_say(id) {     new said[32]     new arg1[32]     new arg2[32]     read_args(said, 31)     remove_quotes(said)     strbreak(said, arg1, 31, arg2, 31)    //split string     //check if first arg. equals desired command     if (equali(arg1, "/maps") || equali(arg1, "maps"))           executeListMaps(id, arg2)    //send prefix or empty string as an arg. } public cmdListMaps(id) {     new arg1[17]     read_argv(1, arg1, 16)     executeListMaps(id, arg1) } public executeListMaps(id, param[]) {     new maps_cmd[33]     new prefix_to_send[16]         new arg1[17]     copy(arg1, 16, param)     set_cvar_string("rcon_password", "temporary")     if (!arg1[0])     {         format(prefix_to_send, 1, "*")         format(maps_cmd, 32, "maps %s", prefix_to_send)         client_cmd(id, "rcon_password temporary")         client_cmd(id, "rcon %s", maps_cmd)         client_cmd(id, "rcon_password empty")     }     else     {         remove_quotes(arg1)         copy(prefix_to_send, 16, arg1)         format(maps_cmd, 32, "maps %s", prefix_to_send)         client_cmd(id, "rcon_password temporary")         client_cmd(id, "rcon %s", maps_cmd)         client_cmd(id, "rcon_password empty")     }     set_cvar_string("rcon_password", g_oldpass)     return PLUGIN_HANDLED }
__________________
anssik is offline
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 05-29-2007 , 12:49   Re: Simple plugin not working
Reply With Quote #4

I think the problem with check_say is that arg1 returns "say". So you need arg2 to the /map and arg3 for the prefix. Also a better way of getting the maps would be reading the maps directory.

PHP Code:
say /map de_ 
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.

Last edited by Cheap_Suit; 05-29-2007 at 12:58.
Cheap_Suit is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-29-2007 , 14:03   Re: Simple plugin not working
Reply With Quote #5

Wrong, "say" is the command and arg1 will never return "say" until you type it in chat or type "say say" in console
My version works fine, I checked it.

slmclarengt, even if this work fine I recommend you to rewrite it other way.
ex. store list of maps in file on server, load list on plugin_init to some array and code some function to display it for clients, you can use containi ( const source[], const string[] ) to compare arg. and maps in the array.
__________________
Impossible is Nothing
Sylwester is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 05-29-2007 , 14:57   Re: Simple plugin not working
Reply With Quote #6

I would do it like this:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "List Maps" #define VERSION "1.0" #define AUTHOR "stupok69" #define MAP_DIR "maps" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say /maps", "function_list_maps", -1, "lists all maps on server")     register_clcmd("say maps", "function_list_maps", -1, "lists all maps on server")     register_concmd("list_maps", "function_list_maps", -1, "lists all maps on server") } public function_list_maps(id) {     new file[64]         new dirh = open_dir(MAP_DIR, file, 63)         if(dirh)     {         if(containi(file, ".bsp") != -1)         {             console_print(id, file)         }     }     else     {         console_print(id, "Directory (%s) could not be opened.", MAP_DIR)     }         new counter     while(next_file(dirh, file, 63))     {         if(containi(file, ".bsp") != -1)         {             counter++             set_task(0.01 * float(counter), "delay_console_print", id, file, 63)         }     }         close_dir(dirh) } public delay_console_print(params[], id) {     console_print(id, params) }
stupok is offline
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 05-29-2007 , 15:35   Re: Simple plugin not working
Reply With Quote #7

All of your guys ideas were awesome. Thank you very much for the help! +karma to everyone because they all contain things I did not even think of. I got the idea of listing maps because I got so sick of people asking what maps we had and me having to read them off. I'm going to try Stupok's version because the idea I think is the most dynamic and secure - it doesn't give them any password :-) even a temp.

Works beautifully Stupok. I ran down the list of people who helped me and used all my karma up :-\. I'll give you yours tomorrow Stupok :-). It's awesome because unlike the built-in "maps *" command, it doesn't lag the server because it loads them more efficiently. What a surprise eh? AMXX Scripters > VALVe once again.

Score:
AMXX Scripters: Infinite
VALVe: 1

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!

Last edited by slmclarengt; 05-29-2007 at 15:58.
slmclarengt is offline
anssik
Senior Member
Join Date: May 2006
Location: Suomi Finland Perkele
Old 06-01-2007 , 16:42   Re: Simple plugin not working
Reply With Quote #8

Where did the 1 point for VALVe come from? For creating CS?

Yeah the stupoks version is best. Stupok you should release it as separate plugin since it's so useful.

BTW Thanks for the karma.
__________________

Last edited by anssik; 06-01-2007 at 16:44.
anssik is offline
Pro Patria Finland
Senior Member
Join Date: Apr 2006
Location: BaronPub.com
Old 06-01-2007 , 16:44   Re: Simple plugin not working
Reply With Quote #9

Quote:
Originally Posted by anssik View Post
Where did the 1 point for VALVe come from? For creating CS? D

BTW Thanks for the karma.
Valve didn't create CS....
__________________
I am not a number. I am Gordon Freeman!
Pro Patria Finland is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 06-01-2007 , 16:54   Re: Simple plugin not working
Reply With Quote #10

Quote:
Originally Posted by Pro Patria Finland View Post
Valve didn't create CS....
1 point for Pro Patria Finland ;)
__________________
regalis 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 10:37.


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