首页 > 代码库 > 重设BOT名字

重设BOT名字

 1 /** 2  * 重设BOT名字 (ResetBotName) 3  * BotName.lst 中至少要有32个备用名字, 否则炸服 4  * 兵联互创|展鸿 编写 2015-1-10 5  */ 6  7 #include <amxmodx> 8  9 const MAX_NAME = 50;10 new g_szBotNames[MAX_NAME][64];11 new g_iCount = 1;12 13 public plugin_precache()14 {15     register_plugin("ResetBotName", "1.0", "SUIC");16     Load_Name();17 }18 19 stock Load_Name()20 {21     new hFile = fopen("addons/amxmodx/configs/BotName.lst", "rb");22     23     if(!hFile)24         return;25     26     new szData[64];27     28     while(!feof(hFile))29     {30         fgets(hFile, szData, charsmax(szData));31         trim(szData);32         33         if(!szData[0] || szData[0] == ; || szData[0] == /)34             continue;35         36         copy(g_szBotNames[g_iCount++], sizeof g_szBotNames[] - 1, szData);37     }38     39     fclose(hFile);40 }41 42 public client_putinserver(id)43 {44     if(!is_user_bot(id))45         return;46     47     new szName[64];48     49     do{50         GetRandomName(szName, charsmax(szName));51     }52     while(!CheckName(szName))53     54     set_user_info(id, "name", szName);55 }56 57 stock GetRandomName(szName[], iMax)58 {59     new iRandom = random_num(1, g_iCount - 1);60     format(szName, iMax, "%s", g_szBotNames[iRandom]);61 }62 63 stock CheckName(const szName[])64 {65     new szBuff[64];66     67     for(new id = 1; id <= 32; ++id)68     {69         if(!is_user_connected(id))70             continue;71         72         get_user_name(id, szBuff, charsmax(szBuff));73         if(equali(szName, szBuff))74             return false;75     }76     77     return true;78 }

 

重设BOT名字