Raised This Month: $51 Target: $400
 12% 

say number motd number


Post New Thread Reply   
 
Thread Tools Display Modes
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 02-28-2023 , 13:21   Re: say number motd number
Reply With Quote #11

Use fysiks' model
__________________
bigdaddy424 is offline
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 03-13-2023 , 09:21   Re: say number motd number
Reply With Quote #12

Quote:
Originally Posted by bigdaddy424 View Post
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 }
.sma(14 -- 16) : error 017: undefined symbol "fmt"
__________________
rx1983 is offline
Send a message via MSN to rx1983
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 03-13-2023 , 09:23   Re: say number motd number
Reply With Quote #13

Quote:
Originally Posted by fysiks View Post
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
    
}

.sma(20) : error 017: undefined symbol "fmt"
.sma(24) : warning 209: function "hook_say" should return a value
__________________
rx1983 is offline
Send a message via MSN to rx1983
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 03-13-2023 , 20:13   Re: say number motd number
Reply With Quote #14

fmt was introduced in amxx 1.9
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
    
}

    return 
PLUGIN_CONTINUE

__________________
bigdaddy424 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 23:36.


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