AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Info about register_dictionary (https://forums.alliedmods.net/showthread.php?t=107011)

OneMoreLevel 10-21-2009 13:44

Info about register_dictionary
 
I see a bunch of people using register_dictionary, and including text files in their plugins. What does this do? I amxmod funcwiki'd it but it just said that it registers a dictionary, which isnt very informative. I understand they are used to make things multi-lingual(I think), But what do they really do?

P.S. Sorry for making another thread, I just figured if someone searched for this they would find it easier(Like another newbie that needs the answer :D)

Hawk552 10-21-2009 13:57

Re: Info about register_dictionary
 
A dictionary file contains a bunch of text tokens for different languages. For example, if I want to translate my previous sentence into French, I would first put this in a dictionary file:

Code:

[en]
HAWK_TALK = A dictionary file contains a bunch of text tokens for different languages.

[fr]
HAWK_TALK = Un dictionaire containez some bullshit and I suck at translating French so fuck this.

Then, I can put this in my plugin:

PHP Code:

client_printidprint_chat"Hawk552: %L"LANG_PLAYER"HAWK_TALK" 

or

PHP Code:

client_printidprint_chat"Hawk552: %L"LANG_SERVER"HAWK_TALK" 

Anyway, your %L token will be replaced with the given dictionary entry. For example, if the server's language is English, but the client's is French, then it'll print to them in French with the first example and English with the second.

OneMoreLevel 10-21-2009 14:09

Re: Info about register_dictionary
 
So if I make a dictionary file like this:
Code:

[en]
OML_TALK = Hello!

[fr]
OML TALK = Some french word!

Then made a VERY simple plugin like this:
PHP Code:

/* Sample plugin */
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"say /talk" "plugin_talk");
    
register_dictionary("dictionary_talk.txt")
}

public 
plugin_talk (id) {
    
client_printidprint_chat"Server says: %L"LANG_PLAYER"OML_TALK"id )


It would do
Quote:

if the server's language is English, but the client's is French, then it'll print to them in French

Hawk552 10-21-2009 14:19

Re: Info about register_dictionary
 
Yes.

Hawk552 10-21-2009 14:29

Re: Info about register_dictionary
 
Oops, you can scratch that ID stuff. I just looked it up to make sure I was right. I've never used ML before as I think everyone should use English, so you can call me an idiot at this.

LANG_PLAYER seems to only work in functions where an id is passed into them, such as client_print(). Otherwise, you should use LANG_SERVER. There's no id parameter after either of them.

OneMoreLevel 10-21-2009 14:36

Re: Info about register_dictionary
 
Ahh I see so I use:

client_print( id, print_chat, "Hawk552: %L", LANG_PLAYER, "HAWK_TALK" )

Instead the other one?>

Hawk552 10-21-2009 14:39

Re: Info about register_dictionary
 
Yes.

OneMoreLevel 10-21-2009 14:44

Re: Info about register_dictionary
 
Ok, thanks for your help :D

Arkshine 10-21-2009 14:48

Re: Info about register_dictionary
 
It should be client_print( id, print_chat, "Hawk552: %L", id, "HAWK_TALK" ) ; LANG_PLAYER has to be used only when 0 is passed as id.


All times are GMT -4. The time now is 17:46.

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