AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Perform role-specific order? (https://forums.alliedmods.net/showthread.php?t=272135)

CrazY. 09-24-2015 17:41

[SOLVED] Perform role-specific order?
 
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?

Bugsy 09-24-2015 17:45

Re: [HELP] Perform role-specific order?
 
PHP Code:

for ( new sizeofmessages ) ; i++ )
{




Bugsy 09-24-2015 18:36

Re: [HELP] Perform role-specific order?
 
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++ ] );



CrazY. 09-24-2015 21:22

Re: [HELP] Perform role-specific order?
 
Did not work.

fysiks 09-24-2015 21:30

Re: [HELP] Perform role-specific order?
 
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.

CrazY. 09-24-2015 21:42

Re: [HELP] Perform role-specific order?
 
the message appears but continues randomized, appears when you start the round, then no longer appears.

fysiks 09-24-2015 21:45

Re: [HELP] Perform role-specific order?
 
Quote:

Originally Posted by CrazY. (Post 2346652)
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.

CrazY. 09-24-2015 22:25

Re: [HELP] Perform role-specific order?
 
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.

fysiks 09-24-2015 22:53

Re: [HELP] Perform role-specific order?
 
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.

CrazY. 09-25-2015 09:36

Re: [HELP] Perform role-specific order?
 
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");
}



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

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