Raised This Month: $ Target: $400
 0% 

announcement plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RuRuRu612754
Senior Member
Join Date: Sep 2011
Old 06-15-2012 , 03:41   announcement plugin
Reply With Quote #1

hello

I created a plugin for my server announcement.
However, does not work.

How can I resolve this problem I do?

amxx.cfg
PHP Code:
announcement "1"

announcement_1 "1"
announcement_2 "0"
announcement_3 "0"
announcement_4 "0"
announcement_5 "0"

announcement_detail_1 "Welcome to this server"
announcement_detail_2 ""
announcement_detail_3 ""
announcement_detail_4 ""
announcement_detail_5 "" 
announcement.sma
PHP Code:
#include <amxmodx>

new announcement

new announcement_1
new announcement_2
new announcement_3
new announcement_4
new announcement_5

new announcement_detail_1
new announcement_detail_2
new announcement_detail_3
new announcement_detail_4
new announcement_detail_5

public plugin_init()
{
    
register_plugin("PLUGIN""PLUGIN""AUTHOR")

    
announcement register_cvar("announcement""1")

    
announcement_1 register_cvar("announce_1""0")
    
announcement_2 register_cvar("announce_2""0")
    
announcement_3 register_cvar("announce_3""0")
    
announcement_4 register_cvar("announce_4""0")
    
announcement_5 register_cvar("announce_5""0")

    
announcement_detail_1 register_cvar("announcement_detail_1""")
    
announcement_detail_2 register_cvar("announcement_detail_2""")
    
announcement_detail_3 register_cvar("announcement_detail_3""")
    
announcement_detail_4 register_cvar("announcement_detail_4""")
    
announcement_detail_5 register_cvar("announcement_detail_5""")

    
set_task(180.0"CmdAnnounce"0""0"b")
}

public 
CmdAnnounce(id)
{
    if(
get_pcvar_num(announcement))
    {
        if(
get_pcvar_num(announcement_1))
        {
            
client_print(0print_chat"%s"get_pcvar_num(announcement_detail_1))
        }
        if(
get_pcvar_num(announcement_2))
        {
            
client_print(0print_chat"%s"get_pcvar_num(announcement_detail_2))
        }
        if(
get_pcvar_num(announcement_3))
        {
            
client_print(0print_chat"%s"get_pcvar_num(announcement_detail_3))
        }
        if(
get_pcvar_num(announcement_4))
        {
            
client_print(0print_chat"%s"get_pcvar_num(announcement_detail_4))
        }
        if(
get_pcvar_num(announcement_5))
        {
            
client_print(0print_chat"%s"get_pcvar_num(announcement_detail_5))
        }
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED

RuRuRu612754 is offline
iBrazilian
Senior Member
Join Date: May 2011
Old 06-15-2012 , 03:46   Re: announcement plugin
Reply With Quote #2

Damn, that's horrible. Either way, try using enum, look in the tutorial sections..

enum
{
ANC_1,
ANC_2,
ANC_3
};
__________________
Pokemod Season 5 [ |||||||||| Complete]
iBrazilian is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 06-15-2012 , 06:25   Re: announcement plugin
Reply With Quote #3

client_print(0, print_chat, "%s", get_pcvar_num(announcement_detail_1))

you should use get_pcvar_string not num

Example:

PHP Code:
new szMessage1[128];
get_pcvar_string(announcement_detail_1szMessage1127)
// Then
client_print(0print_chat"%s"szMessage1

Last edited by DjOptimuS; 06-15-2012 at 06:27.
DjOptimuS is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-15-2012 , 09:46   Re: announcement plugin
Reply With Quote #4

Hard-coded to 5 announcements, better code than before.
Spoiler


More efficient to allow 0 to infinite announcements.
Spoiler


The 2nd code removes the announce_# cvar.
Also, the # in announcement_detail has been removed.

So it looks like this:

Code:
announce 1

annoucement_detail "Line #1"
//announcement_detail "Hello"
announcement_detail "Line #2"
Notice the 2nd announcement has // before it, so it will not be added to the plugin.
That is how you can disable your announcements.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
RuRuRu612754
Senior Member
Join Date: Sep 2011
Old 06-19-2012 , 04:49   Re: announcement plugin
Reply With Quote #5

@DjOptimuS
thanks!!

@Exolent[jNr]
thanks!!
i used this XD
RuRuRu612754 is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 06-19-2012 , 07:24   Re: announcement plugin
Reply With Quote #6

I made something similiar while ago, some kind of reminder.
It may help you:
Spoiler


Exolent can you explain ArrayGetStringHandle, haven't seen it before, on amxmodx wiki says DoNotUse ..
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-19-2012 , 09:04   Re: announcement plugin
Reply With Quote #7

Code:
formatex(string, charsmax(string), "String: %a", ArrayGetStringHandle(array, index)) // is the same as ArrayGetString(array, index, arrayString, charsmax(arrayString)) formatex(string, charsmax(string), "String: %s", arrayString)

The difference is that the first doesn't require it to be stored in a variable, which also allows you to save some memory.
It may say do not use, but is perfectly safe if not used incorrectly. It is even used in one of the base AMXX plugins (maybe map chooser or something).
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 06:11.


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