AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_task print color chat (https://forums.alliedmods.net/showthread.php?t=253564)

FLAiTE 12-24-2014 10:15

set_task print color chat
 
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!

popeye10 12-24-2014 11:05

Re: set_task print color chat
 
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");



FLAiTE 12-24-2014 11:41

Re: set_task print color chat
 
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).

zmd94 12-24-2014 12:05

Re: set_task print color chat
 
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")



FLAiTE 12-24-2014 12:27

Re: set_task print color chat
 
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)?

zmd94 12-24-2014 12:42

Re: set_task print color chat
 
Yes. It will start again with first message.

FLAiTE 12-24-2014 17:34

Re: set_task print color chat
 
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.

zmd94 12-24-2014 20:49

Re: set_task print color chat
 
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.

FLAiTE 12-24-2014 23:38

Re: set_task print color chat
 
Quote:

Originally Posted by zmd94 (Post 2239666)
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 :D i already did, and it works flawless.

zmd94 12-24-2014 23:49

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


All times are GMT -4. The time now is 15:18.

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