Raised This Month: $ Target: $400
 0% 

CountryChat error


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
lashsh
BANNED
Join Date: Jun 2010
Location: Georgia, Tbilisi
Old 06-24-2010 , 09:31   CountryChat error
Reply With Quote #1

Code:
/*
*  Link to the plugin: http://virtual.new.bg/forum/viewtopic.php?f=125&t=1864 
*=====================================================================================
*  Country Chat plugin by Virtual.New.BG Version 2.1 Made in Bulgaria
*=====================================================================================
*  Change Log:
*    v1.0 = Initial release
*    v1.1 = Correction Code
*    v2.0 = Fixed all possible bugs
*    v2.1 = Fixed bug with the quote where country is not shown
*           Fixed bug with logging the chat in the console
*           Fixed bug where the players see team chat of the other team
*    v2.2 = Added Cvar out how to name the country - full or short name
*    v2.3 = Now plugin replace error message
*    v2.4 = Added GeoIP Code3. To display three characters from the Country
*=====================================================================================
*  Tests:
*    Under Windows 4554 platform with AmxModx 1.8.1 - Work
*    Under Linux 4617 platform with AmxModx 1.8.1 - Work
*=====================================================================================
*/

#include <amxmodx>
#include <geoip>

#define VERSION   "2.4"

new SzCountryLength, SzMaxPlayers, SzSayText;
new SzName[33][32];
new SzIP[17][16];
new SzGeoIP2[4][3];
new SzGeoIP3[5][4];
new SzCountry[33][46];

new SzGTeam[3][] = {
   "Spectator",
   "Terrorist",
   "Counter-Terrorist"
}

public plugin_init()
{
   register_plugin("Country Chat", VERSION, "Virtual.New.BG");
   register_clcmd("say", "hook_say");
   register_clcmd("say_team", "hook_say_team");
   
   SzCountryLength = register_cvar("country_chat_length", "1");
   
   register_cvar("country_chat_version",   VERSION, FCVAR_SERVER|FCVAR_SPONLY);
   set_cvar_string("country_chat_version",   VERSION);
   
   SzSayText = get_user_msgid ("SayText");
   SzMaxPlayers = get_maxplayers();
   
   register_message(SzSayText, "MsgDuplicate");
}

public MsgDuplicate(id){ return PLUGIN_HANDLED; }

public hook_say(id){
   new Messages[192];
   new SzAlive = is_user_alive(id);
   
   read_args(Messages, 191);
   remove_quotes(Messages);
   get_user_name(id, SzName[id], 31);
   get_user_ip(id, SzIP[id], 15);
   geoip_country(SzIP[id], SzCountry[id]);
   geoip_code2(SzIP[id], SzGeoIP2[id]);
   geoip_code3(SzIP[id], SzGeoIP3[id]);   
   
   if(!is_valid_msg(Messages))
      return PLUGIN_CONTINUE;

   switch(get_pcvar_num(SzCountryLength)){
      case 1: { (SzAlive ? format(Messages, 191, "^4[%s] ^3%s : ^1%s", SzCountry[id], SzName[id], Messages) : format(Messages, 191, "^1*DEAD* ^4[%s] ^3%s : ^1%s", SzCountry[id], SzName[id], Messages)); }
      case 2: { (SzAlive ? format(Messages, 191, "^4[%s] ^3%s : ^1%s", SzGeoIP2[id], SzName[id], Messages) : format(Messages, 191, "^1*DEAD* ^4[%s] ^3%s : ^1%s", SzGeoIP2[id], SzName[id], Messages)); }
      case 3: { (SzAlive ? format(Messages, 191, "^4[%s] ^3%s : ^1%s", SzGeoIP3[id], SzName[id], Messages) : format(Messages, 191, "^1*DEAD* ^4[%s] ^3%s : ^1%s", SzGeoIP3[id], SzName[id], Messages)); }}
   
   for(new i = 1; i <= SzMaxPlayers; i++){
      if(!is_user_connected(i))
         continue;
      if(SzAlive && is_user_alive(i) || !SzAlive && !is_user_alive(i)){
         message_begin(MSG_ONE, SzSayText, {0, 0, 0}, i);
         write_byte(id);
         write_string(Messages);
         message_end();} }
   return PLUGIN_CONTINUE;
}

public hook_say_team(id){
   new Messages[192];
   new SzPlayerTeam = get_user_team(id);
   new SzAlive = is_user_alive(id);
   
   read_args(Messages, 191);
   remove_quotes(Messages);
   get_user_name(id, SzName[id], 31);
   get_user_ip(id, SzIP[id], 15)
   geoip_country(SzIP[id], SzCountry[id]);
   geoip_code2(SzIP[id], SzGeoIP2[id]);
   geoip_code3(SzIP[id], SzGeoIP3[id]);
   
   if(!is_valid_msg(Messages))
      return PLUGIN_CONTINUE;
   
   switch(get_pcvar_num(SzCountryLength)){
      case 1: { (SzAlive ? format(Messages, 191, "^1(%s) ^4[%s] ^3%s : ^1%s", SzGTeam[SzPlayerTeam], SzCountry[id], SzName[id], Messages) : format(Messages, 191, "^1*DEAD* (%s) ^4[%s] ^3%s : ^1%s", SzGTeam[SzPlayerTeam], SzCountry[id], SzName[id], Messages)); }
      case 2: { (SzAlive ? format(Messages, 191, "^1(%s) ^4[%s] ^3%s : ^1%s", SzGTeam[SzPlayerTeam], SzGeoIP2[id], SzName[id], Messages) : format(Messages, 191, "^1*DEAD* (%s) ^4[%s] ^3%s : ^1%s", SzGTeam[SzPlayerTeam], SzGeoIP2[id], SzName[id], Messages)); } 
      case 3: { (SzAlive ? format(Messages, 191, "^1(%s) ^4[%s] ^3%s : ^1%s", SzGTeam[SzPlayerTeam], SzGeoIP3[id], SzName[id], Messages) : format(Messages, 191, "^1*DEAD* (%s) ^4[%s] ^3%s : ^1%s", SzGTeam[SzPlayerTeam], SzGeoIP3[id], SzName[id], Messages)); } }
   
   for(new i = 1; i <= SzMaxPlayers; i++){
      if(!is_user_connected(i))
         continue;
      if(get_user_team(i) != SzPlayerTeam)
         continue;
      if(SzAlive && is_user_alive(i) || !SzAlive && !is_user_alive(i)){
         message_begin(MSG_ONE, SzSayText, {0, 0, 0}, i);
         write_byte(id);
         write_string(Messages);
         message_end();} }
   return PLUGIN_CONTINUE;
}

bool:is_valid_msg(const Messages[]){
   if( Messages[0] == '@'
   || !strlen(Messages)){ return false; }
   return true;}


Code:
L 06/24/2010 - 14:19:27: [AMXX] Run time error 4 (plugin "CountryChat.amxx") - debug not enabled!
L 06/24/2010 - 14:19:27: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).

original plug-in


CountryChat.amxx debug
Code:
L 06/24/2010 - 16:57:20: [AMXX] Displaying debug trace (plugin "CountryChat.amxx")
L 06/24/2010 - 16:57:20: [AMXX] Run time error 4: index out of bounds 
L 06/24/2010 - 16:57:20: [AMXX]    [0] CountryChat.sma::hook_say (line 69)
L 06/24/2010 - 16:57:21: [AMXX] Displaying debug trace (plugin "CountryChat.amxx")
L 06/24/2010 - 16:57:21: [AMXX] Run time error 4: index out of bounds 
L 06/24/2010 - 16:57:21: [AMXX]    [0] CountryChat.sma::hook_say (line 67)

line 67
Code:
  geoip_country(SzIP[id], SzCountry[id]);
line 69
Code:
  geoip_code3(SzIP[id], SzGeoIP3[id]);
please help.
lashsh is offline
Send a message via Skype™ to lashsh
 


Thread Tools
Display Modes

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 14:50.


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