本帖最后由 kk阿朗 于 2010-11-22 12:37 编辑
Spec Information -
- //#define DOD_STATS
- #include <amxmodx>
- #include <amxmisc>
- #include <nvault>
- #if defined DOD_STATS
- #include <dodstats>
- #else
- #include <csx>
- #endif
- #include <ipseeker>
- #define PLUGIN "Spec Information"
- #define VERSION "1.0"
- #define AUTHOR "K.K.Lv"
- new g_LevelNum
- new g_SyncObj
- new Array:g_LevelName
- new Array:g_LevelXp
- new g_pCvarXpos, g_pCvarYpos, g_pCvarOpColor, g_pCvarVipColor, g_pCvarUserColor, g_pCvarMsg, g_pCvarEffects
- new g_iSpecMode[33]
- new g_szSign[33][192]
- new g_iColor[3][3]
- new Float:g_fXpos, Float:g_fYpos
- public plugin_init() {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- g_LevelName = ArrayCreate(32)
- g_LevelXp = ArrayCreate(1, 1)
- g_pCvarXpos = register_cvar("amx_xpos", "0.55")
- g_pCvarYpos = register_cvar("amx_ypos", "0.66")
- g_pCvarOpColor = register_cvar("amx_opcolor", "250 250 250")
- g_pCvarVipColor = register_cvar("amx_vipcolor", "250 250 010")
- g_pCvarUserColor = register_cvar("amx_usercolor", "010 250 010")
- g_pCvarEffects = register_cvar("amx_effects", "0")
- g_pCvarMsg = register_cvar("amx_msg", "[%level%]Name:%name% - Flag:%flag% - Rank:%rank%\nCountry:%country% - Area:%area%\nSign:%sign%")
- g_fXpos = get_pcvar_float(g_pCvarXpos)
- g_fYpos = get_pcvar_float(g_pCvarYpos)
- g_SyncObj = CreateHudSyncObj()
- new szColor[3][12], szRGB[3][3][4]
- get_pcvar_string(g_pCvarOpColor, szColor[0], charsmax(szColor[]))
- get_pcvar_string(g_pCvarVipColor, szColor[1], charsmax(szColor[]))
- get_pcvar_string(g_pCvarUserColor, szColor[2], charsmax(szColor[]))
- for (new a = 0; a < 3; a++)
- {
- parse(szColor[a], szRGB[a][0], charsmax(szRGB[][]), szRGB[a][1], charsmax(szRGB[][]), szRGB[a][2], charsmax(szRGB[][]))
- g_iColor[a][0] = str_to_num(szRGB[a][0])
- g_iColor[a][1] = str_to_num(szRGB[a][1])
- g_iColor[a][2] = str_to_num(szRGB[a][2])
- }
- register_event("TextMsg", "eventSpecMode", "bd", "2&ec_Mod")
- register_event("StatusValue", "eventShowInfo", "bd", "1=2")
- register_clcmd("say", "hookSay")
- new szFileName[64]
- get_localinfo("amxx_configsdir", szFileName, charsmax(szFileName))
- format(szFileName, charsmax(szFileName), "%s/%s", szFileName, "rank_level.ini")
- if (!file_exists(szFileName))
- {
- pause("a")
- }
- load_settings(szFileName)
- }
- public eventSpecMode(id)
- {
- new szData[12]
- read_data(2, szData, charsmax(szData))
- g_iSpecMode[id] = (szData[10] == '4')
- return PLUGIN_CONTINUE
- }
- public eventShowInfo(id)
- {
- if (g_iSpecMode[id])
- {
- new iPlayer = read_data(2)
- if (is_user_connected(iPlayer))
- {
- new szName[32], szIp[16], szCountry[45], szArea[64], szMsg[512], iStats[8], iBody[8], szRank[5], iRank = get_user_stats(iPlayer, iStats, iBody)
- new iEffects = get_pcvar_num(g_pCvarEffects)
- get_pcvar_string(g_pCvarMsg, szMsg, charsmax(szMsg))
- get_user_name(iPlayer, szName, charsmax(szName))
- get_user_ip(iPlayer, szIp, charsmax(szIp))
- ipseeker2(szIp, szCountry, charsmax(szCountry), 1, szArea, charsmax(szArea), 1)
- num_to_str(iRank, szRank, charsmax(szRank))
- replace_all(szMsg, charsmax(szMsg), "\n", "^n")
- replace_all(szMsg, charsmax(szMsg), "%level%", get_levelname(iPlayer))
- replace_all(szMsg, charsmax(szMsg), "%name%", szName)
- replace_all(szMsg, charsmax(szMsg), "%rank%", szRank)
- replace_all(szMsg, charsmax(szMsg), "%country%", szCountry)
- replace_all(szMsg, charsmax(szMsg), "%area%", szArea)
- replace_all(szMsg, charsmax(szMsg), "%flag%", get_flagname(iPlayer))
- replace_all(szMsg, charsmax(szMsg), "%sign%", g_szSign[iPlayer])
-
- if (access(iPlayer, ADMIN_IMMUNITY))
- set_hudmessage(g_iColor[0][0], g_iColor[0][1], g_iColor[0][2], g_fXpos, g_fYpos, iEffects, _, _, _, _, _)
- else if (access(iPlayer, ADMIN_RESERVATION) && !access(iPlayer, ADMIN_IMMUNITY))
- set_hudmessage(g_iColor[1][0], g_iColor[1][1], g_iColor[1][2], g_fXpos, g_fYpos, iEffects, _, _, _, _, _)
- else set_hudmessage(g_iColor[2][0], g_iColor[2][1], g_iColor[2][2], g_fXpos, g_fYpos, iEffects, _, _, _, _, _)
-
- ShowSyncHudMsg(id, g_SyncObj, szMsg)
- }
- }
- }
- public hookSay(id)
- {
- new szChat[192], szName[32]
- read_args(szChat, charsmax(szChat))
- remove_quotes(szChat)
- get_user_name(id, szName, charsmax(szName))
- if (szChat[0] == '!' && szChat[1] == '+')
- {
- copy(g_szSign[id], charsmax(g_szSign[]), szChat[2])
- client_print(id, print_center, "%s", szChat[2])
- new iVault = nvault_open("sign")
- if (iVault == INVALID_HANDLE)
- set_fail_state("nValut return invalid handle.")
- nvault_set(iVault, szName, g_szSign[id])
- nvault_close(iVault)
- return PLUGIN_HANDLED
- }
- return PLUGIN_CONTINUE
- }
- public client_putinserver(id)
- {
- new szName[32], szSign[192], iVault = nvault_open("sign")
- if (is_user_connected(id))
- {
- get_user_name(id, szName, charsmax(szName))
-
- if (iVault == INVALID_HANDLE)
- set_fail_state("nValut return invalid handle.")
-
- if (nvault_get(iVault, szName, szSign, charsmax(szSign)))
- {
- copy(g_szSign[id], charsmax(g_szSign[]), szSign)
- }
- else copy(g_szSign[id], charsmax(g_szSign[]), "say !+your sign")
- }
- nvault_close(iVault)
- }
- public plugin_natives()
- {
- register_native("get_user_sign", "_get_user_sign")
- register_native("get_user_flagname", "_get_user_flagname")
- }
- public _get_user_sign(amx, param)
- {
- new id = get_param(1)
- if (g_szSign[id][0])
- {
- set_string(2, g_szSign[id], get_param(3))
- return 1
- }
- return 0
- }
- public _get_user_flagname(amx, param)
- {
- new id = get_param(1)
- new szFlagName[16]
- format(szFlagName, charsmax(szFlagName), "%s", get_flagname(id))
- if (szFlagName[0])
- {
- set_string(2, szFlagName, get_param(3))
- return 1
- }
- return 0
- }
- load_settings(const filename[])
- {
- new fp = fopen(filename, "rt")
- if (!fp)
- {
- return 0
- }
- new szText[256]
- new szLevelName[32], szLevelXp[6], iLevelXp
- while (!feof(fp))
- {
- fgets(fp, szText, charsmax(szText))
-
- if (szText[0] == ';' || (szText[0] == '/' && szText[1] == '/'))
- continue
- if (parse(szText, szLevelName, charsmax(szLevelName), szLevelXp, charsmax(szLevelXp)) < 1)
- continue
- iLevelXp = str_to_num(szLevelXp)
- ArrayPushString(g_LevelName, szLevelName)
- ArrayPushCell(g_LevelXp, iLevelXp)
-
- g_LevelNum++
- }
- server_print("%i", g_LevelNum)
- return 1
- }
- get_levelname(id)
- {
- new szLevelName[32], i, iLevel, iStats[8], iBody[8], iRank = get_user_stats(id, iStats, iBody)
- for (i = 0; i < g_LevelNum; i++)
- {
- iLevel = ArrayGetCell(g_LevelXp, i)
- if (iRank <= iLevel)
- {
- ArrayGetString(g_LevelName, i, szLevelName, charsmax(szLevelName))
- break
- }
- ArrayGetString(g_LevelName, i, szLevelName, charsmax(szLevelName))
- }
- return szLevelName
- }
- get_flagname(id)
- {
- new szFlagName[16]
- if (access(id, ADMIN_IMMUNITY))
- {
- copy(szFlagName, 5, "ADMIN")
- }
- else if (access(id, ADMIN_RESERVATION) && !access(id, ADMIN_IMMUNITY))
- {
- copy(szFlagName, 3, "VIP")
- }else copy(szFlagName, 4, "USER")
- return szFlagName
- }
复制代码这是个老插件了,之前点通有朋友写了,但是好像没源码! 所以昨天我自己尝试写了一个! 但是单机测试不出来,本想测试完才发出来的,现在只有靠感兴趣的朋友来帮忙测试一下了! 我只简单写了一些,要用的模块是 - #include <nvault>
- #include <csx>
- #include <ipseeker>
复制代码相信大家都有这些吧,所以我只把源码贴出来哈! 我还加了两个接口, -
- native get_user_sign(id, szSign[], len)
- native get_user_flagname(id, szFlagName[], lev)
复制代码分别是获取玩家个性签名,和获取玩家权限职称的! 难免有问题,希望大家积极反馈哈! 任何问题可以跟贴! 会尽力决哈! |