Raised This Month: $ Target: $400
 0% 

[SOLVED] Perform role-specific order?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-24-2015 , 17:41   [SOLVED] Perform role-specific order?
Reply With Quote #1

Hi , I created this basic code to display messages to all players, works fine however I was wondering if you have to run them in the order in this case I used random as in the example:

Code:
#include < amxmodx >

new messages[][] =
{
    "[ZP] Test 1",
    "[ZP] Test 2",
    "[ZP] Test 3"
}

public plugin_init()
{
    set_task(2.0, "show_message");
}

public show_message()
{
    new sizeof_messages = random(sizeof messages);
    client_print(0, print_chat, messages[sizeof_messages]);

    set_task(2.0, "show_message");
}
in short , how to show the messages in order from [ZP] Test 1 until [ZP] Test 3?
__________________









Last edited by CrazY.; 09-26-2015 at 17:23.
CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-24-2015 , 17:45   Re: [HELP] Perform role-specific order?
Reply With Quote #2

PHP Code:
for ( new sizeofmessages ) ; i++ )
{


__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-24-2015 , 18:36   Re: [HELP] Perform role-specific order?
Reply With Quote #3

Sorry, I didn't fully read your post. Untested.
PHP Code:
#include < amxmodx >

new iMsgIndex;

new 
messages[][] =
{
    
"[ZP] Test 1",
    
"[ZP] Test 2",
    
"[ZP] Test 3"
}

public 
plugin_init()
{
    
iMsgIndex 0;
    
set_task(2.0"show_message" , .flags="a" , .repeat=sizeofmessages ) );
}

public 
show_message()
{
    
client_print(0print_chatmessagesiMsgIndex++ ] );

__________________

Last edited by Bugsy; 09-24-2015 at 19:08.
Bugsy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-24-2015 , 21:22   Re: [HELP] Perform role-specific order?
Reply With Quote #4

Did not work.
__________________








CrazY. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-24-2015 , 21:30   Re: [HELP] Perform role-specific order?
Reply With Quote #5

It probably worked perfectly fine but nobody will be in the server 2 seconds after the map starts. Try changing 2.0 to something larger so that you know you will be in the server when it prints the message.
__________________
fysiks is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-24-2015 , 21:42   Re: [HELP] Perform role-specific order?
Reply With Quote #6

the message appears but continues randomized, appears when you start the round, then no longer appears.
__________________








CrazY. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-24-2015 , 21:45   Re: [HELP] Perform role-specific order?
Reply With Quote #7

Quote:
Originally Posted by CrazY. View Post
the message appears but continues randomized, appears when you start the round, then no longer appears.
If it's randomized then you are not running Bugsy's code. Also, Bugsy's code has nothing to do with the round starting. It will only show the three messages once after the map starts.

If you've changed the code significantly, you'll need to post your code. Also, what exactly are you trying to do? You're description is either extremely vague or wrong.
__________________

Last edited by fysiks; 09-24-2015 at 21:46.
fysiks is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-24-2015 , 22:25   Re: [HELP] Perform role-specific order?
Reply With Quote #8

This short code I did was to display messages to all players automatically, just that they want to appear in the order, not random. Sorry if not I could not explain.
__________________








CrazY. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-24-2015 , 22:53   Re: [HELP] Perform role-specific order?
Reply With Quote #9

So, the code you posted will show a message every 2 seconds . . that is very quick.

Anyways, to make the messages go in order, you just need to add a global variable and then in the show_message() do:

Code:
global_variable = global_variable % sizeof(messages)
and use global_variable to index your messages array in the client_print() function.
__________________

Last edited by fysiks; 09-24-2015 at 22:58.
fysiks is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-25-2015 , 09:36   Re: [HELP] Perform role-specific order?
Reply With Quote #10

I try this, but this only displaying the last message, if [ZP] Test 3

Code:
#include < amxmodx >

new messages[][] =
{
	"[ZP] Test 1",
	"[ZP] Test 2",
	"[ZP] Test 3"
}

public plugin_init()
{
	set_task(2.0, "show_message");
}

public show_message()
{
	new global_variable = global_variable % sizeof(messages);
	client_print(0, print_chat, messages[global_variable]);

	set_task(2.0, "show_message");
}
__________________









Last edited by CrazY.; 09-25-2015 at 09:36.
CrazY. 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 22:18.


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