AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   say number motd number (https://forums.alliedmods.net/showthread.php?t=324348)

bigdaddy424 02-28-2023 13:21

Re: say number motd number
 
Use fysiks' model

rx1983 03-13-2023 09:21

Re: say number motd number
 
Quote:

Originally Posted by bigdaddy424 (Post 2800369)
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 03-13-2023 09:23

Re: say number motd number
 
Quote:

Originally Posted by fysiks (Post 2800411)
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

bigdaddy424 03-13-2023 20:13

Re: say number motd number
 
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




All times are GMT -4. The time now is 12:24.

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