如何分离无限金钱函数?上限16000就行了 有代码
本帖最后由 eason39 于 2009-5-27 09:21 编辑#include <amxmodx>
#include <unlimited_money>
#define MAX_NAME_LENGTH 32
#define MAX_TEXT_LENGTH 512
#define ACCESS_LEVEL ADMIN_LEVEL_A
// Default on/off
new gBonusMode = 1
new bool:gRoundStart
new gBonusCount = 0
//new gBonusIndex = { 5000,4000,3000,2000,1000 }
// 用于不需要重复定义(临时)
new _tmpStr
public admin_bonuskill(id)
{
// Check access level
if (!(get_user_flags(id)&ACCESS_LEVEL)) {
console_print(id,"[注意] 你没有权限使用这个命令!")
return PLUGIN_HANDLED
}
// Check arguments
if (read_argc() < 2) {
console_print(id,"[注意] 使用格式为: money_bonus < 1 | 0 >")
return PLUGIN_HANDLED
}
new sArg1
read_argv(1,sArg1,MAX_NAME_LENGTH)
if (str_to_num(sArg1)) {
gBonusMode = 1
client_print(id,print_chat," 前五名杀人奖励插件已启用.")
}
else {
gBonusMode = 0
client_print(id,print_chat," 前五名杀人奖励插件已关闭.")
}
return PLUGIN_HANDLED
}
public event_death()
{
if (gBonusMode && gRoundStart) {
new iKiller = read_data(1)
new iVictim = read_data(2)
new sMsg
new sName
new addmoney=random_num(50,10000)
get_user_name(iKiller,sName,MAX_NAME_LENGTH)
if ((iKiller != iVictim) && (gBonusCount < 5) && (get_user_team(iKiller) != get_user_team(iVictim))) {
gBonusCount++
cs_set_user_money2(iKiller,cs_get_user_money2(iKiller)+addmoney)
if (gBonusCount == 2) {
//format(sMsg,MAX_TEXT_LENGTH,"%s 第2个杀人! 奖励$%i金钱 ",sName,gBonusIndex)
format(_tmpStr, 255, "^x03%s^x04 第2个杀人!奖励$%i金钱",sName,addmoney)
client_cmd(0, "spk misc/coin2.wav")
//set_hudmessage(0,255,0,-1.58,0.18,0,6.0,6.0,0.5,0.5,158)
_showChatGreenMsg(iKiller, _tmpStr)
}
else if (gBonusCount == 3) {
//format(sMsg,MAX_TEXT_LENGTH,"%s 第3个杀人! 奖励$%i金钱 ",sName,gBonusIndex)
format(_tmpStr, 255, "^x03%s^x04 第3个杀人!奖励$%i金钱",sName,addmoney)
client_cmd(0, "spk misc/coin2.wav")
//set_hudmessage(255, 0, 255,-1.58,0.26,0,6.0,6.0,0.5,0.5,157)
_showChatGreenMsg(iKiller, _tmpStr)
}
else if (gBonusCount == 4) {
//format(sMsg,MAX_TEXT_LENGTH,"%s 第4个杀人! 奖励$%i金钱 ",sName,gBonusIndex)
format(_tmpStr, 255, "^x03%s^x04 第4个杀人!奖励$%i金钱",sName,addmoney)
client_cmd(0, "spk misc/coin2.wav")
//set_hudmessage(255, 242, 0,-1.58,0.34,0,6.0,6.0,0.5,0.5,156)
_showChatGreenMsg(iKiller, _tmpStr)
}
else if (gBonusCount == 5) {
//format(sMsg,MAX_TEXT_LENGTH,"%s 第5个杀人! 奖励$%i金钱 ",sName,gBonusCount,gBonusIndex)
format(_tmpStr, 255, "^x03%s^x04 第5个杀人!奖励$%i金钱",sName,addmoney)
client_cmd(0, "spk misc/coin2.wav")
//set_hudmessage(0,100,255,-1.58,0.42,0,6.0,6.0,0.5,0.5,150)
_showChatGreenMsg(iKiller, _tmpStr)
}
//display_msg(sMsg,200,200,200)
show_hudmessage(0,sMsg)
}
}
return PLUGIN_CONTINUE
}
public event_round_end() {
gRoundStart = false
gBonusCount = 0
}
public round_start() { //增加行
gRoundStart = true //增加行
} //增加行
//public display_msg(msg[],r,g,b)
//{
//set_hudmessage(r,g,b,-1.0,0.40,0,6.0,6.0,0.5,0.15,2)
//set_hudmessage(random_num(0,255),random_num(0,255),random_num(0,255),-1.0,0.80,2,0.3,6.0,0.03,2.0,153)
//show_hudmessage(0,msg)
//}
// 显示(Green)颜色的聊天信息
public _showChatGreenMsg(id, msg) {
format(msg, 255, "^x01^x04%s^x01", msg)
new g_msgSayText = get_user_msgid("SayText")
message_begin(MSG_ALL,g_msgSayText, {0,0,0}, id)
write_byte(id)
write_string(msg)
message_end()
}
/************************************************************
* PLUGIN FUNCTIONS
************************************************************/
public plugin_init()
{
register_plugin("Plugin Money Bonus","1.0","DreamZSW")
register_event("DeathMsg","event_death","a")
register_event("SendAudio","event_round_end","a","2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
register_event("HLTV", "round_start", "a", "1=0", "2=0")
register_concmd("money_bonus","admin_bonuskill",ACCESS_LEVEL,"amx_powers < authid | part of nick >")
}
public plugin_precache()
{
precache_sound("misc/coin2.wav")
}次插件是下载到zhangsheng的,装这插件必须要金钱无上限插件,我不想用无限金钱插件,太多钱了,能不能分离出来? 把 #include <unlimited_money> 这行替换成 #include <cstrike>,把所有cs_set_user_money2替换为cs_set_user_money,把所有cs_get_user_money2替换为cs_get_user_money。 谢谢R版但还有个问题,上面代码是在聊天频道显示奖励信息的,但是按照你说的方法已经可以正常使用了,但有聊天频道还是没有奖励信息出现 空空的 但钱已经奖励了 受教了,谢谢R版主 注意下件源码的编码是否UTF8无编码,否则编译出的插件中文会变乱码
页:
[1]