Raised This Month: $ Target: $400
 0% 

Creating a script with data/lang


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 05-01-2007 , 10:05   Creating a script with data/lang
Reply With Quote #1

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.
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
mateo10
Veteran Member
Join Date: Jan 2006
Old 05-01-2007 , 11:17   Re: Creating a script with data/lang
Reply With Quote #2

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.

Last edited by mateo10; 05-01-2007 at 11:26.
mateo10 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-01-2007 , 11:29   Re: Creating a script with data/lang
Reply With Quote #3

Quote:
You gotta have the "id" there because you want to use the id's language.
Is this way the same than LANG_PLAYER?
__________________
Arkshine is offline
mateo10
Veteran Member
Join Date: Jan 2006
Old 05-01-2007 , 11:32   Re: Creating a script with data/lang
Reply With Quote #4

Think so. I'm not sure though :S
mateo10 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-01-2007 , 11:33   Re: Creating a script with data/lang
Reply With Quote #5

I'm sure. lol

LANG_PLAYER or LANG_SERVER are available.
__________________
Arkshine is offline
mateo10
Veteran Member
Join Date: Jan 2006
Old 05-01-2007 , 11:48   Re: Creating a script with data/lang
Reply With Quote #6

When I used id instead of LANG_PLAYER it worked too.
mateo10 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 05-01-2007 , 17:19   Re: Creating a script with data/lang
Reply With Quote #7

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
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 05-01-2007 at 17:35.
teame06 is offline
Send a message via AIM to teame06
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 05-02-2007 , 15:20   Re: Creating a script with data/lang
Reply With Quote #8

Code:
console_print(id, "%L", id, "TESTING")
It isn't working , but evry thing alce dose.
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
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.

Last edited by MPNumB; 05-02-2007 at 15:43.
MPNumB is offline
Send a message via Skype™ to MPNumB
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 05-02-2007 , 15:39   Re: Creating a script with data/lang
Reply With Quote #9

Quote:
Originally Posted by MPNumB View Post
Code:
console_print(id, "%L", id, "TESTING")
It isn't working , but evry thing alce dose.
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.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 05-02-2007 , 15:44   Re: Creating a script with data/lang
Reply With Quote #10

You writed more faster, than I edited my last post. =P Thx if you'll try to help me. =)
Works just: DROPPED_RESERV
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.

Last edited by MPNumB; 05-02-2007 at 20:44.
MPNumB is offline
Send a message via Skype™ to MPNumB
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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