Raised This Month: $ Target: $400
 0% 

message doesn't shows when player connects


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Afro-Ankan
Member
Join Date: Jul 2009
Location: Sweden
Old 07-13-2010 , 09:32   message doesn't shows when player connects
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <geoip>
#define MAX_SAVE_CONNECTS 10000
new g_iConnectSaves;
new 
g_sAuthid[MAX_SAVE_CONNECTS][35];
new 
g_iConnections[MAX_SAVE_CONNECTS];
new 
g_iMsgSayText;
new 
g_iMaxPlayers;
public 
plugin_init()
{
 
register_plugin("Connect""1.0""someone");
 
g_iMsgSayText get_user_msgid("SayText");
 
g_iMaxPlayers get_maxplayers();
}
public 
client_putinserver(id)
{
 static 
sAuthid[sizeof(g_sAuthid[])], iNum;
 
get_user_authid(idsAuthidsizeof(sAuthid) - 1);
 
iNum = -1
 
if(g_iConnectSaves 0)
 {
  static 
i;
  for(
0g_iConnectSavesi++)
  {
   if(
equali(g_sAuthid[i], sAuthid))
   {
    
iNum i;
    
g_iConnections[i]++;
    break;
   }
  }
 }
 if(
iNum == -&& g_iConnectSaves MAX_SAVE_CONNECTS)
 {
  
copy(g_sAuthid[g_iConnectSaves], sizeof(g_sAuthid[]) - 1sAuthid);
  
iNum g_iConnectSaves++;
 }
 
 static 
sName[32], sIP[64], sCountry[46];
 
get_user_name(idsNamesizeof(sName) - 1);
 
get_user_ip(idsIPsizeof(sIP) - 11);
 
geoip_country(sIPsCountrysizeof(sCountry) - 1);
 
 static 
sMessage[192];
 
formatex(sMessagesizeof(sMessage) - 1"^x04[Connect] %s connected from %s [Connections: %d]"sNamesCountryg_iConnections[iNum]);
 
green_print(0sMessage);
}
public 
client_disconnect(id)
{
 static 
sName[32], sIP[64], sCountry[46];
 
get_user_name(idsNamesizeof(sName) - 1);
 
get_user_ip(idsIPsizeof(sIP) - 11);
 
geoip_country(sIPsCountrysizeof(sCountry) - 1);
 
 static 
sMessage[192];
 
formatex(sMessagesizeof(sMessage) - 1"^x04[Connect] %s disconnected from %s."sNamesCountry);
 
green_print(0sMessage);
}
stock green_print(indexsMessage[])
{
 if(
get_playersnum() < 1)
 {
  return 
0;
 }
 
 static 
MSG_typeid;
 if(
is_user_connected(index))
 {
  
id index;
  
MSG_type MSG_ONE_UNRELIABLE;
 }
 else
 {
  static 
i;
  for(
1<= g_iMaxPlayersi++)
  {
   if(
is_user_connected(i))
   {
    
id i;
    break;
   }
  }
  
MSG_type MSG_BROADCAST;
 }
 
 
message_begin(MSG_typeg_iMsgSayText_id);
 
write_byte(id);
 
write_string(sMessage);
 
message_end();
 
 return 
1;


Last edited by Afro-Ankan; 07-13-2010 at 09:40.
Afro-Ankan is offline
Send a message via MSN to Afro-Ankan
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-13-2010 , 17:12   Re: message doesn't shows when player connects
Reply With Quote #2

Your green_print() is incorrectly coded. Look at a colored print function and see how it is done there.

An example that I've used recently:

PHP Code:
// Prints chat in colours 
// use !g for green color 
// use !t for team color [Team color can be red ,blue or grey, It depends on players team] 
// use !y for yellow color 
stock client_colored_print(const id, const input[], any:...) 

    new 
iCount 1iPlayers[32

    static 
szMsg[191
    
vformat(szMsgcharsmax(szMsg), input3

    
replace_all(szMsg190"!g""^4"// green txt 
    
replace_all(szMsg190"!y""^1"// orange txt 
    
replace_all(szMsg190"!t""^3"// team txt 

    
if(idiPlayers[0] = id 
    
else get_players(iPlayersiCount"ch"

    for (new 
0iCounti++) 
    { 
        if (
is_user_connected(iPlayers[i])) 
        { 
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _iPlayers[i]) 
            
write_byte(iPlayers[i]) 
            
write_string(szMsg
            
message_end() 
        } 
    } 

__________________

Last edited by fysiks; 07-13-2010 at 17:16.
fysiks is offline
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 07:06.


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