自定义玩家信息
本帖最后由 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
new g_szSign
new g_iColor
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, szRGB
get_pcvar_string(g_pCvarOpColor, szColor, charsmax(szColor[]))
get_pcvar_string(g_pCvarVipColor, szColor, charsmax(szColor[]))
get_pcvar_string(g_pCvarUserColor, szColor, charsmax(szColor[]))
for (new a = 0; a < 3; a++)
{
parse(szColor, szRGB, charsmax(szRGB[][]), szRGB, charsmax(szRGB[][]), szRGB, charsmax(szRGB[][]))
g_iColor = str_to_num(szRGB)
g_iColor = str_to_num(szRGB)
g_iColor = str_to_num(szRGB)
}
register_event("TextMsg", "eventSpecMode", "bd", "2&ec_Mod")
register_event("StatusValue", "eventShowInfo", "bd", "1=2")
register_clcmd("say", "hookSay")
new szFileName
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
read_data(2, szData, charsmax(szData))
g_iSpecMode = (szData == '4')
return PLUGIN_CONTINUE
}
public eventShowInfo(id)
{
if (g_iSpecMode)
{
new iPlayer = read_data(2)
if (is_user_connected(iPlayer))
{
new szName, szIp, szCountry, szArea, szMsg, iStats, iBody, szRank, 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)
if (access(iPlayer, ADMIN_IMMUNITY))
set_hudmessage(g_iColor, g_iColor, g_iColor, g_fXpos, g_fYpos, iEffects, _, _, _, _, _)
else if (access(iPlayer, ADMIN_RESERVATION) && !access(iPlayer, ADMIN_IMMUNITY))
set_hudmessage(g_iColor, g_iColor, g_iColor, g_fXpos, g_fYpos, iEffects, _, _, _, _, _)
else set_hudmessage(g_iColor, g_iColor, g_iColor, g_fXpos, g_fYpos, iEffects, _, _, _, _, _)
ShowSyncHudMsg(id, g_SyncObj, szMsg)
}
}
}
public hookSay(id)
{
new szChat, szName
read_args(szChat, charsmax(szChat))
remove_quotes(szChat)
get_user_name(id, szName, charsmax(szName))
if (szChat == '!' && szChat == '+')
{
copy(g_szSign, charsmax(g_szSign[]), szChat)
client_print(id, print_center, "%s", szChat)
new iVault = nvault_open("sign")
if (iVault == INVALID_HANDLE)
set_fail_state("nValut return invalid handle.")
nvault_set(iVault, szName, g_szSign)
nvault_close(iVault)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public client_putinserver(id)
{
new szName, szSign, 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, charsmax(g_szSign[]), szSign)
}
else copy(g_szSign, 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)
{
set_string(2, g_szSign, get_param(3))
return 1
}
return 0
}
public _get_user_flagname(amx, param)
{
new id = get_param(1)
new szFlagName
format(szFlagName, charsmax(szFlagName), "%s", get_flagname(id))
if (szFlagName)
{
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
new szLevelName, szLevelXp, iLevelXp
while (!feof(fp))
{
fgets(fp, szText, charsmax(szText))
if (szText == ';' || (szText == '/' && szText == '/'))
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, i, iLevel, iStats, iBody, 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
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)
分别是获取玩家个性签名,和获取玩家权限职称的!难免有问题,希望大家积极反馈哈!任何问题可以跟贴!会尽力决哈! 先坐个沙发!! :lol支持! 由于发贴比较匆忙,把那个定义等级的内容忘了哈!
现在补充一下!rank_level.ini文件的内容如下,可以自行修改的!
我相信大家应该比较清楚了,我还是贴上来哈!"上将" "15"
"中将" "55"
"少将" "75"
"大校" "105"
"上校" "145"
"中校" "195"
"少校" "255"
"上尉" "325"
"中尉" "405"
"少尉" "495"
"六级士官" "595"
"五级士官" "705"
"四级士官" "825"
"三级士官" "955"
"二级士官" "1095"
"一级士官" "1245"
"上等兵" "1408"
"列兵" "1575"我主要的思路都是根据那个100%自定义军衔来写的,主要的核心是计算玩家的军衔!
其他的显示玩家金钱吖等等,就让有兴趣的朋友自动手加哈:)
之前那个插件是签名与显示信息分开为两个插件,我这里都合在一起了!
还有,这个代码原则上可以让你定义无数个等级,不过我想应该不用定义这么多个了!
就如上面这些我想就足够了哈! 看看先!好像不能在DOD上用 5# ghf
应该是可以的,把#include <csx>改成#include <dodstats>应该就可以了,,你可以自己试试,我没有DOD哈! kk顶你哈。。:) 顶。。。。。。 楼主,编译错误,如图:
本帖最后由 kk阿朗 于 2010-11-17 22:50 编辑
9# 银闪闪
估计你用的是老版本!
edit:AMXX 1.8.1