搜索
查看: 1443|回复: 1

请问检钱掉钱插件怎样精简呢?

[复制链接]
发表于 2005-5-18 05:23:28 | 显示全部楼层 |阅读模式 来自 海南海口
我不想用里面的登陆显示排名功能,因为它读的是csststa的排名数据,而我使用的是psychostats排名,不正确.还有就是里面的更改了CS无线电信息.想不要这个功能.请问怎样更改sma编译.我上传原 sma文件

本帖子中包含更多资源

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

×
 楼主| 发表于 2005-5-18 05:24:39 | 显示全部楼层 来自 海南海口
/* Rewarding
   ver 0.1 By Zhao on 2004.12.4
*/
#include <amxmodx>
#include <csx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <mysql>
#include <csstats>

//#define DEBUG
#define MONEY_TIER 8000 // DON'T MESS WITH, Money total at which the plugin switches over keeping

track of money
#define MAX_DROPED_MONEY_COUNT 100
#define TE_GLOWSPRITE      23      
#define Maxsounds 1
#define BIG_MONEY_INDEX 16
#define OPEN_SQL
#define MONEY_REWARD
// coord, coord, coord (pos) short (model index) byte (scale / 10)

new soundlist[Maxsounds][] = {"Half-Life17"} //Connecting Music
new money_total[33] // Keep track of peeps money if above MONEY_TIER
new gmsg_Money
new playerkilled[33]

new rewards[20]=

{50,100,300,500,800,1200,2000,3000,5000,7000,9000,10000,12000,15000,17000,19000,20000,25000,28000

,32000}//Rewarding Ramdon
new g_firstblood,Round_Control
new g_random,g_roundcount
new g_money11,g_money22,g_money33
new rewardedbig,g_iRoundEndTriggered
//new connectingmp3

new droped_money_postion[MAX_DROPED_MONEY_COUNT][3]
new droped_money_ammount[MAX_DROPED_MONEY_COUNT][2]//[.][0] is money,[][1] is the round
new droped_money_count


public client_putinserver(id){
        client_cmd(id,"mp3 stop")
        return PLUGIN_CONTINUE
}

public abs(num){
                return (num>=0)?num:-num
}

public client_connect(id){
        new i
        i = random_num(0,Maxsounds-1)
        client_cmd(id,"mp3 play media/%s",soundlist)
        set_cvar_float("mp_startmoney", 801.0) // So you can track when to change to

amx_startmoney ammount, I know.. a crude method
        money_total[id] = 0
        //client_cmd(id,"mp3 play ^"../valve/media/half-life17.mp3^"");
}

public read_gmsg_Money(id)
{       
        new current_total = read_data(1)
       
        if(current_total == 801){                        // If CS is spawning you with

mp_startmoney default
                current_total = get_cvar_num("amx_startmoney")                // current total is

actually amx_startmoney
                cs_set_user_money(id, current_total,0)                        // so set user money to

amx_startmoney
                money_total[id] = 0 // reset
        }
        if(current_total >= MONEY_TIER && !money_total[id]) // If first time above MONEY_TIER
        {
                money_total[id] = current_total // Keep track of current total
                send_moneymsg(id,1) // send money msg of current total
                return PLUGIN_CONTINUE
        }
        if(money_total[id]) // If was over tier on last money message
        {
                money_total[id] += current_total - MONEY_TIER  // figure the term of current

total - tier

                if(money_total[id] < MONEY_TIER){  // If less then tier set user money to

money_total[id] and stop keeping track
                        cs_set_user_money(id,money_total[id],1)
                        money_total[id] = 0
                }
                else{
                        send_moneymsg(id,1) // else send money message
                }
               
                return PLUGIN_CONTINUE               
        }

        return PLUGIN_CONTINUE
}

public send_moneymsg(id,flash)
{
        cs_set_user_money(id,MONEY_TIER,flash) //Set user money to tier ammount so easy to track

add and subtract terms
       
        static MAXAMMOUNT
       
        MAXAMMOUNT = get_cvar_num("amx_maxmoney")
       
        if(money_total[id] > MAXAMMOUNT)
                money_total[id] = MAXAMMOUNT

        message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id) //Send money message with ammount

stored in money_total[id]
        write_long(money_total[id])
        write_byte(flash)
        message_end()
}

public ramdon_money(params[]){
        new killer=params[0]
        new oldamount=params[1]
        new amount
        new killername[32]
        new random_range,randomvalue
        random_range=(rewardedbig)?BIG_MONEY_INDEX:20//控制大额的奖励不会出现太多次
        for(;;){
                randomvalue=random(random_range)
                amount=rewards[randomvalue]
                if (amount!=oldamount) break;
        }
        get_user_name(killer,killername,31)
        if (g_random>0){
                g_random--
                set_hudmessage(0,255,0,0.05,0.25,0, 0.02, 0.4, 0.01, 0.1, 2)
                show_hudmessage(0,"%s一马当先,奋勇杀敌,奖励%6d金钱",killername,amount)
                new param[2]
                param[0]=killer       
                param[1]=amount
                set_task(0.3,"ramdon_money",0,param,1)
        }
        else {
                if(randomvalue>=BIG_MONEY_INDEX) rewardedbig=1
                //set_hudmessage(0,255,0,0.75,0.18,0, 1.0, 5.0, 0.1, 0.2, 1)
                set_hudmessage(0,255,0,0.05, 0.25, 0, 0.02, 6.0, 0.01, 0.1, 2)
                show_hudmessage(0,"%s一马当先,奋勇杀敌,奖励%6d金钱",killername,amount)
                add_player_money(killer,amount)
                new msg[512]
                format(msg,511,"^x03%s^x01 一马当先,奋勇杀敌,奖励^x04 %d ^x01金

钱",killername,amount)
                client_color(0,killer,msg)
        }
}

public add_player_money(player,ammount){
                                static MAXAMMOUNT
                                MAXAMMOUNT = get_cvar_num("amx_maxmoney")
                                new new_total_money
                                if(money_total[player]){
                                        new_total_money=money_total[player]+ammount
                                }
                                else
                                        new_total_money=cs_get_user_money(player) + ammount
                                if (new_total_money>=MONEY_TIER){
                                        money_total[player]=new_total_money
                                        if(money_total[player]>MAXAMMOUNT) money_total[player]

=MAXAMMOUNT
                                        send_moneymsg(player,1) // send money msg of current

total                                               
                                }
                                else {
                                        cs_set_user_money(player,new_total_money)
                                        money_total[player]=0
                                }
}

public random_drop_money(ori_ammount){
                new drop_control
                if(ori_ammount>10000){
                        drop_control=random(30000)
                        if(ori_ammount>=drop_control){//按照钱的多少,我们产生不同的掉钱的随机数


                                //现在我们决定要调多少。最多是0.6,0.5  0.4 0.3 0.2,0.1
                                return random(6)+1
                        }else return 0       
                }
                return 0
}

//public client_death(killer,victim,wpnindex,hitplace,TK){
public eDeathMsg(){
        new killer,victim,TK
        killer=read_data(1)
        if(!killer) return PLUGIN_CONTINUE
        victim=read_data(2)
        TK=(get_user_team(killer)==get_user_team(victim))?1:0
        //headshot=read_data(3)
        new wpnname[4]
        read_data(4,wpnname,3)
        new killername[32]
        //if (wpnindex==CSW_C4||TK) return PLUGIN_CONTINUE
        if(equal(wpnname,"c4")||TK) return PLUGIN_CONTINUE
//        new headshot = ( hitplace==HIT_HEAD ) ? 1:0
        new selfkill = ( killer==victim ) ? 1:0
        if (selfkill) return PLUGIN_CONTINUE
        playerkilled[killer]++
        if(equal(wpnname,"kni")){
                add_player_money(killer,5000)
                get_user_name(killer,killername,31)
                set_hudmessage(0,255,0,0.05,0.25,0, 0.2, 6.0, 0.1, 0.1, 2)
                //set_hudmessage(0,255,0,0.75,0.18,0, 1.0, 1.0, 0.1, 0.2, 12)
                show_hudmessage(0,"%s使用匕首杀敌,奖励5000金钱",killername)
                new msg[100]
                format(msg,99,"^x03%s^x01使用匕首杀敌,奖励^x04 5000 ^x01 金钱",killername)
                client_color(0,killer,msg)
                //log_message("%s使用匕首杀敌,奖励5000金钱",killername)
        }
       
        if (g_firstblood){
                g_firstblood=0
                g_random=6
                new param[2]
                param[0]=killer
                param[1]=0;
                ramdon_money(param)
        }
        //The Victim Will Drop Some Money
        new victim_money
        if(money_total[victim]==0) victim_money=cs_get_user_money(victim)
        else victim_money=money_total[victim]
        //if (victim_money>= MONEY_TIER&&
        if (droped_money_count<MAX_DROPED_MONEY_COUNT){
                new drop_prec=random_drop_money(victim_money)
                //new int:dropedmoney=*victim_money
                if(drop_prec>0){
                        new dropedmoney=(victim_money*drop_prec/10000)*1000
                        add_player_money(victim,-dropedmoney)
                        new victim_coord[3]
                        get_user_origin(victim, victim_coord)               
                        new i
                        for (i=0;i<MAX_DROPED_MONEY_COUNT;i++)
                        {
                                if(droped_money_ammount[0]==0){
                                        droped_money_count++
                                        droped_money_postion[0]=victim_coord[0]
                                        droped_money_postion[1]=victim_coord[1]
                                        droped_money_postion[2]=victim_coord[2]
                                        droped_money_ammount[1]=g_roundcount//We record which

round droped the money
                                        droped_money_ammount[0]=dropedmoney*8/10 //We Drop 20

precent money
                                        break;
                                }
                        }
                        //new ammount_desc[32]
                        new victimname[32]
                        get_user_name(victim,victimname,31)
                        new msg[100]
                        format(msg,99,"^x03%s^x01掉了^x04%d^x01钱.",victimname,dropedmoney)
                        client_color(0,victim,msg)
                }
        }
        return PLUGIN_CONTINUE
}

public show_droped_money(){
        new i
        new money_model_id
        for (i=0;i<MAX_DROPED_MONEY_COUNT;i++){
                if (droped_money_ammount[0]>0){
                        //We Display the money;
                        if(droped_money_ammount[0]<10000){
                                money_model_id=g_money11
                        }
                        else if (droped_money_ammount[0]<100000){
                                money_model_id=g_money22
                        } else money_model_id=g_money33
                        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
                        write_byte(17)//#define TE_SPRITE  17      // additive sprite, plays 1

cycle,More Info,plz reffer to HLSDK
                        write_coord(droped_money_postion[0]);
                        write_coord(droped_money_postion[1]);
                        write_coord(droped_money_postion[2]+20);
                        write_short(money_model_id)
                        write_byte(2)
                        write_byte(128)
                        message_end()
                }
        }
}
public check_player_pos(){
        new playerslist[32]
        new i,playerscount,j,moneyammount
        new playerspos[3],playername[32]
        get_players(playerslist,playerscount,"a") //we only check the alive players
        for(i=0;i<playerscount;i++){
                get_user_origin(playerslist,playerspos)
                for(j=0;j<MAX_DROPED_MONEY_COUNT;j++){
                                if(droped_money_ammount[j][0]>0&&
                                         abs(playerspos[0]-droped_money_postion[j][0])<=20&&
                                         abs(playerspos[1]-droped_money_postion[j][1])<=20&&
                                         abs(playerspos[2]-droped_money_postion[j][2])<=30)

{//Pick Up Money
                                         moneyammount=droped_money_ammount[j][0]
                                         droped_money_ammount[j][0]=0;
                                         droped_money_count--;
                                         add_player_money(playerslist,moneyammount)
                                         get_user_name(playerslist,playername,31)
                                          new msg[100]
                                         format(msg,99,"^x03%s^x01捡到^x04%d^x01

钱.",playername,moneyammount);
                                         client_color(0,playerslist,msg)
                                         break;
                                }
                }
        }       
}

public new_round(){
        new i
        if (!Round_Control){
                g_roundcount++
                Round_Control = 1
                g_firstblood=1
                g_iRoundEndTriggered=0
                for(i=0;i<=32;i++)playerkilled=0;
                //We Remove the droped money 3 round ago
                for(i=0;i<MAX_DROPED_MONEY_COUNT;i++){
                        if (droped_money_ammount[0]>0&&g_roundcount>(droped_money_ammount

[1]+2)){
                                droped_money_ammount[0]=0
                                droped_money_ammount[1]=0
                                droped_money_count--
                        }
                }
        }
}

public eEndRound(){
                if (g_iRoundEndTriggered) return
                g_iRoundEndTriggered=1
                Round_Control=0
                new i,maxkillcount
                maxkillcount=0
                new RoundEndMsg[513],ipos
                new playerslist[32],playerscount
                ipos=0
                ipos+=format(RoundEndMsg[ipos],512-ipos,"本局杀敌最多的玩家")

                get_players(playerslist,playerscount)//Get  Players
                for(i=0;i<playerscount;i++){
                        if(playerkilled[playerslist]&&playerkilled[playerslist]

>maxkillcount) maxkillcount=playerkilled[playerslist]
                }
                if(maxkillcount){
                        new playername[33],playeradded=0
                        ipos+=format(RoundEndMsg[ipos],512-ipos,"  (杀%d人)^n-------------------

--------------^n",maxkillcount)
                        for(i=0;i<playerscount;i++){
                                if(playerkilled[playerslist]==maxkillcount){//WeiGet this

players
                                        if (get_user_name(playerslist,playername,32))
                                                ipos+=format(RoundEndMsg[ipos],512-ipos,"%

s^n",playername)
                                        else ipos+=format(RoundEndMsg[ipos],512-ipos,"未知或已离

开游戏^n")
                                        ++playeradded
                                }
                               
                                if(playeradded>=2){
                                        ipos+=format(RoundEndMsg[ipos],512-ipos,"......^n")
                                        break;
                                }
                        }
                               
                }
                else{
                        ipos+=format(RoundEndMsg[ipos],512-ipos,"^n-----------------------------

----^n大家太客气了,都没有杀敌^n")
                }
                ipos+=format(RoundEndMsg[ipos],512-ipos,"^n金钱最多的玩家^n---------------------

------------^n")       
                new maxctmoney=0,maxtmoney=0,maxmoneytid=0,maxmoneyctid=0
                for(i=0;i<playerscount;i++){
                        new userid=playerslist
                        new usermoney
                        if(!is_user_connected(userid)) continue
                        if(money_total[userid]) usermoney=money_total[userid]
                        else usermoney=cs_get_user_money(userid)
                        if(cs_get_user_team(userid)==CS_TEAM_T){
                                if(usermoney>maxtmoney){
                                        maxtmoney=usermoney
                                        maxmoneytid=userid
                                }
                        }
                        else {
                                if(usermoney>maxctmoney){
                                        maxctmoney=usermoney
                                        maxmoneyctid=userid
                                }
                        }
                       
                }
                new ctname[33],tname[33]
                if(maxmoneytid)get_user_name(maxmoneytid,tname,32)
                else tname="没有人"
                if(maxmoneyctid)get_user_name(maxmoneyctid,ctname,32)
                else ctname="没有人"
                ipos+=format(RoundEndMsg[ipos],512-ipos,"反恐小组^n%s   %d^n恐怖分子^n%s   %

d",ctname,maxctmoney,tname,maxtmoney)
                set_hudmessage( 100, 200, 0, 0.05, 0.55, 0, 0.02, 5.0, 0.1, 0.2, 2 )
                show_hudmessage(0,RoundEndMsg)
}

public eRestart(){
        new i
        g_roundcount = 0
        g_firstblood = 0
        Round_Control = 0
        rewardedbig = 0
        for(i=0;i<=32;i++)        money_total=0;
        for(i=0;i<=32;i++)playerkilled=0;
        for(i=0;i<MAX_DROPED_MONEY_COUNT;i++){
                droped_money_ammount[0]=0
                droped_money_ammount[1]=0
        }
        droped_money_count=0
//        client_print(0,print_chat,"Round Restart and Roundcount=%d",g_roundcount)
}

public plugin_precache()
{
        g_money11 = precache_model("sprites/money11.spr");
        g_money22 = precache_model("sprites/money22.spr");
        g_money33 = precache_model("sprites/money33.spr");
        //precache_sound("../valve/media/half-life17.mp3");
}
public client_color(playerid,colorid,msg[]){
                new playerslist[32],playerscount//,i
                get_players(playerslist,playerscount,"c")
                new userid
                if(playerid==0){
                        userid=playerid
                        message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0}, userid)
                        write_byte(colorid)
                        write_string(msg)
                        message_end()
                               
                }
                else{
                        userid=playerid
                        message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, userid)
                        write_byte(colorid)
                        write_string(msg)
                        message_end()
                }
}


public plugin_init(){
        register_plugin("First Killer Reward","0.1","Zhao")
        register_event("RoundTime", "new_round", "bc")        
//        register_event("ResetHUD", "new_round", "abc")
        #if defined MONEY_REWARD
        register_event("DeathMsg","eDeathMsg","a")
        register_event("Money","read_gmsg_Money","b")
        #endif
        register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!

MRAD_rounddraw")
        register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")
//        register_event("BarTime","bartime_event","b")
        register_cvar("amx_startmoney", "800")
        register_cvar("amx_maxmoney", "32000")

        register_message(get_user_msgid("TextMsg"),"color_radio")
        register_event("TeamInfo","team_join","a","2!UNASSIGNED") // Team Joining
               
        g_firstblood=1
        rewardedbig = 0
        droped_money_count=0
        g_roundcount=0
        gmsg_Money = get_user_msgid("Money")
        #if defined MONEY_REWARD
        set_task(0.5,"show_droped_money",887,"",0,"b")
        set_task(0.1,"check_player_pos",888,"",0,"b")
        #endif
}
以上是我自己乱修改的.编译报错了. :(
回复

使用道具 举报

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

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