捡钱的声效怎么添加?
捡钱的声效怎么添加?我用的是 giveoutmoney.amxx ;掉钱与捡钱插件请高手教教我,万分感激!!!
回复: 捡钱的声效怎么添加?
修改两处add_player_money(id, -money)
client_cmd(0,"spk misc/dropmoney") //增加行
new msg, name
get_user_name(id, name, 31)
format(msg, 255, "^x03%s^x01 发了 ^x04%d^x01 金钱", name, money)
client_color(0, id, msg
new oldmoney = total_money
add_player_money(ptd, money)
client_cmd(ptd,"spk misc/getmoney") //增加行
new usergetmoney = total_money - oldmoney
if(usergetmoney>99){//玩家可以捡的钱数太少就不提示了
public plugin_precache()
{
precache_model(g_MoneyModel)
precache_model(g_MoneyModel)
precache_model(g_MoneyModel)
precache_sound( "misc/dropmoney.wav")
precache_sound( "misc/getmoney.wav")
}
红色部份是加进去的代码.
请自行对比.
回复: 捡钱的声效怎么添加?
掉钱的声音我只能修改到让所有人听到,如果要改成同一队伍的才可以听到还是亲自请教Rulzy老大吧.我有源文件谁帮我编译成amxx
/*参数及命令介绍:
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> ...
设置发钱菜单中的发钱数目
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
new g_Money = {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[]={
"models/money/money1.mdl",
"models/money/money2.mdl",
"models/money/money3.mdl"
}
new total_money, g_specmoney
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> ...")
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, 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, 511-iLen, "^n0. 退出")
g_keys |= MENU_KEY_0
}
public plugin_precache()
{
precache_model(g_MoneyModel)
precache_model(g_MoneyModel)
precache_model(g_MoneyModel)
}
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 = 0
newmoney = g_startmoney
}else{
if(total_money>MONEY_TIER)
newmoney = total_money - MONEY_TIER + current_total
else if(total_money%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)
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)
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 = money
}
public native_cs_get_user_money2(id)
{
return total_money
}
public add_player_money(player, addmoney)
{
check_start_maxmoney()
new newmoney = total_money + 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
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, 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, 511-iLen, "^n0. 退出")
g_keys |= MENU_KEY_0
return PLUGIN_HANDLED
}
public ActionMoneyMenu(id, key)
{
if(key!=9)
{
GiveMoney(id, g_Money)
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<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, Float:uservelocity, Float:velocity
entity_get_vector(id, EV_VEC_origin, origin)
entity_get_vector(id, EV_VEC_velocity, uservelocity)
velocity_by_aim(id, 450, velocity)
velocity += uservelocity
velocity += uservelocity
velocity = 0.0
//使发出的钱适当分散
velocity+=random_float(-100.0,100.0)
velocity+=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)
else if(money<30000)
entity_set_model(gEnt, g_MoneyModel)
else
entity_set_model(gEnt, g_MoneyModel)
new iOrigin
FVecIVec(origin, iOrigin)
new param
param = gEnt
param = iOrigin
param = iOrigin
param = iOrigin
set_task(0.2, "reset_size", 0, param, 4)
add_player_money(id, -money)
client_cmd(0,"spk misc/dropmoney.mp3")
new msg, name
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
if(!is_valid_ent(gEnt)) return
new oldOrigin, Float: newOrigin, inewOrigin
oldOrigin = param
oldOrigin = param
oldOrigin = param
entity_get_vector(gEnt, EV_VEC_origin, newOrigin)
FVecIVec(newOrigin, inewOrigin)
if(get_distance(oldOrigin, inewOrigin)>0){
param = gEnt
param = inewOrigin
param = inewOrigin
param = inewOrigin
set_task(0.2, "reset_size", 0, param, 4)
}else{
new Float:maxbox = {15.0, 15.0, 15.0}, Float:minbox = {-15.0, -15.0, -15.0}
entity_set_size(gEnt, minbox, maxbox)
}
}
public money_touch(ptr, ptd)
{
if (is_user_alive(ptd)&&(total_money<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
add_player_money(ptd, money)
client_cmd(ptd,"spk misc/getmoney.mp3")
new usergetmoney = total_money - oldmoney
if(usergetmoney>99){//玩家可以捡的钱数太少就不提示了
new name
get_user_name(ptd, name, 31)
new msg
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)
else if(leftmoney<30000)
entity_set_model(ptr, g_MoneyModel)
else
entity_set_model(ptr, g_MoneyModel)
new Float:maxbox = {15.0, 15.0, 15.0}, Float:minbox = {-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
read_logargv(0, user, 127)
new name, oldteam={0}
parse_loguser(user, name, 31, _, _, _, oldteam, 11)
new id = get_user_index(name)
new newteam
read_logargv(2,newteam, 15)
new savespecmoney = get_cvar_num("amx_savespecmoney")
if(equal(newteam,"SPECTATOR")) //加入观察员
{
if(oldteam) //从T或CT加入观察员
{
if(savespecmoney)
g_specmoney = total_money
else
g_specmoney = g_startmoney
}else{//进入服务器就加入观察员
g_specmoney = g_startmoney
}
}else{//加入T队伍或CT队伍
if(oldteam==0)//连接到服务器就加入T或CT
{
total_money = 0
native_cs_set_user_money2(id, g_startmoney, 1)
}else if(equal(oldteam,"SPECTATOR")){//从观察员加入T或CT
if(savespecmoney)
{
total_money = 0
native_cs_set_user_money2(id, g_specmoney, 1)
}else{
total_money = 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
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
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)
else if(money<30000)
entity_set_model(gEnt, g_MoneyModel)
else
entity_set_model(gEnt, g_MoneyModel)
new iOrigin
FVecIVec(victim_coord, iOrigin)
new param
param = gEnt
param = iOrigin
param = iOrigin
param = iOrigin
set_task(0.2, "reset_size", 0, param, 4)
new victimname
get_user_name(victim,victimname,31)
new msg
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, smoney, 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
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
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 */
回复: 捡钱的声效怎么添加?
2楼的代码已修改得很清楚了,自已动一下手.声音文件自己去找.回复: 捡钱的声效怎么添加?
但是源文件不能编译啊?回复: 捡钱的声效怎么添加?
源文件不能编译啊:sweat: ?回复: 捡钱的声效怎么添加?
哦,之前没留意代码里面已经有了precache.不好意思.
帮你改好了.不过没测试.自己编译吧.
回复: 捡钱的声效怎么添加?
钱。钱。钱。钱钱钱。钱。钱。钱。钱钱钱。钱。钱。钱回复: 捡钱的声效怎么添加?
:D 捡钱的声效 :super: 捡钱的声效:D
页:
[1]
2