搜索
查看: 5724|回复: 9

捡钱和掉钱音效有源码谁帮我编译一下

[复制链接]
发表于 2007-9-20 12:27:43 | 显示全部楼层 |阅读模式 来自 中国–浙江–湖州
捡钱和掉钱音效有源码谁帮我编译一下
 楼主| 发表于 2007-9-20 12:29:46 | 显示全部楼层 来自 中国–浙江–湖州

捡钱和掉钱音效有源码谁帮我编译一下

捡钱和掉钱音效有源码谁帮我编译一下
回复

使用道具 举报

 楼主| 发表于 2007-9-20 13:08:44 | 显示全部楼层 来自 中国–浙江–湖州

回复: 捡钱和掉钱音效有源码谁帮我编译一下

/* AMX Mod X
参数及命令介绍:
amx_maxmoney <300000>
    设置可以达到的最大金钱数, n≥16000(如果小于,自动设为16000),默认 300000
    最好不要超过999999,因为如果为7位数,则最后一位数根本就看不到
    注意:其个位数不能为1或6,如果是1或6,会自动减1(是为了保证插件正常工作)
amx_startmoney <n>
    开始金钱数,≥800(如果小于,自动设为800),且个位数不能为1或6,如果是1或6,会自动减1,默认 800
amx_mindropmoney <10000>
  玩家的钱大于等于此值才会掉钱, 默认 10000
  最小取值 1000
amx_dropmoney <16000>
  玩家的钱大于等于值此值肯定会掉钱,默认 100000
  最小取值 不小于 amx_mindropmoney
amx_savespecmoney <1|0>
  玩家转为观察员后是否保留他的金钱,默认 0 (CS默认也是不保存的)
   
amx_givemoneymenu
    打开发钱菜单(已经绑定到J键)
   
axm_setmoneynum <num1> [num2]...[num9]
    设置发钱菜单中的发钱数目
amx_addmoney <#t|#ct|name|#userid> <money>
    给所有土匪或警察或指定玩家加钱或扣钱
*/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#define MONEY_TIER 8000
#define MAX_DROPED_MONEY_COUNT 100
//Money事件msgid
new gmsg_Money
//开始金额和最大金额
new g_startmoney, g_maxmoney
new droped_money_count, g_roundcount
new g_NewRound = 0
new g_MoneyMenuBody[512]
new g_Money[9] = {3000, 5000, 10000, 20000, 30000,...}
new g_keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_0
new g_MoneyCount = 5
new g_MoneyModel[3][]={
"models/money/money1.mdl",
"models/money/money2.mdl",
"models/money/money3.mdl"
}
new total_money[33], g_specmoney[33]
public plugin_init() {
register_plugin("Unlimited Money", "1.0", "Rulzy")
register_dictionary("common.txt")
register_event("Money","read_gmsg_Money","b")
register_event("DeathMsg","eDeathMsg","a")
register_cvar("amx_startmoney", "800")
register_cvar("amx_maxmoney", "300000")
register_cvar("amx_mindropmoney","10000")
register_cvar("amx_dropmoney","100000")
register_cvar("amx_savespecmoney","0")
register_event("TextMsg", "eRestart", "ac", "2&#Game_Commencing", "2&#Game_will_restart")
register_event("HLTV", "eNewRound", "a", "1=0", "2=0")
register_logevent("eRoundStart", 2, "0=World triggered", "1=Round_Start")
register_logevent("eEndRound", 2, "0=World triggered", "1=Round_End")
register_logevent("team_join",3,"1=joined team","2=TERRORIST","2=CT","2=SPECTATOR")
register_touch("MoneyEnt", "player", "money_touch")
gmsg_Money = get_user_msgid("Money")
register_concmd("axm_setmoneynum" , "cmdSetMoneyNum", ADMIN_LEVEL_A, "<num1> [num2]...[num9]")
register_clcmd("amx_givemoneymenu", "cmdGiveMoneyMenu")
register_menucmd(register_menuid("Give Money"), 1023, "ActionMoneyMenu")
register_concmd("amx_addmoney", "cmdAddmoney", ADMIN_LEVEL_A, "<#t|#ct|name|#userid> <money>")
g_keys = 0
new iLen = format(g_MoneyMenuBody, 511, "\y你想发多少钱?\w^n^n");
for(new i=0;i<g_MoneyCount;i++)
{
  iLen += format(g_MoneyMenuBody[iLen], 511-iLen, "%d. %d^n", i+1, g_Money)
  g_keys |= 1<<i
}
for(new i=g_MoneyCount;i<9;i++)
  g_Money = 0
format(g_MoneyMenuBody[iLen], 511-iLen, "^n0. 退出")
g_keys |= MENU_KEY_0
}
public plugin_precache()
{
precache_model(g_MoneyModel[0])
precache_model(g_MoneyModel[1])
precache_model(g_MoneyModel[2])
}
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的倍数
{
  total_money[id] = 0
  newmoney = g_startmoney
}else{
  if(total_money[id]>MONEY_TIER)
   newmoney = total_money[id] - MONEY_TIER + current_total
  else if(total_money[id]%5==1)
   newmoney = current_total+1
  else
   newmoney = current_total
}
native_cs_set_user_money2(id, newmoney, 1)
}
public plugin_natives()
{
register_native("cs_set_user_money2", "native_cs_set_user_money2", 1)
register_native("cs_get_user_money2", "native_cs_get_user_money2", 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(total_money[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(total_money[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)
}
total_money[id] = money
}
public native_cs_get_user_money2(id)
{
return total_money[id]
}
public add_player_money(player, addmoney)
{
check_start_maxmoney()
new newmoney = total_money[player] + addmoney
native_cs_set_user_money2(player, newmoney, 1)
}
public cmdSetMoneyNum(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
  return PLUGIN_HANDLED
new argv[13]
g_MoneyCount = read_argc() - 1
if(g_MoneyCount>9) g_MoneyCount = 9
g_keys = 0
new iLen = format(g_MoneyMenuBody, 511, "\y你想发多少钱?\w^n^n");
for(new i=0;i<g_MoneyCount;i++)
{
  read_argv(i+1, argv, 12)
  g_Money = str_to_num(argv)
  iLen += format(g_MoneyMenuBody[iLen], 511-iLen, "%d. %d^n", i+1, g_Money)
  g_keys |= 1<<i
}
for(new i=g_MoneyCount;i<9;i++)
  g_Money = 0
format(g_MoneyMenuBody[iLen], 511-iLen, "^n0. 退出")
g_keys |= MENU_KEY_0
return PLUGIN_HANDLED
}
public ActionMoneyMenu(id, key)
{
if(key!=9)
{
  GiveMoney(id, g_Money[key])
  show_menu(id, g_keys, g_MoneyMenuBody, -1, "Give Money")
}
}
public cmdGiveMoneyMenu(id)
{
show_menu(id, g_keys, g_MoneyMenuBody, -1, "Give Money")
return PLUGIN_HANDLED
}
public GiveMoney(id, money)
{
if(!is_user_alive(id))
{
  client_print(id, print_chat, "对不起,只有活着的玩家才能发钱")
  return
}
if(total_money[id]<money)
{
  client_print(id, print_chat, "对不起,你的金钱不足 %d", money)
  return
}
if(droped_money_count>=MAX_DROPED_MONEY_COUNT)
{
  client_print(id, print_chat, "对不起,已经达到最大发钱掉钱金钱数量")
  return
}
droped_money_count++
new Float:origin[3], Float:uservelocity[3], Float:velocity[3]
entity_get_vector(id, EV_VEC_origin, origin)
entity_get_vector(id, EV_VEC_velocity, uservelocity)
velocity_by_aim(id, 450, velocity)
velocity[0] += uservelocity[0]
velocity[1] += uservelocity[1]
velocity[2] = 0.0
//使发出的钱适当分散
velocity[0]+=random_float(-100.0,100.0)
velocity[1]+=random_float(-100.0,100.0)
new gEnt = create_entity("info_target")
entity_set_string(gEnt, EV_SZ_classname, "MoneyEnt")
entity_set_origin(gEnt,origin)
entity_set_int(gEnt, EV_INT_solid, SOLID_TRIGGER)
entity_set_int(gEnt, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_vector(gEnt, EV_VEC_velocity, velocity)
entity_set_int(gEnt, EV_INT_iuser1, g_roundcount) //哪局发的钱
entity_set_int(gEnt, EV_INT_iuser2, money)//玩家可以捡到的钱数
entity_set_edict(gEnt, EV_ENT_owner, id) //谁发的钱
entity_set_float(gEnt, EV_FL_fuser1, get_gametime())//发钱的时间
if(money<5000)
  entity_set_model(gEnt, g_MoneyModel[2])
else if(money<30000)
  entity_set_model(gEnt, g_MoneyModel[1])
else
  entity_set_model(gEnt, g_MoneyModel[0])

new iOrigin[3]
FVecIVec(origin, iOrigin)
new param[4]
param[0] = gEnt
param[1] = iOrigin[0]
param[2] = iOrigin[1]
param[3] = iOrigin[2]
set_task(0.2, "reset_size", 0, param, 4)

add_player_money(id, -money)
        client_cmd(0,"spk misc/dropmoney")
new msg[256], name[32]
get_user_name(id, name, 31)
format(msg, 255, "^x03%s^x01 发了 ^x04%d^x01 金钱", name, money)
client_color(0, id, msg)
}
public reset_size(param[])
{
new gEnt = param[0]
if(!is_valid_ent(gEnt)) return
new oldOrigin[3], Float: newOrigin[3], inewOrigin[3]
oldOrigin[0] = param[1]
oldOrigin[1] = param[2]
oldOrigin[2] = param[3]
entity_get_vector(gEnt, EV_VEC_origin, newOrigin)
FVecIVec(newOrigin, inewOrigin)
if(get_distance(oldOrigin, inewOrigin)>0){
  param[0] = gEnt
  param[1] = inewOrigin[0]
  param[2] = inewOrigin[1]
  param[3] = inewOrigin[2]
  set_task(0.2, "reset_size", 0, param, 4)
}else{
  new Float:maxbox[3] = {15.0, 15.0, 15.0}, Float:minbox[3] = {-15.0, -15.0, -15.0}
  entity_set_size(gEnt, minbox, maxbox)
}
}
public money_touch(ptr, ptd)
{        
if (is_user_alive(ptd)&&(total_money[ptd]<g_maxmoney))
{
  new owner = entity_get_edict(ptr, EV_ENT_owner)
  new Float:droptime = entity_get_float(ptr, EV_FL_fuser1)
  if(owner==ptd && get_gametime()-droptime<0.3) return
  new money = entity_get_int(ptr, EV_INT_iuser2)
  new oldmoney = total_money[ptd]
  add_player_money(ptd, money)
                client_cmd(ptd,"spk misc/getmoney")
  new usergetmoney = total_money[ptd] - oldmoney
  if(usergetmoney>99){  //玩家可以捡的钱数太少就不提示了
   new name[32]
   get_user_name(ptd, name, 31)
   new msg[256]
   format(msg, 255, "^x03%s^x01 捡到 ^x04%d^x01 金钱", name, usergetmoney)
   client_color(0, ptd, msg)
  }
  new leftmoney = money-usergetmoney
  if(leftmoney<100)  //剩余钱数少于100
  {
   remove_entity(ptr)
   droped_money_count--
  }else{
   entity_set_int(ptr, EV_INT_iuser2, leftmoney)
   if(leftmoney<5000)
    entity_set_model(ptr, g_MoneyModel[2])
   else if(leftmoney<30000)
    entity_set_model(ptr, g_MoneyModel[1])
   else
    entity_set_model(ptr, g_MoneyModel[0])
   new Float:maxbox[3] = {15.0, 15.0, 15.0}, Float:minbox[3] = {-15.0, -15.0, -15.0}
   entity_set_size(ptr, minbox, maxbox)
  }
}
}
public client_color(playerid,colorid,msg[])
{
message_begin(playerid?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, playerid)
write_byte(colorid)
write_string(msg)
message_end()
}
public bind_key(id)
{
client_cmd(id, "bind j amx_givemoneymenu")
client_color(id, id, "^x04【提示】^x01按 ^x04J^x01 键打开发钱菜单")
}
public client_putinserver(id)
{
set_cvar_num("mp_startmoney", 801)
check_start_maxmoney()
set_task(5.0, "bind_key", id)
return PLUGIN_CONTINUE
}
public team_join()
{
check_start_maxmoney()
new user[128]
read_logargv(0, user, 127)
new name[32], oldteam[12]={0}
parse_loguser(user, name, 31, _, _, _, oldteam, 11)

new id = get_user_index(name)

new newteam[16]
read_logargv(2,newteam, 15)
new savespecmoney = get_cvar_num("amx_savespecmoney")
if(equal(newteam,"SPECTATOR")) //加入观察员
{
  if(oldteam[0]) //从T或CT加入观察员
  {
   if(savespecmoney)
    g_specmoney[id] = total_money[id]
   else
    g_specmoney[id] = g_startmoney
  }else{  //进入服务器就加入观察员
   g_specmoney[id] = g_startmoney
  }
}else{  //加入T队伍或CT队伍
  if(oldteam[0]==0)  //连接到服务器就加入T或CT
  {
   total_money[id] = 0
   native_cs_set_user_money2(id, g_startmoney, 1)
  }else if(equal(oldteam,"SPECTATOR")){  //从观察员加入T或CT
   if(savespecmoney)
   {
    total_money[id] = 0
    native_cs_set_user_money2(id, g_specmoney[id], 1)
   }else{
    total_money[id] = 0
    native_cs_set_user_money2(id, g_startmoney, 1)
   }
  }
}
}
public eRestart()
{
g_roundcount = 0
check_start_maxmoney()
}
public eNewRound()
{
g_NewRound = 1
g_roundcount++
new gEnt = -1
while ((gEnt = find_ent_by_class(gEnt, "MoneyEnt"))!=0)
{
  if(g_roundcount-entity_get_int(gEnt, EV_INT_iuser1)>3||g_roundcount==1)
  {
   remove_entity(gEnt)
   droped_money_count--
  }
}
}
public eRoundStart()
{
if(!g_NewRound) eNewRound()
}
public eEndRound()
{
g_NewRound = 0
}
public random_drop_money(ori_ammount){
  new drop_control
  new mindropmoney = get_cvar_num("amx_mindropmoney")
  if(mindropmoney<1000)
  {
   mindropmoney = 1000
   set_cvar_num("amx_mindropmoney", 1000)
  }
  if(ori_ammount>=mindropmoney)
  {
   new dropmoney = get_cvar_num("amx_dropmoney")
   if(dropmoney<mindropmoney+1000)
   {
    dropmoney = mindropmoney
    set_cvar_num("amx_dropmoney", dropmoney)
   }
   drop_control=random_num(0, dropmoney)
   if(ori_ammount>=drop_control)
    return random_num(3,7)*random_num(4,8)*random_num(5,10)
   else
    return 0
  }
  return 0
}
public eDeathMsg(){
new killer,victim
killer=read_data(1)
if(!killer) return PLUGIN_CONTINUE
victim=read_data(2)
if(get_user_team(killer)==get_user_team(victim)) return PLUGIN_CONTINUE
//被杀者将会掉一些钱
new victim_money = total_money[victim]
if(droped_money_count<MAX_DROPED_MONEY_COUNT)
{
  new drop_prec = random_drop_money(victim_money)
  if(drop_prec>0){
   new droped_money = victim_money*drop_prec/1000
   new money = droped_money*80/100
   add_player_money(victim,-droped_money)
   new Float:victim_coord[3]
   entity_get_vector(victim, EV_VEC_origin, victim_coord)
   droped_money_count++
   new gEnt = create_entity("info_target")
   entity_set_string(gEnt, EV_SZ_classname, "MoneyEnt")
   entity_set_origin(gEnt, victim_coord)
   entity_set_int(gEnt, EV_INT_solid, SOLID_TRIGGER)
   entity_set_int(gEnt, EV_INT_movetype, MOVETYPE_TOSS)
   entity_set_int(gEnt, EV_INT_iuser1, g_roundcount) //哪局掉的钱
   entity_set_int(gEnt, EV_INT_iuser2, money)//玩家可以捡到的钱数
   entity_set_edict(gEnt, EV_ENT_owner, victim) //谁掉的钱
   entity_set_float(gEnt, EV_FL_fuser1, get_gametime())//掉钱的时间
   if(money<5000)
    entity_set_model(gEnt, g_MoneyModel[2])
   else if(money<30000)
    entity_set_model(gEnt, g_MoneyModel[1])
   else
    entity_set_model(gEnt, g_MoneyModel[0])
   
   new iOrigin[3]
   FVecIVec(victim_coord, iOrigin)
   new param[4]
   param[0] = gEnt
   param[1] = iOrigin[0]
   param[2] = iOrigin[1]
   param[3] = iOrigin[2]
   set_task(0.2, "reset_size", 0, param, 4)
   new victimname[32]
   get_user_name(victim,victimname,31)
   new msg[100]
   format(msg,99,"^x03%s^x01 掉了 ^x04%d^x01 金钱",victimname,droped_money)
   client_color(0,victim,msg)
  }
}
return PLUGIN_CONTINUE
}
public cmdAddmoney(id, level, cid)
{
if(!cmd_access(id, level, cid, 3))
  return PLUGIN_HANDLED

new target[32], smoney[14], money, maxplayers
read_argv(1, target, 31)
read_argv(2, smoney, 13)
money = str_to_num(smoney)
if(money==0) return PLUGIN_HANDLED
maxplayers = get_maxplayers()
new team = 0
if(equali(target, "#t"))
  team = 1
else if(equali(target, "#ct"))
  team = 2
new name[32]
get_user_name(id, name, 31)
if(team>0){
  new teamplayercount = 0
  for(new i=1;i<=maxplayers;i++){
   if(!is_user_connected(i)) continue
   if(get_user_team(i)==team){
    add_player_money(i, money)
    teamplayercount++
   }
  }
  if(teamplayercount>0){
   switch (get_cvar_num("amx_show_activity"))
   {
    case 2: client_print(0, print_chat, "管理员 %s: 给所有%s%s %d 金钱", name, (team==1)?"恐怖分子":"警察", (money>0)?"加":"扣除", abs(money))
    case 1: client_print(0, print_chat, "管理员: 给所有%s%s %d 金钱", (team==1)?"恐怖分子":"警察", (money>0)?"加":"扣除", abs(money))
   }
  }
  return PLUGIN_HANDLED
}
new player = cmd_target(id, target, 2)
if(!player) return PLUGIN_HANDLED
add_player_money(player, money)
new playername[32]
get_user_name(player, playername, 31)
switch (get_cvar_num("amx_show_activity"))
{
  case 2: client_print(0, print_chat, "管理员 %s: 给 %s %s %d 金钱", name, playername, (money>0)?"加":"扣除", abs(money))
  case 1: client_print(0, print_chat, "管理员: 给 %s %s %d 金钱", playername, (money>0)?"加":"扣除", abs(money))
}
return PLUGIN_HANDLED
}
/* UTF-8 func by www.DT-Club.net */
回复

使用道具 举报

发表于 2007-9-25 10:07:01 | 显示全部楼层 来自 中国–江西–新余

回复: 捡钱和掉钱音效有源码谁帮我编译一下

两个音效..解压后放入cstrike\sound\misc里..

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
回复

使用道具 举报

发表于 2007-11-27 03:38:04 | 显示全部楼层 来自 中国–云南–西双版纳傣族自治州–景洪市

回复: 捡钱和掉钱音效有源码谁帮我编译一下

发钱声音代码没写对.发钱声音应该使用emit_sound来写队伍才听得到,而不是client_cmd不然所有人都听得见.
回复

使用道具 举报

发表于 2007-11-27 10:10:33 | 显示全部楼层 来自 中国–广东–深圳

回复: 捡钱和掉钱音效有源码谁帮我编译一下

Post by zhangsheng
发钱声音代码没写对.发钱声音应该使用emit_sound来写队伍才听得到,而不是client_cmd不然所有人都听得见.

学习中..............:super:
回复

使用道具 举报

发表于 2007-11-27 17:52:28 | 显示全部楼层 来自 中国–江西

回复: 捡钱和掉钱音效有源码谁帮我编译一下

多谢战神大大指点..
- -||
改代码技术方面刚学...(业余时间改着玩)
当初也是好玩接触着用的..有些函数研究少不太会运用的说..
回复

使用道具 举报

发表于 2007-12-19 20:56:15 | 显示全部楼层 来自 中国–广东–深圳

回复: 捡钱和掉钱音效有源码谁帮我编译一下

Post by zhangsheng
发钱声音代码没写对.发钱声音应该使用emit_sound来写队伍才听得到,而不是client_cmd不然所有人都听得见.

哈哈,我不知道用这个,所以用下面的实现的


new msg[256], name[32]
get_user_name(id, name, 31)
format(msg, 255, "^x03%s^x01 发了 ^x04%d^x01 金钱", name, money)
for(new idtemp = 1; idtemp <= g_maxplayers; idtemp++)
{
  if(is_user_connected(idtemp) && cs_get_user_team(idtemp) == cs_get_user_team(id))
  {
   client_cmd(idtemp,"spk /misc/dropmoney")   
   client_color(idtemp, id, msg)
  }
}
回复

使用道具 举报

发表于 2007-12-20 12:38:48 | 显示全部楼层 来自 中国–广东–佛山–三水区

回复: 捡钱和掉钱音效有源码谁帮我编译一下

Post by Cr@zyTreE
哈哈,我不知道用这个,所以用下面的实现的


new msg[256], name[32]
get_user_name(id, name, 31)
format(msg, 255, "^x03%s^x01 发了 ^x04%d^x01 金钱", name, money)
for(new idtemp = 1; idtemp <= g_maxplayers; idtemp++)
{
if(is_user_connected(idtemp) && cs_get_user_team(idtemp) == cs_get_user_team(id)...
用法...........
Post by zhangsheng
在include函数表的amxconst.inc函数中出现过.
里面有调用方法的
/* Constants for emit_sound() */
/* Channels */
#define CHAN_AUTO        0
#define CHAN_WEAPON        1
#define    CHAN_VOICE        2
#define CHAN_ITEM        3
#define    CHAN_BODY        4
#define CHAN_STREAM        5    /* allocate stream channel from the static or dynamic area */
#defin...
回复

使用道具 举报

发表于 2011-4-13 15:00:29 | 显示全部楼层 来自 中国–广东–广州–番禺区
学习一下!
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表