AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Announce (https://forums.alliedmods.net/showthread.php?t=206131)

RuRuRu612754 01-18-2013 21:02

Announce
 
hello.

type console in "anno abc123" to print chat "[] 123"
i want type console in "anno abc123" to print chat "[] abc123"
where is the problem?
help me.

thanks.

source code here:
PHP Code:

#include <amxmodx>
#include <fun>

public plugin_init()
{
    
register_clcmd("/anno""cmdAnno")
    
register_clcmd(".anno""cmdAnno")
}

public 
cmdAnno(id)
{
    new 
MessageText[4], PrintText
    read_argv
(1MessageTextcharsmax(MessageText))
    
PrintText str_to_num(MessageText)
    
client_print(idprint_chat"[prifix] %s"PrintText)

    return 
PLUGIN_HANDLED



aaarnas 01-18-2013 21:15

Re: Announce
 
str_to_num is for converting string with number to integer.
Code:

#include <amxmodx>

public plugin_init()
{
        register_clcmd("/anno", "cmdAnno")
        register_clcmd(".anno", "cmdAnno")
}

public cmdAnno(id)
{
        new MessageText[100], Left[1], Right[50]
        read_argv(1, MessageText, charsmax(MessageText))
        strtok(MessageText, Left, charsmax(Left), Right, charsmax(Right), ' ')
        client_print(id, print_chat, "[prifix] %s", Right)

        return PLUGIN_HANDLED
}


fysiks 01-19-2013 00:22

Re: Announce
 
Quote:

Originally Posted by aaarnas (Post 1875920)
str_to_num is for converting string with number to integer.
Code:

#include <amxmodx>

public plugin_init()
{
        register_clcmd("/anno", "cmdAnno")
        register_clcmd(".anno", "cmdAnno")
}

public cmdAnno(id)
{
        new MessageText[100], Left[1], Right[50]
        read_argv(1, MessageText, charsmax(MessageText))
        strtok(MessageText, Left, charsmax(Left), Right, charsmax(Right), ' ')
        client_print(id, print_chat, "[prifix] %s", Right)

        return PLUGIN_HANDLED
}


This code is not correct either. There are no spaces in "abc123" and if there were, your code would give undesirable results. You simply need to print the variable MessageText, that's it.

RuRuRu612754 01-25-2013 07:07

Re: Announce
 
Quote:

Originally Posted by aaarnas (Post 1875920)
str_to_num is for converting string with number to integer.
Code:

#include <amxmodx>

public plugin_init()
{
        register_clcmd("/anno", "cmdAnno")
        register_clcmd(".anno", "cmdAnno")
}

public cmdAnno(id)
{
        new MessageText[100], Left[1], Right[50]
        read_argv(1, MessageText, charsmax(MessageText))
        strtok(MessageText, Left, charsmax(Left), Right, charsmax(Right), ' ')
        client_print(id, print_chat, "[prifix] %s", Right)

        return PLUGIN_HANDLED
}


thanks you.
i will try it.

EpicMonkey 01-25-2013 07:36

Re: Announce
 
Quote:

Originally Posted by RuRuRu612754 (Post 1880167)
thanks you.
i will try it.

Quote:

Originally Posted by fysiks (Post 1876040)
This code is not correct either. There are no spaces in "abc123" and if there were, your code would give undesirable results. You simply need to print the variable MessageText, that's it.



All times are GMT -4. The time now is 13:39.

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