Array and variables
This is a definition for time in a banmenu, but i only know Basic so i need som help.
new g_HighBanMenuValues[4] = {5, 60, 6000, 0} I can see this is an array with 4 values, i would like to convert the values to the following. new g_HighBanMenuValues[4] = {1 Hour,3 Days, 7 Days, Permanent} My problem is the handling of it, so i need to make those strings as variables and give them a number so when the script runs i takes the number instead of the string...... Hope you understand :) /Wolf |
could i define each value as a variable like this:
(it is basic syntax, and hope someone can translate) dim 1Hour as integer dim 3Days as integer dim 7Days as integer dim Permanent as integer 1Hour = 3600 3Days = 259200 7Days = 604800 Permanent = 0 new g_HighBanMenuValues[4] = {1Hour,3Days,7Days,Permanent} And when the array is called the value given to the function will be the integer value of the variable. Cold i do it like that ? |
Code:
Strings are null terminated arrays. The defines are preprocessor directives so that 1Hour, 3Days, and other symbols are replaced with the numeric value defined by it right before it is compiled. |
This is the most dynamic way I can think of.
Also, this is not a string, so it doesn't need a null terminator. It is simply an array. Code:
On a side note, you can do Code:
And it should work. |
Though his example doesn't show it well, I think what L0neW0lf wants is for the menu to display the text but then return the integer value.
i.e. Menu shows: 1 Hour, 3 Days, 7 Days, Permanent Menu returns: 3600, 259200, 604800, 0 I think what you'd have to do is just see what text option was chosen and then based on that, assign the appropriate time integer to a variable. |
Quote:
|
Yes, get_time_length. It could be helpful if he wanted to make it more generic but really the issue is just the conversion from the textual choice the player made to the integer that the plugin needs. That would require either a conversion once the choice was made or if the menuing system allows it, piggybacking the integer value to the menu option somehow and just reading it when the choice is made.
|
Tried to make the piggyback thing i guess :)
But yet again the code might be basic. The original handling of the user choise: if (get_user_flags(id)&HIGHER_BAN_TIME_ADMIN) { switch(g_menuOption[id]) { case 0: g_menuSettings[id] = g_HighBanMenuValues[0] case 1: g_menuSettings[id] = g_HighBanMenuValues[1] case 2: g_menuSettings[id] = g_HighBanMenuValues[2] case 3: g_menuSettings[id] = g_HighBanMenuValues[3] } } My edited handling: if (get_user_flags(id)&HIGHER_BAN_TIME_ADMIN) { switch(g_menuOption[id]) { case 0: tempTime = g_HighBanMenuValues[0] case 1: tempTime = g_HighBanMenuValues[1] case 2: tempTime = g_HighBanMenuValues[2] case 3: tempTime = g_HighBanMenuValues[3] } if temptime = 1Hour then g_menuSettings[id] = 60 if temptime = 1Hour then g_menuSettings[id] = 4320 if temptime = 1Hour then g_menuSettings[id] = 10080 if temptime = 1Hour then g_menuSettings[id] = 0 } Is that a solution ? |
What I'm confused about is what you want g_HighBanMenuValues to refer to, a string or an integer. The code you wrote is equivalent to
Code:
Please tell us exactly how you want the code to operate. By the way, the if clauses are written as such: Code:
|
The following is the time minuts for a ban (0 = permanent)
Code:
In the ban menu those numbers are shown, but it can be har to know excactly what those number are in dayes/weeks. So the thing i want to do is the banmenu shows: Code:
The problem is the function need the time in minuts and not a text string. |
| All times are GMT -4. The time now is 16:38. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.