|
发表于 2007-12-20 21:52:31
|
显示全部楼层
|阅读模式
来自 中国–广东–深圳
首先不明白rulzy版主金钱无限插件里面为什么要跟MONEY_TIER 8000 进行对比判断,请知道
的解答一下
如果我用cs_set_user_money(killer,9000,1)是否就有问题?
另外:
我调用add_player_money(killer,money) 给玩家加钱,想加的钱在右下角显示(就像默认的是+300会显示出来绿色的,如果扣钱就是显示红色的)
插件是在金钱数最大16000的环境下运用,我只是想实现对这个事件的捕捉,可是加了钱,但是没有实事反应出来,请帮忙看看问题在哪里?
下面是初始化部分
register_event("Money","read_gmsg_Money","b")
register_cvar("amx_startmoney", "800")
register_cvar("amx_maxmoney", "16000")
gmsg_Money = get_user_msgid("Money")
[PHP]
#define MONEY_TIER 8000 // DON'T MESS WITH, Money total at which the plugin switches over keeping track of money
new money_total[33] // Keep track of peeps money if above MONEY_TIER
public client_connect(id){
money_total[id] = 0
//check_start_maxmoney()
return PLUGIN_CONTINUE
}
public client_putinserver(id)
{
set_cvar_num("mp_startmoney", 801)
check_start_maxmoney()
return PLUGIN_CONTINUE
}
public check_start_maxmoney()
{
g_maxmoney = get_cvar_num("amx_maxmoney")
if(g_maxmoney>16000) g_maxmoney = 16000
g_startmoney = get_cvar_num("amx_startmoney")
if(g_startmoney>g_maxmoney) g_startmoney = g_maxmoney
else if(g_startmoney<800) g_startmoney=800
set_cvar_num("amx_maxmoney", g_maxmoney)
set_cvar_num("amx_startmoney", g_startmoney)
}
public read_gmsg_Money(id)
{
check_start_maxmoney()
new current_total = read_data(1) //变化后当前真正的钱
new newmoney
if(current_total%5==1) //只有是CS给予玩家默认的第一局钱,其尾数才可能是1或6,游戏中真正加减钱都会是5的倍数
{
money_total[id] = 0
newmoney = g_startmoney
}else{
if(money_total[id]>MONEY_TIER)
newmoney = money_total[id] - MONEY_TIER + current_total
else if(money_total[id]%5==1)
newmoney = current_total+1
else
newmoney = current_total
}
native_cs_set_user_money2(id, newmoney, 1)
}
public native_cs_set_user_money2(id, money, flash)
{
if(!is_user_connected(id)) return
if(money>g_maxmoney)
money=g_maxmoney
else if(money<0)
money = 0
if(money>MONEY_TIER){
cs_set_user_money(id, MONEY_TIER, 0) //设置玩家可用钱为MONEY_TIER
message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id)
write_long(money_total[id])
write_byte(0)
message_end()
message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id)
write_long(money)
write_byte(flash)
message_end()
}
else if(money%5==1){
cs_set_user_money(id, money-1, 0)
message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id)
write_long(money_total[id])
write_byte(0)
message_end()
message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id)
write_long(money)
write_byte(flash)
message_end()
}
else cs_set_user_money(id, money, flash)
money_total[id] = money
}
public native_cs_get_user_money2(id)
{
return money_total[id]
}
public add_player_money(player, addmoney)
{
check_start_maxmoney()
new newmoney = money_total[player] + addmoney
native_cs_set_user_money2(player, newmoney, 1)
}
[/PHP] |
|