Page 1 of 1

Connect announce

Posted: 2015 Feb 04 19:10
by Igor
Norėjau paklausti, kaip padaryti kad žinutę rodytu vieną kartą žemėlapyje? Pvz žmogus prisijungia ir rodo iš kur jis yra jo steam ir pan.. Bet jei jis daro ištisai reconnect vėl rodo, gaunasi flood'as. Tad įdomu ar yra kažkokia kodo eilute o gal reikia kažką darašyti, padėkit. :)

Šaltinis: https://forums.alliedmods.net/showthread.php?t=19228
SMA:

Code: Select all

 #include <amxmodx> #define PLUGIN  "Connect Announce"#define VERSION "0.2"#define AUTHOR  "v3x" new g_iMsgSayText, g_szSoundFile[] = "buttons/blip1.wav"; public plugin_init(){    register_plugin(PLUGIN, VERSION, AUTHOR);    g_iMsgSayText = get_user_msgid("SayText");} public plugin_precache(){    precache_sound(g_szSoundFile);} public client_authorized(id){    if(is_user_bot(id)) return PLUGIN_CONTINUE;     new szUserName[33];    get_user_name(id, szUserName, 32);     new szAuthID[33];    get_user_authid(id , szAuthID , 32);     new iPlayers[32], iNum, i;    get_players(iPlayers, iNum);     for(i = 0; i <= iNum; i++)    {        new x = iPlayers[i];         if(!is_user_connected(x) || is_user_bot(x)) continue;         client_cmd(x, "spk %s", g_szSoundFile);         new szMessage[164];        format(szMessage, 163, "^x04%s (^x01%s^x04) connected", szUserName , szAuthID);         message_begin( MSG_ONE, g_iMsgSayText, {0,0,0}, x );        write_byte  ( x );        write_string( szMessage );        message_end ();    }     return PLUGIN_CONTINUE;}

Re: Connect announce

Posted: 2015 Feb 05 15:40
by ArtHa123

Code: Select all

#include <amxmodx> #define PLUGIN  "Connect Announce"#define VERSION "0.2"#define AUTHOR  "v3x" new g_iMsgSayText, g_szSoundFile[] = "buttons/blip1.wav"; new bool:g_first[33], ip[30]new Trie:has_connected public plugin_init(){    register_plugin(PLUGIN, VERSION, AUTHOR);    g_iMsgSayText = get_user_msgid("SayText");    has_connected = TrieCreate()} public plugin_precache(){    precache_sound(g_szSoundFile);} public client_authorized(id){    if(is_user_bot(id)) return PLUGIN_CONTINUE;     new szUserName[33];    get_user_name(id, szUserName, 32);     new szAuthID[33];    get_user_authid(id , szAuthID , 32);     new iPlayers[32], iNum, i;    get_players(iPlayers, iNum);     for(i = 0; i <= iNum; i++)    {        new x = iPlayers[i];         if(!g_first[x])        {            get_user_ip(x, ip, charsmax(ip), 1)            TrieSetCell(has_connected, ip, 1)                        if(!is_user_connected(x) || is_user_bot(x)) continue;                        client_cmd(x, "spk %s", g_szSoundFile);             new szMessage[164];            format(szMessage, 163, "^x04%s (^x01%s^x04) connected", szUserName , szAuthID);                        message_begin( MSG_ONE, g_iMsgSayText, {0,0,0}, x );            write_byte  ( x );            write_string( szMessage );            message_end ();            g_first[x] = true        }    }    return PLUGIN_CONTINUE;} public client_putinserver(id){    get_user_ip(id, ip, charsmax(ip), 1)     if(TrieKeyExists(has_connected, ip))    {        g_first[id] = true    }    else    {        g_first[id] = false    }}
Netestavau.

Re: Connect announce

Posted: 2015 Feb 06 11:00
by Igor
Kaip ir veikia, bet yra viena klaida, kaip pasikeičia žemėlapis jo neberodo chate kad prisijungė, bet kitam žaidėjui rodė. Kartais rodo kartais ne

Re: Connect announce

Posted: 2015 Feb 15 00:30
by aurimasko

Code: Select all

  #include <amxmodx>     #define PLUGIN  "Connect Announce"#define VERSION "0.2"#define AUTHOR  "v3x"     new g_iMsgSayText, g_szSoundFile[] = "buttons/blip1.wav" new Trie:has_connected     public plugin_init(){    register_plugin(PLUGIN, VERSION, AUTHOR)    g_iMsgSayText = get_user_msgid("SayText")    has_connected = TrieCreate()} public plugin_end()    TrieDestroy(has_connected)    public plugin_precache()    precache_sound(g_szSoundFile) public client_putinserver(id){        if(is_user_bot(id))            return PLUGIN_CONTINUE        new szIP[20];    get_user_ip(id, szIP, charsmax(szIP), 1)         if(!TrieKeyExists(has_connected, szIP))    {         new szUserName[33]        get_user_name(id, szUserName, 32)             new szAuthID[33]        get_user_authid(id , szAuthID , 32)             TrieSetCell(has_connected, szIP, 1)            client_cmd(0, "spk %s", g_szSoundFile)             new szMessage[164]        format(szMessage, 163, "^x04%s (^x01%s^x04) connected", szUserName , szAuthID)                       message_begin( MSG_ALL, g_iMsgSayText, {0,0,0}, 0)        write_byte  ( x )        write_string( szMessage )        message_end ()    }} 
Netestavau bet turėtų veikti.