Raised This Month: $ Target: $400
 0% 

Arrays and Consts


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mrki_Drakula
Senior Member
Join Date: Jun 2011
Location: Serbia
Old 09-08-2012 , 06:52   Arrays and Consts
Reply With Quote #1

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.
Mrki_Drakula is offline
Send a message via MSN to Mrki_Drakula Send a message via Skype™ to Mrki_Drakula
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-08-2012 , 08:15   Re: Arrays and Consts
Reply With Quote #2

you need to index g_DayType array in show_hudmessage
jimaway is offline
Mrki_Drakula
Senior Member
Join Date: Jun 2011
Location: Serbia
Old 09-10-2012 , 04:30   Re: Arrays and Consts
Reply With Quote #3

Not possible, 'cause i cant index a day. It should do it automatically.
Mrki_Drakula is offline
Send a message via MSN to Mrki_Drakula Send a message via Skype™ to Mrki_Drakula
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-10-2012 , 04:45   Re: Arrays and Consts
Reply With Quote #4

new g_DayType[7]
Types[g_DayType]

how the hell should g_DayType be indexed automatically there?
jimaway is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 09-10-2012 , 05:06   Re: Arrays and Consts
Reply With Quote #5

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

Last edited by OvidiuS; 09-10-2012 at 05:12.
OvidiuS is offline
Send a message via Skype™ to OvidiuS
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 08:13.


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