Monday, June 9, 2014

CS Bomb Scripting - Hướng Dẫn Chung Về Chế Độ Đặt Bom



Giới Thiệu :
Bom là một trong những khía cạnh thú vị nhất của kịch bản CS. Tôi thấy rất nhiều câu hỏi kịch bản bom / sai lầm. Vì vậy, tôi quyết định để tạo ra các "CS bom Scripting Hỏi đáp / Hướng dẫn".

Yêu Cầu :
Bạn nên làm quen với những điều cơ bản của kịch bản amxx. Chức năng Fakemeta tiện ích được sử dụng ở đây. Để có được chỉ số của người chơi (chỉ có trong "logevent_function_p"), bạn phải sử dụng:

PHP Code:
stock get_loguser_index() {
    new 
loguser[80], name[32]
    
read_logargv(0, loguser, 79)
    
parse_loguser(loguser, name, 31)

    return 
get_user_index(name)
}  
Ví dụ:
PHP Code:
public logevent_function_p() {
    new 
id = get_loguser_index()
    
// ...}  
1. Player/Bomb
PHP Code:
// Bom bị rớt xuống hay mang đi?
    
if (fm_find_ent_by_class(-1, "weapon_c4"))
 
// Nếu bom rớt?
    
new bomb = fm_find_ent_by_class(-1, "weapon_c4")
    if (
bomb && pev(bomb, pev_owner) > get_maxplayers())
 
// Nếu bom được mang đi ? / Ai mang bom đi ?
    
new carrier = 0, ownerent, bomb = fm_find_ent_by_class(-1, "weapon_c4")
    if (
bomb && (ownerent = pev(bomb, pev_owner)) <= get_maxplayers())
        
carrier = ownerent
    
if (carrier) // Chúng tô có người mang bom
    
else // Chúng tôi không có người mang bom

// Người chơi có được bom hay không ?
    
if (user_has_weapon(id, CSW_C4)) // Cách #1
    
if (pev(id, pev_weapons) & (1<<CSW_C4)) // Cách #2
    
if (fm_find_ent_by_owner(-1, "weapon_c4", id)) // Cách #3

// Làm sao để chuyển giao bom từ người chơi cho một người khác ?
    
fm_transfer_user_gun(carrier, recipient, CSW_C4) // Trả về True nếu thành công
// Làm thế nào để buộc người chơi thả bom ra ?
    
engclient_cmd(id, "drop", "weapon_c4")
 
// Làm thế nào để gở bỏ các quả bom rơi ?
    
new weapbox, bomb = fm_find_ent_by_class(-1, "weapon_c4")
    if (
bomb && (weapbox = pev(bomb, pev_owner)) > get_maxplayers()) {
        
dllfunc(DLLFunc_Think, weapbox) // Điều này sẽ gở bỏ weaponbox + weaponbox_c4
        // Loại bỏ nhấp nháy bom màu đỏ trên radar
        
message_begin(MSG_ALL, get_user_msgid("BombPickup"))
        
message_end()
    }
 
// Làm sao để cung cấp bomd cho người chơi
    
fm_give_item(id, "weapon_c4")
    
// use cs_set_user_plant(id) cho phép trồng

// Làm thế nào để g bom từ một người chơi
    
engclient_cmd(id, "weapon_c4")
    
cs_set_user_bpammo(id, CSW_C4, 0)
    
engclient_cmd(id, "lastinv")
    
// loại bỏ HUD bomb
    
message_begin(MSG_ONE, get_user_msgid("StatusIcon"), _, id)
    
write_byte(0)
    
write_string("c4")
    
message_end()
 
// Nếu bomb được đặt làm sao để gỡ bomb?
    
new bomb
    
if ((bomb = fm_find_ent_by_model(-1, "grenade", "models/w_c4.mdl"))) {
        
// Bomd được đặt
        
fm_remove_entity(bomb) // Gỡ bỏ bomb
    
}  
2. Drop/Collect
PHP Code:
// Người chơi sinh ra mang bom sẵn
    
register_logevent("logevent_function_p", 3, "2=Spawned_With_The_Bomb")
 
// Bom rơi ( bao gồm sự kiện người ngắt kết nối hoặc chết)
    
register_logevent("logevent_function_p", 3, "2=Dropped_The_Bomb")
    
// sử dụng is_user_alive/is_user_connected để kiểm tra disconnect/death

// Bom được nhặt ( ngoại trừ sự kiện hồi sinh )
    
register_logevent("logevent_function_p", 3, "2=Got_The_Bomb")
 
// Bomb gained (including spawn/give_item) event
    
register_event("WeapPickup", "event_function", "be", "1=6")  
3. Plant/Defuse
PHP Code:
// Sự kiện bom đang được đặt
    
register_event("BarTime", "event_function", "be", "1=3")
 
// Sự kiện bom đã được đặt
    
register_logevent("logevent_function_p", 3, "2=Planted_The_Bomb")
 
// Sự kiện bom đang được gỡ
    
register_event("BarTime", "event_function", "be", "1=5", "1=10")
 
// Bomb defusion (without kit) started event
    
register_logevent("logevent_function_p", 3, "2=Begin_Bomb_Defuse_Without_Kit")
 
// Bomb defusion (with kit) started event
    
register_logevent("logevent_function_p", 3, "2=Begin_Bomb_Defuse_With_Kit")
 
// Sự kiện bom đã được gỡ
    
register_logevent("logevent_function_p", 3, "2=Defused_The_Bomb")
 
// Bom được đặt/gỡ sự kiện
    
register_event("BarTime", "event_function", "b", "1=0")
    
register_event("CurWeapon", "event_function", "be", "2!6")
    
// Bạn phải chắc chắn rằng tiến trình đặt/gỡ bom đang được tiến hành

// Lưu sự kiện
    
register_logevent("logevent_function", 6, "3=Target_Saved")  
4. Explosion
PHP Code:
//Sự kiện mục tiêu được đánh bom ( ngay trước khi hết round)
    
register_logevent("logevent_function", 6, "3=Target_Bombed")
 
// Sự kiện bom phát nổ trước/sau khi kết thúc round
    
register_event("23", "event_function", "a", "1=17", "6=-105", "7=17")
 
// Sự kiện người chơi giết chết bởi bom
    // will not work if victim is killed by env_explosion entity that is triggered by explosion
    
public client_death(killer, victim, wpnindex, hitplace, TK) {
        if (
wpnindex == CSW_C4)
    }  
5. Targets
PHP Code:
// Is player at the bomb target (func_bomb_target)?
    // Note: there are no good way to detect if player is at the info_bomb_target
    
new target = -1, class[] = "func_bomb_target", bool:is_inside = false
    
while ((target = fm_find_ent_by_class(target, class))) {
        if (!
fm_boxents_distance(index, target)) {
            
is_inside = true
            
break
        }
    }
    if (
is_inside)
 
// Is map contain bomb targets?
    
if (fm_find_ent_by_class(-1, "func_bomb_target") || fm_find_ent_by_class(-1, "info_bomb_target"))
 
// How to remove bomb targets?
    
new target = -1, classname[] = "func_bomb_target"
    
while ((target = fm_find_ent_by_class(target, classname)))
        
fm_remove_entity(target)
    
classname = "info_bomb_target"
    
while ((target = fm_find_ent_by_class(target, classname)))
        
fm_remove_entity(target)  

0 nhận xét:

Post a Comment