AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Whats wrong with menu creation (https://forums.alliedmods.net/showthread.php?t=86457)

mogel 02-26-2009 02:35

Whats wrong with menu creation
 
Hi,

following code

Code:

public TeamSelect2(player) {
   
    new menu[1000]
    new line[100]
    new class[PLAYERCLASS]
    new keys
   
    client_cmd(player, "play sound/predatormod/menuloop.wav")
   
    // Anzahl aller Spieler zählen und entsprechend verhindern
    new players[32], count
    get_players(players, count, "h")
    for(new i = 0; i < count; i++) class[PLAYERCLASS:newclass[players[i]]]++;
   
    // die Headline einfügen
    //get_pcvar_string(pcv_headline, line, 99)
    format(menu, 999, "Predator-Mod (Version %s)^n%s", VERSION, line)
   
   
    format(menu, 999, "%s^n^n^n\rchoose your class\w^n", menu)
   
    AddMenuPoint(menu, 999, 1, "scout", class[PC_AUFKLAERUNG], get_pcvar_num(pcv_max_scout), keys, MENU_KEY_1, " - \ycan see the predator on his radar")
    AddMenuPoint(menu, 999, 2, "dogfight", class[PC_NAHKAMPF], get_pcvar_num(pcv_max_dogfight), keys, MENU_KEY_2, " - \yhas a flash")
    AddMenuPoint(menu, 999, 3, "infantry", class[PC_INFANTERIE], get_pcvar_num(pcv_max_infantry), keys, MENU_KEY_3, " - \yuse a parachute")
    AddMenuPoint(menu, 999, 4, "sniper", class[PC_SNIPER], get_pcvar_num(pcv_max_sniper), keys, MENU_KEY_4, " - \yless visible")
    AddMenuPoint(menu, 999, 5, "rear cover", class[PC_RUECKENDECKUNG], get_pcvar_num(pcv_max_rearcover), keys, MENU_KEY_5, " - \yhas a smoke")
   
    // Leerzeile
    format(menu, 999, "%s^n^n", menu)
   
    // Admins das Spect-Menü ermöglichen
    if (get_user_flags(player) & ADMIN_BAN) AddMenuPoint(menu, 999, 7, "spectator", 0, 0, keys, MENU_KEY_7, "")
   
    // Leerzeile
    format(menu, 999, "%s^n^n", menu)
   
    // und immer beenden
    AddMenuPoint(menu, 999, 0, "exit", 0, 0, keys, MENU_KEY_0, "")
   
    show_menu(player, keys, menu, -1, "TeamMenu")
   
    return PLUGIN_HANDLED
}
public AddMenuPoint(menu[], length, point, text[], count, max, &keys, key, info[]) {
    if (!max)
    {
        format(menu, length, "%s^n%i - %s%s", menu, point, text, info)
    } else
    {
        format(menu, length, "%s^n%c%i - %s (%i/%i)\w%s", menu, (count < max ? "\w" : "\d"), point, text, count, max, info)
    }
    if ((count < max) || !max) keys |= key
}

generates this bad menu

http://x8bit.de/images/cstrike/predatormenu.jpg

changes in Amxx since 1.7 ?

hand, mogel

PS: i'm using Notepad++ (ANSI/Utf-8/etc.) and Webcompiler

fysiks 02-26-2009 02:40

Re: Whats wrong with menu creation
 
I use Notepad++ too! I love it with my syntax highlighting. Also, you should use ANSI when programming these. I get failed compiles with UTF-8.

mogel 02-26-2009 03:09

Re: Whats wrong with menu creation
 
first i used ANSI ... then i try the same with UTF-8 ... same probleme :down:

xPaw 02-26-2009 03:10

Re: Whats wrong with menu creation
 
use new-style menus

mogel 02-26-2009 04:23

Re: Whats wrong with menu creation
 
new-style menu :?:

xPaw 02-26-2009 04:35

Re: Whats wrong with menu creation
 
http://forums.alliedmods.net/showthread.php?t=46364 ...

mogel 02-26-2009 05:10

Re: Whats wrong with menu creation
 
ah - ok ... copy&paste the code to the mod ... it looks better - but not corrent ... i try it an other time

Arkshine 02-26-2009 06:38

Re: Whats wrong with menu creation
 
mogel ; old-menu works perfectly fine and using new-menu is not necessary. I don't understand why some users give you as suggestions to use new-menu. Not the time to look at your code, but it's built strangely ; maybe should you redo your code with some testing.

ConnorMcLeod 02-26-2009 06:50

Re: Whats wrong with menu creation
 
May be it's because the string is formatted numerous times in a row, try to use add or formatex(menu[n],.. or something equivalent.

mogel 02-26-2009 09:11

Re: Whats wrong with menu creation
 
Moin,

Quote:

Originally Posted by arkshine (Post 769354)
old-menu works perfectly fine

ahhh - nice to hear ... but now i found the problem :arrow: webcompiler

e.g., this code
Code:

format(menu, 999, "%s^n^n^n\rchoose your class\w^n", menu)
have to replace with

Code:

format(menu, 999, "%s^n^n^n\\\rchoose your class\\\w^n", menu)
:wink:


All times are GMT -4. The time now is 10:49.

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