AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Arrays and Consts (https://forums.alliedmods.net/showthread.php?t=195485)

Mrki_Drakula 09-08-2012 06:52

Arrays and Consts
 
Hello. How can i assign the right const according to the variable size, number whatever?

PHP Code:

new g_DayType[7]                    // Which Day Type is today?

new const Types[][] =
{
    
"Normal Day",
    
"Free Day",
    
"Games Day"


Now, i need to show right day type in the status hud.

PHP Code:

set_hudmessage255000.050.2000.11.00.10.1);
show_hudmessage0"[STATUS]^n- Day Type: %s"Types[g_DayType] ); 

That is what i have been trying, but its not working. Can someone help me please?

Note: I've attached number 7 to g_DayType, becasue there are 7 days ( 0, 1, 2, 3, 4, 5, 6 ... And 7 for 0 again ), so the Server can count the days. Which means, this is how im declaring the day, and day type.

PHP Code:

g_DayType[0] = 

First 0 says which day it is, and the second is attaching a day type to the day. Hope you understood me.

jimaway 09-08-2012 08:15

Re: Arrays and Consts
 
you need to index g_DayType array in show_hudmessage

Mrki_Drakula 09-10-2012 04:30

Re: Arrays and Consts
 
Not possible, 'cause i cant index a day. It should do it automatically.

jimaway 09-10-2012 04:45

Re: Arrays and Consts
 
new g_DayType[7]
Types[g_DayType]

how the hell should g_DayType be indexed automatically there?

OvidiuS 09-10-2012 05:06

Re: Arrays and Consts
 
Code:
#include < amxmodx > enum _:DAYS                                      // removed tag so i can use random func {     NORMAL,     FREE,     GAMES }     new g_DayType                   // Which Day Type is today? new const Types[ DAYS ][] = {     "Normal Day",     "Free Day",     "Games Day" }   public plugin_init( ) {     register_clcmd( "say /day", "command_Day" ) } public command_Day( id ) {     g_DayType = random( DAYS )     client_print( id, print_chat, "Day: %s", Types[ g_DayType  ] ) }
When command_Day is called, random day is choosen.
You should add manually index to g_DayType when some type of day is played.
Like:
Code:
g_DayType = GAME


All times are GMT -4. The time now is 08:13.

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