AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Creating a script with data/lang (https://forums.alliedmods.net/showthread.php?t=54674)

MPNumB 05-01-2007 10:05

Creating a script with data/lang
 
What will the formula look like if I want to create a script with lagnuage menu, and lang will be in: console_print(id,...) and server_cmd(kick %s ...)? I had tryed but i just printed me: ML_NOTFOUND: ...
P.S. I'm sorry 4 this question, but I'm just a bit new in this scripting.

mateo10 05-01-2007 11:17

Re: Creating a script with data/lang
 
If we assume you have a dictionary file called "dictionary.txt" in amxmodx/data/lang folder, and you have this line in it.
Code:

TEST = Test
First, you'll have to register the dictionary in plugin_init:
Code:
register_dictionary("dictionary.txt")

Then, use it in a way like this:
Code:
client_print(id, print_chat, "%L", id, "TEST")
You gotta have the "id" there because you want to use the id's language.

This will print out "Test" in chat.

Arkshine 05-01-2007 11:29

Re: Creating a script with data/lang
 
Quote:

You gotta have the "id" there because you want to use the id's language.
Is this way the same than LANG_PLAYER?

mateo10 05-01-2007 11:32

Re: Creating a script with data/lang
 
Think so. I'm not sure though :S

Arkshine 05-01-2007 11:33

Re: Creating a script with data/lang
 
I'm sure. lol

LANG_PLAYER or LANG_SERVER are available.

mateo10 05-01-2007 11:48

Re: Creating a script with data/lang
 
When I used id instead of LANG_PLAYER it worked too.

teame06 05-01-2007 17:19

Re: Creating a script with data/lang
 
You use the player index when your only sending the client the message. You use LANG_PLAYER When you do print to all client. You would do the same thing with show_hudmessage.

Code:
client_print(0, print_chat, "%L", LANG_PLAYER, "TEST");

If you want to send a message using the server language. You would replace id or LANG_PLAYER with LANG_SERVER.


Edit:

P.S. LANG_PLAYER was design to show the message in the client language vs just one language

MPNumB 05-02-2007 15:20

Re: Creating a script with data/lang
 
Code:

console_print(id, "%L", id, "TESTING")
It isn't working :( , but evry thing alce dose. :P
Will it be difrent if i'll use LANG_PLAYER isted of id?

This plugin:
Code:

/*
* Cvars:
*
* amx_reservation <value>
* 0 - Disables the plugin.
* 1 - Kicks the Player with the shortest playing time when an admin connects to a full server.
* 2 - Kicks the Player with the longest playing time when an admin connects to a full server.
* 3 - Kicks the Player with the highest ping when an admin connects to a full server.
* 4 - Normal AMX Mode: 'amx_reservedslots' are reserved, nobody is kicked when an admin connects to a full server
*
* amx_reservedslots <value> : number of reserved slots (if amx_reservation is set to 4)
*
* amx_hideslots <1 or 0> : hide reserved slots or not (if amx_reservation is set to 4)
*
* amx_rslot_redirect <1 or 0> : if 1 will redirect player, if 0 - kick
*
* amx_rslot_redirectip <server.ip.address.and:port> : set server ip/domain and port to where player will be redirected (if amx_rslot_redirect is set to 1)
*
* amx_rslot_redirectpw <password> : set password of server where player will be redirected (if amx_rslot_redirect is set to 1)
*
*
*/
 
#define PLUGIN "Admin Slots Ultimate"
#define VERSION "1.2"
#define AUTHOR "NumB & Slmclarengt"
#include <amxmodx>
#include <amxmisc>
new g_maxplayers
new cvar_redirectip
new cvar_redirectpw
public plugin_init() {
 register_plugin(PLUGIN, VERSION, AUTHOR)
 register_cvar("amx_reservation","0")
 register_cvar("amx_reservedslots","0")
 register_cvar("amx_hideslots","0")
 register_cvar("amx_rslot_redirect","0")
 cvar_redirectip = register_cvar("amx_rslot_redirectip"," ")
 cvar_redirectpw = register_cvar("amx_rslot_redirectpw"," ")
 register_dictionary("adminslots_ultimate.txt")
 
 g_maxplayers = get_maxplayers()
}
public plugin_cfg() {
 new amx_reservation_var = get_cvar_num("amx_reservation")
 new amx_hideslots = get_cvar_num("amx_hideslots")
 new amx_reservedslots = get_cvar_num("amx_reservedslots")
 if(amx_reservation_var > 0 && amx_reservation_var < 4) {
  set_cvar_num("sv_visiblemaxplayers", g_maxplayers - 1)
 } else if(amx_reservation_var == 4) {
  if(amx_hideslots == 1) {
  new players = get_playersnum(1)
  new limit = g_maxplayers - amx_reservedslots
  setVisibleSlots(players, limit)
  }
 }
}
kick(id) {
 new amx_rslot_redirect = get_cvar_num("amx_rslot_redirect")
 if(amx_rslot_redirect == 1) {
  if (is_user_bot(id)) {
  new lReason[128]
  format(lReason, 127, "%L", id, "DROPPED_RESERV")
  server_cmd("kick #%d %s", get_user_userid(id), lReason)
  } else {
  new redirectip[64], redirectpw[32]
  get_pcvar_string(cvar_redirectip,redirectip,63)
  get_pcvar_string(cvar_redirectpw,redirectpw,31)
  client_cmd(id,"echo;echo -=====-;echo Redirecting...;echo -=====-;echo;wait;disconnect;password ^"%s^";serverpassword ^"%s^";connect %s",redirectpw,redirectpw,redirectip)
  }
 } else {
  new lReason[128]
  format(lReason, 127, "%L", id, "DROPPED_RESERV")
  server_cmd("kick #%d %s", get_user_userid(id), lReason)
 }
}
public client_authorized(id) {
 new players = get_playersnum(1)
 new limit, who
 new amx_reservation_var = get_cvar_num("amx_reservation")
 if(amx_reservation_var <= 0) return PLUGIN_CONTINUE
 
 if(amx_reservation_var < 4) {
  limit = g_maxplayers - 1
  if(players > limit) {
  if(get_user_flags(id) & ADMIN_RESERVATION) {
    switch(amx_reservation_var) {
    case 1:
    who = kickShortestPlayingTime()
    case 2:
    who = kickLongestPlayingTime()
    case 3:
    who = kickLag()
    }
    if(who) {
    new name[32]
    get_user_name(who, name, 31)
    console_print(id, "* %L", id, "WAS_KICKED", name)
    }
    return PLUGIN_CONTINUE
  }
  kick(id)
  return PLUGIN_HANDLED
  }
 } else if(amx_reservation_var == 4) {
  limit = g_maxplayers - get_cvar_num("amx_reservedslots")
  if((get_user_flags(id) & ADMIN_RESERVATION) || (players <= limit)) {
  if(get_cvar_num("amx_hideslots") == 1) {
    setVisibleSlots(players, limit)
  }
  return PLUGIN_CONTINUE
  }
  kick(id)
 }
 return PLUGIN_CONTINUE
}
public client_disconnect(id) {
 if(get_cvar_num("amx_reservation") == 4 && get_cvar_num("amx_hideslots") == 1) {
  setVisibleSlots(get_playersnum(1) - 1, g_maxplayers - get_cvar_num("amx_reservedslots"))
 }
 return
}
kickShortestPlayingTime() {
 new who = 0, itime, shortest = 0x7fffffff
 for(new i = 1; i <= g_maxplayers; ++i) {
  if(!is_user_connected(i) && !is_user_connecting(i))
  continue
  if(get_user_flags(i) & ADMIN_RESERVATION)
  continue
  itime = get_user_time(i)
  if(shortest > itime) {
  shortest = itime
  who = i
  }
 }
 if(who) {
  console_print(who, "%L", who, "DROPPED_SHORTEST")
  kick(who)
 }
 return who
}
kickLongestPlayingTime() {
 new who = 0, itime, longest = -1
 for(new i = 1; i <= g_maxplayers; ++i) {
  if(!is_user_connected(i) && !is_user_connecting(i))
  continue
  if(get_user_flags(i) & ADMIN_RESERVATION)
  continue
  itime = get_user_time(i)
  if(longest < itime) {
  longest = itime
  who = i
  }
 }
 if(who) {
  console_print(who, "%L", who, "DROPPED_LONGEST")
  kick(who)
 }
 return who
}
kickLag() {
 new who = 0, ping, loss, worst = -1
 for(new i = 1; i <= g_maxplayers; ++i) {
  if(!is_user_connected(i) && !is_user_connecting(i))
  continue
  if(get_user_flags(i) & ADMIN_RESERVATION)
  continue
  get_user_ping(i, ping, loss)
  if(ping > worst) {
  worst = ping
  who = i
  }
 }
 if(who) {
  console_print(who, "%L", who, "DROPPED_HIGHPING")
  kick(who)
 }
 return who
}
setVisibleSlots(players, limit) {
 new num = players + 1
 if(players == g_maxplayers) {
  num = g_maxplayers
 } else if(players < limit) {
  num = limit
 }
 set_cvar_num("sv_visiblemaxplayers", num)
}

lang:
[en]
DROPPED_RESERV = Dropped due to slot reservation
WAS_KICKED = * "%s" was kicked to free this slot
DROPPED_SHORTEST = Dropped due to shortest playing time to free slot for an admin
DROPPED_LONGEST = Dropped due to longest playing time to free slot for an admin
DROPPED_HIGHPING = Dropped due to high ping to free slot for an admin

teame06 05-02-2007 15:39

Re: Creating a script with data/lang
 
Quote:

Originally Posted by MPNumB (Post 472609)
Code:

console_print(id, "%L", id, "TESTING")
It isn't working :( , but evry thing alce dose. :P
Will it be difrent if i'll use LANG_PLAYER isted of id?

LANG_PLAYER isn't meant to be used if you were sending a message to a single client only. I would suggest you paste your whole code then if it not working with the lang file etc.

MPNumB 05-02-2007 15:44

Re: Creating a script with data/lang
 
You writed more faster, than I edited my last post. =P Thx if you'll try to help me. =)
Works just: DROPPED_RESERV :(


All times are GMT -4. The time now is 06:34.

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