搜索
查看: 1775|回复: 1

游戏中拥有直升机插件 存在好些BUG请高手修复

[复制链接]
发表于 2007-3-18 04:22:56 | 显示全部楼层 |阅读模式 来自 中国–广东–深圳–南山区
原贴地址:
http://www.dt-club.net/forum/thr ... 4%E5%8D%87%E6%9C%BA
希望高手能修正几个问题。
1、飞机只有上升,没有下降,似乎不够人性化
2、升空后发射炮弹后机体会自动爆炸
3、升空后好像不能移动、视角也不是很好
4、最重要的是,用力这个插件后,活着的玩家走到死亡玩家尸体旁边,就会把尸体一起拖着走,1拖2拖3拖4……靠近多少尸体就会拖多少。。。


[PHP]
//Includes
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <fun>

//Roflcopter 0.4 mod
//fairieclan.vze.com
//Pinkfairie

new roflcopterent[33] //invis sold
new roflcopterent2[33] //Copter mdl
new heli_is[33]; //Is inhelicopter
new heli_isup[33]; //Is going up
new Float:angles[33][3] //Angles
new Float:angles2[33][3] //Angles
new Float:bullettime[33] //Times to prevent crashing
new bullet
new smoketrail

//Initation
public plugin_init(){
        register_plugin("roflcopter","0.5","Pink | C.H.M"); //Register Plugin

        register_clcmd("+heli", "heliup_plus") //Register Commands
        register_clcmd("-heli", "heliup_minus")

        register_touch("bullet_ent","player","touch_bullet");

        register_clcmd("/rocket", "rocket2")
        register_clcmd("say /autobind", "autobind")

        register_concmd("amx_roflcopter","cmd_roflcopter",ADMIN_LEVEL_A,"<name> <0|1> - 直升机 1 开启 0 关闭");
}

public client_putinserver(id) { //Join server
        angles[id][0] = 0.0
        angles[id][1] = 0.0
        angles[id][2] = 0.0
        remove_task(id,0); //Remove current tasks
        heli_check(id) //Play helicopter check
        heli_sound(id)//Play helicopter sound
        heli_is[id] = 0 //Make them not a helicopter
}

public heli_check(id) {
        if(is_user_connected(id) == 0) { //If not connected, stop and go back
                return PLUGIN_HANDLED;
        }

        if(heli_is[id] > 0) { //If is a helicopter
                remove_entity(roflcopterent[id]) //remove the two ents...
                remove_entity(roflcopterent2[id])// "  "  " "
                entity_get_vector(id,EV_VEC_angles,angles2[id]) //get the players angels

                angles[id][1] = angles2[id][1] //Keep copter on the player but let the copter have moving physics

                set_entity_visibility(id, 0) //Make the person invisable so the 2nd ent looks like them! :)
                if(is_user_alive(id) == 0) { //If dead, Remove the chopper and exit them from the copter
                        heli_is[id] = 0 //Not a heli
                        client_print(id,print_chat,"* [直升机] 你已经死亡直升机坠毁.^n"); //Message
                }
                new origin[3] //Origin varible
                get_user_origin(id,origin); //Get origin

                //Entity1
                roflcopterent[id] = create_entity("info_target"); // create entity
                set_entity_visibility(roflcopterent[id], 0) //make the solid enity invisable
                entity_set_model(roflcopterent[id],"models/copter.mdl"); // set model
                entity_set_vector(roflcopterent[id],EV_VEC_angles,Float:{0.0,0.0,0.0}); //set vector
                new Float:choppos[3]; //new pos
                choppos[0] = float(origin[0]);
                choppos[1] = float(origin[1]);
                choppos[2] = float(origin[2] -60); //make it 60 coords below feet
                entity_set_origin(roflcopterent[id],choppos); //Set the origin
                entity_set_int(roflcopterent[id],EV_INT_solid, 2) //Make it solid
                new Float:maxs[3] = {16.0,16.0,16.0} //How big solid?
                new Float:mins[3] = {-16.0,-16.0,-16.0} //How big solid?
                entity_set_size(roflcopterent[id],mins,maxs) //set size

                //Entity2
                roflcopterent2[id] = create_entity("info_target"); // create entity
                entity_set_model(roflcopterent2[id],"models/copter.mdl"); // set model
                entity_set_vector(roflcopterent2[id],EV_VEC_angles,angles[id]);
                new Float:choppos2[3];
                choppos2[0] = float(origin[0]);
                choppos2[1] = float(origin[1]);
                choppos2[2] = float(origin[2]);
                entity_set_origin(roflcopterent2[id],choppos2);
                entity_set_int(roflcopterent2[id],EV_INT_solid, 2)


                if(heli_isup[id] > 0) { //If holding in the heliup key
                        origin[2] += 50 //Make them go up! woo!
                }

                set_user_origin(id,origin); //Set it
                set_task(0.1,"heli_check",id); //Loop
                return PLUGIN_HANDLED;
        }
        set_entity_visibility(id, 1)
        set_task(0.1,"heli_check",id); //If not in helicopter, Loop
        return PLUGIN_HANDLED;
}

public heli_sound(id) {
        if(is_user_connected(id) == 0) { //If not connected, stop and go back
                return PLUGIN_HANDLED;
        }
        if(heli_is[id] > 0) { //If is a helicopter
                emit_sound(id, CHAN_VOICE, "PinkRPG/roflcopter.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) //player a heli sound
                set_task(1.5,"heli_sound",id); //Loop
                return PLUGIN_HANDLED;
        }
        set_task(1.5,"heli_sound",id); //If not in helicopter, Loop
        return PLUGIN_HANDLED;
}

public heliup_plus(id) {
        heli_isup[id] = 1
}

public heliup_minus(id) {
        heli_isup[id] = 0
}



public cmd_roflcopter(id,level,cid) {
        if(!cmd_access(id,level,cid,3)) {
                return PLUGIN_HANDLED;
        }
        new arg1[256], arg2[256]
        read_argv(1,arg1,255);
        read_argv(2,arg2,255);
        new player = cmd_target(id,arg1,2); //make the first arugment the player
        new heli_onoff = str_to_num(arg2); //Make the 2nd one a number
        if(!player) { //Player not exist, Stop
                return PLUGIN_HANDLED;
        }
        if (heli_onoff > 1 || heli_onoff < 0) {
                console_print(id,"* [直升机] 你的数字必须是 1 或 2.^n");
                return PLUGIN_HANDLED;
        }

        if(heli_onoff < 1) { //if they put 0, make them stop being a roflcopter
                heli_is[player] = 0
                client_print(player,print_chat,"* [直升机] 管理员关闭了直升机插件.^n");
                remove_entity(roflcopterent[player])
                remove_entity(roflcopterent2[player])
                return PLUGIN_HANDLED;
        }
        if(heli_onoff > 0) { //Make them a helicopter if they put 1 :)
                heli_is[player] = 1
                client_print(player,print_chat,"* [直升机] 管理员开启直升机插件.(绑定一个键位 +heli 飞机升空, /rocket 发射炮弹.)^n");
                return PLUGIN_HANDLED;
        }
        return PLUGIN_HANDLED;
}

public plugin_precache() {
        precache_sound( "PinkRPG/roflcopter.wav")
        precache_model( "models/copter.mdl")
        precache_model( "models/rpgrocket.mdl")
        smoketrail = precache_model("sprites/smoke.spr")
}

public client_PreThink(id) {

        if(heli_is[id] > 0) { //if is in the helicopter

                new button = entity_get_int(id,EV_INT_button); // get buttons

                if((button & IN_FORWARD)){ //If going forward
                        angles[id][0] = 330.0 //Dip forward
                }
                else {
                        angles[id][0] = 0.0
                }
                if((button & IN_BACK)){ //Going back?
                        angles[id][0] = 30.0 //Dip back!
                }


                if((button & IN_MOVELEFT)){ //If going left
                        angles[id][2] = 330.0 //Swing to the side
                }
                else {
                        angles[id][2] = 0.0
                }
                if((button & IN_MOVERIGHT)){ //If going right
                        angles[id][2] = 30.0 //Swing to the side
                }

        }


}


public rocket2(id) {
        if(heli_is[id] > 0) { //if in heli
                if(get_gametime() < bullettime[id] + 1.0) { //if recently fired missel ingame, stop to prevent crashing
                        return PLUGIN_HANDLED;
                }
                bullettime[id] = get_gametime() //Reset time so they can fire again in .5 seconds
                new origin[3], Float:Angle[3] //Create the angle the missle points
                get_user_origin(id,origin); //Get the origin of the player
                entity_get_vector(id, EV_VEC_v_angle, Angle) //Make angle = to person's so the missle will be pointing forward when fired
                bullet = create_entity("info_target") //Create the bullet already!
                entity_set_string(bullet, EV_SZ_classname, "bullet_ent") //Give it a classname
                entity_set_model(bullet, "models/rpgrocket.mdl") //Make it the classic tfc model <3

                new Float:bulletpos[3]; //New pos
                bulletpos[0] = float(origin[0]); //Make the bullet = to the players origin in XYZ
                bulletpos[1] = float(origin[1]);
                bulletpos[2] = float(origin[2]);
                entity_set_origin(bullet,bulletpos); //Set it

                entity_set_vector(bullet, EV_VEC_angles, Angle) //Set the angle, So it looks forward
                entity_set_int(bullet, EV_INT_movetype, 5) //Movetype 5, rocket
                entity_set_edict(bullet, EV_ENT_owner, id) //Set the edict so it can fire when moving forward

                //Make this solid!
                new Float:mins[3] = {-5.0, -5.0, -5.0} //set the minimums
                new Float:maxs[3] = {5.0, 5.0, 5.0} //maxs
                entity_set_vector(bullet, EV_VEC_mins, mins) //Set the vector
                entity_set_vector(bullet, EV_VEC_maxs, maxs) // " " "
                entity_set_int(bullet, EV_INT_solid, 2) // Now actually make it solid

                //Set the vector's velocity
                new Float:Velocity[3]
                VelocityByAim(id, 1000, Velocity)
                entity_set_vector(bullet, EV_VEC_velocity, Velocity)

                //SEND IT OFF!
                message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
                write_byte(22)
                write_short(bullet)
                write_short(smoketrail)
                write_byte(30)
                write_byte(3)
                write_byte(255)
                write_byte(255)
                write_byte(255)
                write_byte(255)
                message_end()
                set_task(0.9,"remove_bullet",id);
                return PLUGIN_HANDLED;
        }
        return PLUGIN_HANDLED;
}


public basic_explosion(id) {
        new vec1[3]
        get_user_origin(id,vec1)
        message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)
        write_byte( 12 )
        write_coord(vec1[0])
        write_coord(vec1[1])
        write_coord(vec1[2])
        write_byte( 188 ) // byte (scale in 0.1's)
        write_byte( 10 ) // byte (framerate)
        message_end()
}

public touch_bullet(ent,id) { //If a player and the bullet touch
        new origin[3], Float:forigin[3] //make an origin, and a float
        get_user_origin(id,origin,0) //Get user origin
        IVecFVec(origin,forigin) //Convert to float
        basic_explosion(id) //Play an explosion
        user_silentkill(id) //Silent kill
        radius_damage(forigin,50,25) //Make some splash damage
        return PLUGIN_HANDLED
}

public autobind(id) {
        client_cmd(id, "bind uparrow +heli")
        client_cmd(id, "bind downarrow /rocket")
}

public remove_bullet(id) {
        new Float:origin[3]
        entity_get_vector(bullet,EV_VEC_origin, origin)

        new Float:vec1[3],iVec1[3]
        entity_get_vector(bullet,EV_VEC_origin, vec1)
        FVecIVec(vec1,iVec1)
        message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
        write_byte( 12 )
        write_coord(iVec1[0])
        write_coord(iVec1[1])
        write_coord(iVec1[2])
        write_byte( 188 ) // byte (scale in 0.1's)
        write_byte( 10 ) // byte (framerate)
        message_end()

        radius_damage(origin,50,25) //Make some splash damage
        remove_entity(bullet) //Remove rocket

        return PLUGIN_HANDLED;
}

[/PHP]
发表于 2007-8-13 15:40:11 | 显示全部楼层 来自 中国–广东–肇庆

回复: 游戏中拥有直升机插件 存在好些BUG请高手修复

唉```没想到```3月到现在```````
回复

使用道具 举报

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

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