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

set_task print color chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FLAiTE
Member
Join Date: Aug 2008
Old 12-24-2014 , 10:15   set_task print color chat
Reply With Quote #1

Hi. I'm new to AMXX coding, and i'd have a simple question:

I'm using AMXX Beta v1.8.3+, and i'd like to create my own plugin that prints chat messages.
so far, i did this:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Simple Messages"
#define VERSION "1.0"
#define AUTHOR "FLAiTE"

public plugin_init() 
{
    
set_task(10.0,  "m1"___"b"0);
    
set_task(30.0,  "m2"___"b"0);
    
set_task(50.0,  "m3"___"b"0);
    
set_task(70.0,  "m4"___"b"0);
    
set_task(90.0,  "m5"___"b"0);
}

public 
m1(id)
{
    
client_print_color(0print_team_red"^1* ^3RED_message");
}

public 
m2(id)
{
    
client_print_color(0print_team_blue"^1* ^3BLUE_message");
}

public 
m3(id)
{
    
client_print_color(0print_team_grey"^1* ^3GREY_message");
}

public 
m4(id)
{
    
client_print_color(0print_team_default"^1* ^4green_message");
}

public 
m5(id)
{
    
client_print_color(0print_team_default"^1* yellow_message");

even if it compiles without errors, the plugin does not display the messages the way i want.
for example, the first time it prints:
* RED_message
the second time it prins:
* RED_message
* BLUE_message
third time:
* RED_message
etc.

I mean...it's working but not the way i want it to.
My purpose is to print multiple messages, at different time intervals. To be more specific:
* message 1
(60 seconds later)
* message 2
(30 seconds later)
* message 3
(45 seconds later)
* message 4
etc.

also, after all messages are finished, i want it to restart with * message 1.
It is imperative that the messages have different colors, else i could just modify this plugin, and print them all (for CT/T/SPEC the SAME color) RED, GREY or BLUE, depending on my choice.

so, can anyone help me?
thanks!
FLAiTE is offline
popeye10
Senior Member
Join Date: May 2014
Location: Navi Mumbai (India)
Old 12-24-2014 , 11:05   Re: set_task print color chat
Reply With Quote #2

like this ?
PHP Code:
#include <amxmodx>
#include <colorchat>

#define PLUGIN "Simple Messages"
#define VERSION "1.0"
#define AUTHOR "FLAiTE"

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
set_task(10.0,  "m1"___"b"0);
    
set_task(30.0,  "m2"___"b"0);
    
set_task(50.0,  "m3"___"b"0);
    
set_task(70.0,  "m4"___"b"0);
    
set_task(90.0,  "m5"___"b"0);
}

public 
m1(id)
{
    
client_print_color(0RED"* RED_message");
}

public 
m2(id)
{
    
client_print_color(0BLUE"* BLUE_message");
}

public 
m3(id)
{
    
client_print_color(0GREY"* GREY_message");
}

public 
m4(id)
{
    
client_print_color(0GREEN"* Green_message");
}

public 
m5(id)
{
    
client_print_color(0NORMAL"* Yellow_message");

__________________

Last edited by popeye10; 12-24-2014 at 11:11.
popeye10 is offline
FLAiTE
Member
Join Date: Aug 2008
Old 12-24-2014 , 11:41   Re: set_task print color chat
Reply With Quote #3

obviously not, since i said the code is not working as it should, even though it compiles without errors/warnings.
in amxx v1.8.3+, the colorchat function is integrated, and the syntax to use it is as i wrote in post #1 (print_team_red, print_team_blue etc).

the plugin is not working as i would like it to (the defects are mentioned also in post #1).

Last edited by FLAiTE; 12-24-2014 at 11:42.
FLAiTE is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-24-2014 , 12:05   Re: set_task print color chat
Reply With Quote #4

Maybe, something like this?
PHP Code:
#include <amxmodx>

public plugin_init() 
{
    
// For first message
    
set_task(10.0"m1")
}

public 
m1()
{
    
client_print_color(0print_team_red"^1* ^3RED_message");
    
    
// For message 2
    
set_task(10.0"m2")
}

public 
m2()
{
    
client_print_color(0print_team_blue"^1* ^3BLUE_message");
    
    
// For message 3
    
set_task(10.0"m3")
}

public 
m3()
{
    
client_print_color(0print_team_grey"^1* ^3GREY_message");
    
    
// For message 4
    
set_task(10.0"m4")
}

public 
m4()
{
    
client_print_color(0print_team_default"^1* ^4green_message");
    
    
// For message 5
    
set_task(10.0"m5")
}

public 
m5()
{
    
client_print_color(0print_team_default"^1* yellow_message");
    
    
// Start again with first message
    
set_task(10.0"m1")


Last edited by zmd94; 12-24-2014 at 20:51.
zmd94 is offline
FLAiTE
Member
Join Date: Aug 2008
Old 12-24-2014 , 12:27   Re: set_task print color chat
Reply With Quote #5

gonna try it tonight.
if it works, i'll let you know.
also, does it loop these functions (restart with m1, then m2, then m3 etc)?

Last edited by FLAiTE; 12-24-2014 at 12:27.
FLAiTE is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-24-2014 , 12:42   Re: set_task print color chat
Reply With Quote #6

Yes. It will start again with first message.
zmd94 is offline
FLAiTE
Member
Join Date: Aug 2008
Old 12-24-2014 , 17:34   Re: set_task print color chat
Reply With Quote #7

finally, this is the version that does exactly what i want:
PHP Code:
#include <amxmodx>

#define PLUGIN "Simple Messages"
#define VERSION "1.0"
#define AUTHOR "FLAiTE"

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
// pentru primul mesaj
    
set_task(10.0,  "m1"___"a"1)
}

public 
m1(id)
{
    
client_print_color(0print_team_red"^1* ^3RED_message"
    
// pentru mesajul al 2-lea
    
set_task(10.0,  "m2"___"a"1)
}

public 
m2(id)
{
    
client_print_color(0print_team_blue"^1* ^3BLUE_message")
    
// pentru mesajul al 3-lea
    
set_task(10.0,  "m3"___"a"1)
}

public 
m3(id)
{
    
client_print_color(0print_team_grey"^1* ^3GREY_message")
    
// pentru mesajul al 4-lea
    
set_task(10.0,  "m4"___"a"1)
}

public 
m4(id)
{
    
client_print_color(0print_team_default"^1* ^4green_message")
    
// pentru mesajul al 5-lea
    
set_task(10.0,  "m5"___"a"1)
}

public 
m5(id)
{
    
client_print_color(0print_team_default"^1* yellow_message")
    
// incepe iar cu primul mesaj...
    
set_task(10.0,  "m1"___"a"1)

this topic can be closed. what was asked in the beginning was realised.
FLAiTE is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-24-2014 , 20:49   Re: set_task print color chat
Reply With Quote #8

set_task(10.0, "m1", _, _, _, "a", 1) is not needed as you only repeat the message once. So just use set_task(10.0, "m1").

This is the same will all of your set_task. So, please change it.

Just do as I have shown to you from above code.

Last edited by zmd94; 12-24-2014 at 20:52.
zmd94 is offline
FLAiTE
Member
Join Date: Aug 2008
Old 12-24-2014 , 23:38   Re: set_task print color chat
Reply With Quote #9

Quote:
Originally Posted by zmd94 View Post
set_task(10.0, "m1", _, _, _, "a", 1) is not needed as you only repeat the message once. So just use set_task(10.0, "m1").

This is the same will all of your set_task. So, please change it.

Just do as I have shown to you from above code.
it does repeat multiple times the messages. (m1 function is called again at the end, as you coded)
the last argument, after "a", ("1" to be more explicit) means to repeat (if it's set to 0, it means to not repeat the message, in this case, if you want the message to be repeated, "a" should be replaced by "b" (loop mode) - source).
so, it works and it does repeat...basically it does everything i wanted in the beginning.

don't believe me? try it yourself i already did, and it works flawless.

Last edited by FLAiTE; 12-24-2014 at 23:42.
FLAiTE is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-24-2014 , 23:49   Re: set_task print color chat
Reply With Quote #10

If I'm not mistaken set_task(10.0, "m1", _, _, _, "a", 1) is the same with set_task(10.0, "m1").

Last edited by zmd94; 12-24-2014 at 23:52.
zmd94 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 19:59.


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