AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ML Support for menus? (https://forums.alliedmods.net/showthread.php?t=46312)

k007 10-23-2006 08:27

ML Support for menus?
 
could someone show how to add ML support for Menus

jopmako 10-23-2006 14:56

Re: ML Support for menus?
 
ML = multi lingual?

k007 10-23-2006 17:46

Re: ML Support for menus?
 
yeah

Nostrodamous 10-23-2006 18:57

Re: ML Support for menus?
 
:D Ok well this time Im going to show everyone how to make a menu , and make it support multiple languges , and text from file . So first let me begin by saying , If you arnt famailar with amxmodx scripting read over my tutorials 1 and 2 before reading this one . Im going to asume you know the basices of the codeing .
Ok first like the rest of our scripts were going to make our includes . Menu are pretty much covered by amxmodx and misc . So no other modules are needed to make a menu .
Code:

#include <amxmodx>
#include <amxmisc>

So the next thing in our script is going to be our variables . Here were decalaring that these are the keys for the menu
Code:

new  keys  = MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9
So next is the part where we always regiister the plugin . It has to be in every script , Its like the main() functon in C++ . It is included in every script .
Code:

public plugin_init()
 {
 register_plugin("RapHero's Tutorial 3" , "1.0" , "RapHero2000")
 register_menucmd(register_menuid("raps_menu") ,1023 , "next_menu")
 register_concmd("amx_menu" , "raps_menu" , ADMIN_ALL , "Brings Up Menu")
 register_dictionary("raps_file.txt")
}

Ok now let me go into detail about what we just registered . When you make a menu you have to register it in the plugin_init . So the first param is the menuid , then the name of the menu , then the keys , then the function that will be called after selcting from the menu . Then we have also registered a dictionary . This is the text file that we will be caling from later in the script . but in order to use it , and mulit lang support you need it . Also ,once again we registered a concmd , that the player will type in to make the menu show up . Next were making the function that shows the menu .
Code:

public raps_menu(id)
{
 new menu[192] //this declares the menu and lenght used
 format(menu , 191 , "%L" , LANG_PLAYER , "HI")  //format of the menu
 show_menu(id, keys , menu , -1  , "raps_menu")  // shows the menu
 return PLUGIN_CONTINUE
}

Ok so first we have to decalre that we are going to have something called menu, and that menu can contain 192 charachters . The format , menu , keys , and length ,have already been defined , length will alwaya be 1 less then what we declared .
%L Means we are calling to a Lang file (the dictioanry we registered earlier) , LANG_PLAYER meens were translating into the language of the current player . We could use the servers language which is LANG_SERVER . Next were calling "HI" , which is in the txt file . In the txt file youll see
Code:

[en]  //this meens english
HI = Hello^n How Are You ?^n1. Good^n2. Bad^n

So HI is what it found from file , and hi == whatever . So it will show what HI equals . ^ is a new line for the menu .
return PLUGIN_CONTINUE meens functions will keep going . The show menu function is what will actually make the menu display . id , keys and
menu are already defined . so next the -1 means that we wont specify a set time for the menu to be displayed .The the menu that will be dispayed . Next up is what happens when some one make a choice from the menu
Code:

public next_menu(id , key ) // this is the function called when a chioce is made last param from register_menucd
{
 if(key ==0) // option 1 "good"
 {
  client_print(id , print_chat , "%L" , LANG_PLAYER , "GOOD")
 }
 else  // switches the statemant
 {
  if(key == 1)// option 2  "bad"
  {
  client_print(id , print_chat , "%L" , LANG_PLAYER , "BAD")
  }
 }
 return PLUGIN_HANDLED
}

So here we did aa client print in the players language from the lnguage file , depending on what they selected .There are also a good amount of languages supported by amxmodx .
[en] = english
[es] = spanish
[de] = german
so on and so forth . for a full list , go and get your languages file from the amxmodx/data/lang folder . It has all the languages and symbols it supports . So here is our full code
Code:

/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
new  keys  = MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9

public plugin_init()
 {
 register_plugin("nas Tutorial 3" , "1.0" , "nas")
 register_menucmd(register_menuid("my_menu") ,1023 , "next_menu")
 register_concmd("amx_menu" , "my_menu" , ADMIN_ALL , "Brings Up Menu")
 register_dictionary("my_file.txt")
}
public my_menu(id)
{
 new menu[192]
 format(menu , 191 , "%L" , LANG_PLAYER , "HI")
 show_menu(id, keys , menu , -1  , "my_menu")
 return PLUGIN_CONTINUE
}
public next_menu(id , key )
{
 if(key ==0) // option 1
 {
  client_print(id , print_chat , "%L" , LANG_PLAYER , "GOOD")
 }
 else
 {
  if(key == 1)// option 2
  {
  client_print(id , print_chat , "%L" , LANG_PLAYER , "BAD")
  }
 }
 return PLUGIN_HANDLED
}

and here is our text file
Code:

[en]
HI = Hello^n How Are You ?^n1. Good^n Bad^n^n0: EXIT
GOOD = Im Glad To Hear it . Im Good also
BAD = Im Sorry To hear That .
[es]
HI = ¿hola cómo es usted?^n1. Buena^n2. Mala^n^n0 : SALIDA
GOOD = Im alegre oírlo. Im bueno también
BAD = Im apesadumbrado de oír eso

Notice i only did english and spanish support . But you can add mroe on your own . Hope this helps . Any questions just ask :D

k007 10-23-2006 19:11

Re: ML Support for menus?
 
rap thats kinda of not what im looking fo i want to add ML to something like this
Code:
 format(menu, 511, "\rGrenade Mod\w^n^n1. Buy Seeking HE grenade           \y($%i)\w^n2. Buy Colored FlashBang       \y($%i)\w^n3. Buy Smoke grenade         \y($%i)\w^n^n0. Exit^n", HE, FB, SG)

teame06 10-23-2006 19:15

Re: ML Support for menus?
 
For ML in menus is the same as in if you were going to use client_print, console_print.

Lord_Destros 10-23-2006 21:35

Re: ML Support for menus?
 
Quote:

Originally Posted by k007 (Post 394481)
rap thats kinda of not what im looking fo i want to add ML to something like this

good job :roll:. And now we wait for the moderators.....Hence the cycle repeats :lol:

Nostrodamous 10-24-2006 00:00

Re: ML Support for menus?
 
the way i added multi-lang for the menu is the same as if you were to do like so
Code:
client_print(id,print_chat,"%L",id,"HELLO"); or format(menu,192,"%L",id,"MENU");

:up:

jopmako 10-24-2006 01:09

Re: ML Support for menus?
 
Quote:

Originally Posted by k007 (Post 394481)
rap thats kinda of not what im looking fo i want to add ML to something like this

format(menu, 511, "\rGrenade Mod\w^n^n1. Buy Seeking HE grenade \y($%i)\w^n2. Buy Colored FlashBang \y($%i)\w^n3. Buy Smoke grenade \y($%i)\w^n^n0. Exit^n", HE, FB, SG)

Code:

new menu[512], Menuname[64], Item1[64], Item2[64], Item3[64], Item4[64]
format(Menuname,[63],"\r%L^n^n",id,"MENU_NAME")
format(Menuname,[63], "\w1.%L\y($%i)^n", id, "ITEM_1", HE)
format(Menuname,[63], "\w2.%L\y($%i)^n", id, "ITEM_2", FB)
format(Menuname,[63], "\w3.%L\y($%i)^n^n", id, "ITEM_3", SG)
format(Menuname,[63], "\w0.%L", id, "ITEM_4")
format(menu,511,"%s%s%s%s%s",Menuname, Item1, Item2, Item3, Item4)

Use this kind of code or new menu system will clear more and easy for ML.


All times are GMT -4. The time now is 04:47.

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