Dėl menu

Šiame forume rašomi vartotojų klausimai/problemos su kuriomis jie susidūrė kuriant pluginus.
Post Reply
xedga
Jau po truputį tampa savu
Posts: 154
Joined: 2010 Sep 24 20:12
Skype: xedga-beribu
Location: Šiauliai/Kaunas

Dėl menu

Post by xedga »

Sveiki,
Kaip padaryti menu daugiau nei case 9, nes darant case 10 error. Tikiuosi supratot :D Ačiu už pagalba :)

addinol
Jau po truputį tampa savu
Posts: 144
Joined: 2010 Sep 05 15:20
Skype: kasparas94

Re: Dėl menu

Post by addinol »

jei new menu style tai negali būti, turi viskas veikti :)

xedga
Jau po truputį tampa savu
Posts: 154
Joined: 2010 Sep 24 20:12
Skype: xedga-beribu
Location: Šiauliai/Kaunas

Re: Dėl menu

Post by xedga »

public menu_gameschoice(id, menu, item)
{
if(item == MENU_EXIT || g_GameMode > 1)
{
menu_destroy(menu)
cmd_gamesmenu(id)
return PLUGIN_HANDLED
}

static dst[32], data[5], access, callback


menu_item_getinfo(menu, item, access, data, charsmax(data), dst, charsmax(dst), callback)
menu_destroy(menu)
get_user_name(id, dst, charsmax(dst))

switch(data[0])
{

case('1'):
{

if (is_user_admin(id)) cmd_game_game1()
}

case'2':
{
if (is_user_admin(id))cmd_game_game2()
}

case('3'):
{
if ( is_user_admin(id)) cmd_game_game3()
}

case('4'):
{
if ( is_user_admin(id)) cmd_game_game4()
}

case('5'):
{
if (is_user_admin(id)) cmd_game5(id)
}

case('6'):
{
if (is_user_admin(id)) cmd_game6(id)
}

case('7'):
{
if (is_user_admin(id)) cmd_game_game7()
}

case('8'):
{
if (is_user_admin(id)) cmd_game_game8()
}

case('9'):
{
if (is_user_admin(id)) cmd_game_game9()
}

case('10'):
{
if (is_user_admin(id)) cmd_game_game10()
}

}
return PLUGIN_HANDLED
}

public cmd_gamegamesmenu(id)

{
if ((is_user_admin(id)) && g_GameMode <= 1)
{
static menu, menuname[32], option[64]

formatex(menuname, charsmax(menuname), "%L", LANG_SERVER, "MENU_MENU")
menu = menu_create(menuname, "game_gameschoice")


new allowed[31];
get_pcvar_string(gp_Games, allowed,31)
if (strlen(allowed) <= 0 ) return PLUGIN_CONTINUE

//gp_Games


if (containi(allowed,"e") >= 0)
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME1")
menu_additem(menu, option, "1", 0)
}
if (containi(allowed,"e") >= 0)
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME2")
menu_additem(menu, option, "2", 0)
}
if (containi(allowed,"e") >= 0)
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME3")
menu_additem(menu, option, "3", 0)
}
if (containi(allowed,"e") >= 0)
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME4")
menu_additem(menu, option, "4", 0)
}
if (containi(allowed,"e") >= 0)
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME5")
menu_additem(menu, option, "5", 0)
}
if (containi(allowed,"f") >= 0 && is_plugin_loaded("lol"))
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME6")
menu_additem(menu, option, "6", 0)
}
if (containi(allowed,"f") >= 0)
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME7")
menu_additem(menu, option, "7", 0)
}
if (containi(allowed,"f") >= 0)
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME8")
menu_additem(menu, option, "8", 0)
}
if (containi(allowed,"f") >= 0)
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME9")
menu_additem(menu, option, "9", 0)
}
if (containi(allowed,"f") >= 0)
{
formatex(option, charsmax(option), "%L", LANG_SERVER, "MENU_GAME10")
menu_additem(menu, option, "10", 0)
}


menu_display(id, menu)


}
return PLUGIN_HANDLED
}


Čia toks pavizdys mano meniu, šiaip aš naujokas scriptinime, tad prašau paaiškint, kai reikia daryt, ačiū.

addinol
Jau po truputį tampa savu
Posts: 144
Joined: 2010 Sep 05 15:20
Skype: kasparas94

Re: Dėl menu

Post by addinol »

Šiaip tai pirmiausia įdėk visą kodą į code, tada case naudok ne ('x') o tiesiog x

User avatar
hleV
AMX Mod X ekspertai
Posts: 875
Joined: 2011 Apr 02 11:23
Skype: hlev.lt
Location: Šiauliai

Re: Dėl menu

Post by hleV »

Char gali sudaryt tik vieną simbolį ('a', '1' ir t.t.), o tu padarei '10'. Pasiversk tą data[] į int (new num = str_to_num(data);) ir switch'e tikrink būtent num.
Image ← RIP best userbar
DISKUSIJA: KIETAS PLUGIN'O UŽSAKOVAS
Privačios pagalbos neteikiu!

xedga
Jau po truputį tampa savu
Posts: 154
Joined: 2010 Sep 24 20:12
Skype: xedga-beribu
Location: Šiauliai/Kaunas

Re: Dėl menu

Post by xedga »

Tai tarkim char galiu naudoti raides, vietoj skaičių? Tada viskas ok butu, nes raidžiu pasirinkimas nemažas :D

User avatar
hleV
AMX Mod X ekspertai
Posts: 875
Joined: 2011 Apr 02 11:23
Skype: hlev.lt
Location: Šiauliai

Re: Dėl menu

Post by hleV »

Aš tai siūlyčiau item tikrint, o ne data[].

Code: Select all

switch (item){    case 0:    {        // 1 pasirinkimas    }    case 1:    {        // 2 pasirinkimas    }    // Ir t.t.}
Image ← RIP best userbar
DISKUSIJA: KIETAS PLUGIN'O UŽSAKOVAS
Privačios pagalbos neteikiu!

xedga
Jau po truputį tampa savu
Posts: 154
Joined: 2010 Sep 24 20:12
Skype: xedga-beribu
Location: Šiauliai/Kaunas

Re: Dėl menu

Post by xedga »

O tada tarkim gali but daugiau nei 9? 10,11,12...?

User avatar
hleV
AMX Mod X ekspertai
Posts: 875
Joined: 2011 Apr 02 11:23
Skype: hlev.lt
Location: Šiauliai

Re: Dėl menu

Post by hleV »

Taip.
Image ← RIP best userbar
DISKUSIJA: KIETAS PLUGIN'O UŽSAKOVAS
Privačios pagalbos neteikiu!

xedga
Jau po truputį tampa savu
Posts: 154
Joined: 2010 Sep 24 20:12
Skype: xedga-beribu
Location: Šiauliai/Kaunas

Re: Dėl menu

Post by xedga »

Žodžiu, ačiū visiems už pagalba :)

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests