|
楼主 |
发表于 2009-3-8 22:11:52
|
显示全部楼层
来自 中国–湖南–衡阳
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)
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]
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)
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()
{
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
} |
|