Raised This Month: $32 Target: $400
 8% 

say number motd number


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 05-13-2020 , 19:33   say number motd number
Reply With Quote #1

how I do to send a random number.

to a page with motd?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <chatcolor>

public plugin_init() {

    
register_plugin("say top","1","mestre")
    
register_clcmd("say topY",  "topY",  0"zzz"); // Y = NUMBER
}

public 
top_Y(id,level,cid) {
    new 
szNome32 ];
    
get_user_nameidszNome31 )
    if (!
cmd_access(id,level,cid,1))
    return 
PLUGIN_CONTINUE
    show_motd
(id,"http://www.xxxx.com.xx/xxxx/xxx.php?top=Y""TOP Y ( Y = NUMBER ) ")
    
client_print_color0print_chat"^3%s ^4topY ^1 rank xxx"szNome);
    return 
PLUGIN_CONTINUE   


Name:  we.jpg
Views: 486
Size:  73.2 KB



__________________
rx1983 is offline
Send a message via MSN to rx1983
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-13-2020 , 21:57   Re: say number motd number
Reply With Quote #2

Read the argument string (read_args()) and then get the number from the string and use it for your URL.

Also, if you have a predefined number of commands that work, you need to register all of them to call that same function. If the number is fully arbitrary, then you need to hook "say" and then process the the arg string to first check that it matches your command (i.e. "top") and then call your MOTD if it does.

Also, you mean arbitrary number, not random number.
__________________

Last edited by fysiks; 05-13-2020 at 22:00.
fysiks is offline
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 02-21-2023 , 19:08   Re: say number motd number
Reply With Quote #3

bump, can someone do this
__________________
rx1983 is offline
Send a message via MSN to rx1983
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-22-2023 , 01:38   Re: say number motd number
Reply With Quote #4

Here ya go. Add as many register_clcmd() functions as needed with a different number and update with your URL.

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define MIN_VALUE 1
#define MAX_VALUE 2000

public plugin_init()
{
    
register_plugin("say top""1.0.0""mestre/fy")

    new 
szSayCmd[20]
    for( new 
MIN_VALUE<= MAX_VALUEi++ )
    {
        
formatex(szSayCmdcharsmax(szSayCmd), "say top%d"i);
        
register_clcmd(szSayCmd"showTopMOTD");
    }
}

public 
showTopMOTD(id)
{
    new 
szCmd[10], iValueszUrl[128];
    
read_argv(1szCmdcharsmax(szCmd));
    
iValue str_to_num(szCmd[3]);

    
formatex(szUrlcharsmax(szUrl), "http://www.xxxx.com.xx/xxxx/xxx.php?top=%d"iValue);
    
show_motd(idszUrl);

    new 
szName[32];
    
get_user_nameidszNamecharsmax(szName))
    
client_print(0print_chat"^3%s ^4topY ^1 rank xxx"szName);
    
    return 
PLUGIN_CONTINUE;

__________________

Last edited by fysiks; 02-24-2023 at 00:10.
fysiks is offline
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 02-22-2023 , 06:28   Re: say number motd number
Reply With Quote #5

I need this to be done with a loop, the rank can go from 1 to 2000...

it will be very difficult to declare 2000 register_clcmd ...
__________________
rx1983 is offline
Send a message via MSN to rx1983
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-24-2023 , 00:10   Re: say number motd number
Reply With Quote #6

Would have been nice to know. Updated above. I'm not sure if there is any limitations to registering commands like this, if it causes issues, we can switch how it's done to not require all the registered commands.
__________________

Last edited by fysiks; 02-24-2023 at 00:11.
fysiks is offline
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 02-27-2023 , 09:15   Re: say number motd number
Reply With Quote #7



https://www.youtube.com/embed/4h-kEsfcVNk

would you be able to do the same thing without registering so many commands?
__________________
rx1983 is offline
Send a message via MSN to rx1983
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 02-27-2023 , 11:46   Re: say number motd number
Reply With Quote #8


Code:
#include <amxmodx> new command[] = "top" public plugin_init()     register_srvcmd("get", "hook_say") public hook_say(){     new text[32]     read_argv(1, text, charsmax(text))     server_print("said %s, number %d", text, str_to_num(fmt("%s", text[strlen(command)]))) }
__________________
bigdaddy424 is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 02-27-2023 , 12:26   Re: say number motd number
Reply With Quote #9

in this case
Code:
#include <amxmodx> #define WEB_URL "https://google.com/search?q=" public plugin_init()     register_clcmd("say", "hook_say") public hook_say(id){     new text[8], command[8]     read_argv(1, text, charsmax(text))     formatex(command, charsmax(command), "%.3s", text)     if (equal(command, "top"))         show_motd(             id,             fmt("%s%d", WEB_URL, str_to_num(fmt("%s", text[3]))),             fmt("Top %d | %s", str_to_num(fmt("%s", text[3])), __DATE__)         )     return PLUGIN_HANDLED }
__________________
bigdaddy424 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-28-2023 , 01:08   Re: say number motd number
Reply With Quote #10

You are doing way more formatting than you need to do, no formatting related to "text" is required. Should also validate the number before showing the MOTD. Also, returning PLUGIN_HANDLED unconditionally in a "say" hook will prevent all normal chat messages from showing.

PHP Code:
#include <amxmodx>

#define WEB_URL "https://google.com/search?q="

public plugin_init()
{
    
register_clcmd("say""hook_say")
}

public 
hook_say(id)
{
    new 
text[8]
    
read_argv(1textcharsmax(text))

    if( 
equal(text"top"3) )
    {
        new 
iValue str_to_num(text[3])
        if( 
iValue )
        {
            
show_motd(idfmt("%s%d"WEB_URLiValue), fmt("Top %d | %s"iValue__DATE__))
        }
        return 
PLUGIN_HANDLED
    
}

__________________
fysiks 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 07:45.


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