(SMA)設置某時間執行指令....

Home Home
引用 | 編輯 tw2twtw
2010-11-24 21:45
樓主
推文 x0
問題1

請問如何把下面的 if 變成倒數時間的限制.... 
就是在時間到時執行當殭屍王....

 // 當剩下最後一隻喪屍時,設定讓他變成喪屍王.
 if (ts_num == 1)
 {
  static last_zombie_id
  last_zombie_id = ts[0]
  
  if (!g_boss[last_zombie_id]) // 檢查是否已經是成為喪屍王了
  {
   g_survivor_class[last_zombie_id] = 0
   g_boss[last_zombie_id] = true
   set_boss_model(last_zombie_id)
   play_boss_ambience_sound()
   fm_set_user_health(last_zombie_id, g_boss_health)
   g_user_maxspeed[last_zombie_id] = g_boss_maxspeed
   fm_set_user_maxspeed(last_zombie_id, g_user_maxspeed[last_zombie_id])
   set_task(1.0, "boss_beacon_effect", last_zombie_id)
   
   static tname[32]
   get_user_name(last_zombie_id, tname, charsmax(tname))
   set_hudmessage(255, 255, 255, -1.0, 0.17, 0, 6.0, 999.0, 0.1, 0.2, -1)
   //show_hudmessage(0, "%s is the Boss!!!", tname)
   ShowSyncHudMsg(0, g_hudSync3, "%s 是喪屍王!!!", tname)
   log_amx("殭屍王出現了,目前第%d局!",g_level)
  }
 }

問題2~

我用了sk大的模組被攻擊範圍....當殭屍王變成殘達時是有成功....((用nst 動作100多的殘達
但是到下局時"當過殭屍王的小殭擁有達叔的被攻擊範圍"......
希望可以設定,下局時會清除這局的效力...

獻花 x0
引用 | 編輯 chuchung712
2010-11-24 22:03
1樓
  
問題1只要用set_task就好了

獻花 x0
引用 | 編輯 tw2twtw
2010-11-24 22:40
2樓
  
set_task要怎麼用阿.... 表情
是遊戲中下面的黃色倒數?

獻花 x0
引用 | 編輯 chuchung712
2010-11-24 22:44
3樓
  
複製程式
 {
...
...
if (ts_num == 1)
 {
  static last_zombie_id
  last_zombie_id = ts[0]
  
  if (!g_boss[last_zombie_id]) // 檢查是否已經是成為喪屍王了
  {
   set_task(【時間】, "set_boss", last_zombie_id)  //此行的【時間】要輸入數值
  }
 } 
}

public set_boss(last_zombie_id)
{
   g_survivor_class[last_zombie_id] = 0
   g_boss[last_zombie_id] = true
   set_boss_model(last_zombie_id)
   play_boss_ambience_sound()
   fm_set_user_health(last_zombie_id, g_boss_health)
   g_user_maxspeed[last_zombie_id] = g_boss_maxspeed
   fm_set_user_maxspeed(last_zombie_id, g_user_maxspeed[last_zombie_id])
   set_task(1.0, "boss_beacon_effect", last_zombie_id)
   
   static tname[32]
   get_user_name(last_zombie_id, tname, charsmax(tname))
   set_hudmessage(255, 255, 255, -1.0, 0.17, 0, 6.0, 999.0, 0.1, 0.2, -1)
   //show_hudmessage(0, "%s is the Boss!!!", tname)
   ShowSyncHudMsg(0, g_hudSync3, "%s 是喪屍王!!!", tname)
   log_amx("殭屍王出現了,目前第%d局!",g_level)
}


獻花 x0
引用 | 編輯 tw2twtw
2010-11-25 21:21
4樓
  
我想設的是遊戲下面的黃色倒數.....
而且是要來取代下面這段..... 表情
// 當剩下最後一隻喪屍時,設定讓他變成喪屍王.
if (ts_num == 1)

獻花 x0
引用 | 編輯 i-c0112
2010-11-25 22:56
5樓
  
不知道這樣行不行
我想應該不行吧 因為這邊的 if 不是每秒判斷的
複製程式
new Float:time_round_start
public event_round_start{
 ...
 time_round_start = get_gametime()
}

if (get_gametime() - time_round_start >= xx.xx && !g_endround)
{ 
  static last_zombie_id 
  last_zombie_id = ts[0] 
   
  if (!g_boss[last_zombie_id]) // 檢查是否已經是成為喪屍王了 
  { 
   g_survivor_class[last_zombie_id] = 0 
   g_boss[last_zombie_id] = true 
   set_boss_model(last_zombie_id) 
   play_boss_ambience_sound() 
   fm_set_user_health(last_zombie_id, g_boss_health) 
   g_user_maxspeed[last_zombie_id] = g_boss_maxspeed 
   fm_set_user_maxspeed(last_zombie_id, g_user_maxspeed[last_zombie_id]) 
   set_task(1.0, "boss_beacon_effect", last_zombie_id) 
    
   static tname[32] 
   get_user_name(last_zombie_id, tname, charsmax(tname)) 
   set_hudmessage(255, 255, 255, -1.0, 0.17, 0, 6.0, 999.0, 0.1, 0.2, -1) 
   //show_hudmessage(0, "%s is the Boss!!!", tname) 
   ShowSyncHudMsg(0, g_hudSync3, "%s 是喪屍王!!!", tname) 
   log_amx("殭屍王出現了,目前第%d局!",g_level) 
  }
 else if (!g_endround)
 {
   set_hudmessage(255, 255, 255, -1.0, 0.17, 0, 6.0, 999.0, 0.1, 0.2, -1) 
   ShowSyncHudMsg(0, g_hudSync3, "%.2f秒後出現殭屍王!!!", xx.xx - (time_round_start - get_gametime()) ) 
 }
} 



獻花 x0
引用 | 編輯 i-c0112
2010-11-25 23:19
6樓
  
不知改成這樣如何
懶得編排 請見諒表情
複製程式
new Float:time_round_start
public event_round_start
{
 ...
 time_round_start = get_gametime()
set_task(1.0, "check", 0112, _, _, b)
}

if (get_gametime() - time_round_start >= xx.xx && !g_endround)
{ 
  static last_zombie_id 
  last_zombie_id = ts[0] 
   
  if (!g_boss[last_zombie_id]) // 檢查是否已經是成為喪屍王了 
  { 
   g_survivor_class[last_zombie_id] = 0 
   g_boss[last_zombie_id] = true 
   set_boss_model(last_zombie_id) 
   play_boss_ambience_sound() 
   fm_set_user_health(last_zombie_id, g_boss_health) 
   g_user_maxspeed[last_zombie_id] = g_boss_maxspeed 
   fm_set_user_maxspeed(last_zombie_id, g_user_maxspeed[last_zombie_id]) 
   set_task(1.0, "boss_beacon_effect", last_zombie_id) 
    
   static tname[32] 
   get_user_name(last_zombie_id, tname, charsmax(tname)) 
   set_hudmessage(255, 255, 255, -1.0, 0.17, 0, 6.0, 999.0, 0.1, 0.2, -1) 
   //show_hudmessage(0, "%s is the Boss!!!", tname) 
   ShowSyncHudMsg(0, g_hudSync3, "%s 是喪屍王!!!", tname) 
   log_amx("殭屍王出現了,目前第%d局!",g_level) 
  }
} 

public check(id)
{
  if(get_gametime() - time_round_start >= xx.xx && !g_endround)
    {
     remove_task(0112)    

      new i = random_num(1, g_maxplayers)
      while(!g_zombie[i] || !is_user_alive(i) || !g_boss[i])
        i = random_num(1, g_maxplayers)
 
   g_survivor_class[last_zombie_id] = 0 
   g_boss[last_zombie_id] = true 
   set_boss_model(last_zombie_id) 
   play_boss_ambience_sound() 
   fm_set_user_health(last_zombie_id, g_boss_health) 
   g_user_maxspeed[last_zombie_id] = g_boss_maxspeed 
   fm_set_user_maxspeed(last_zombie_id, g_user_maxspeed[last_zombie_id]) 
   set_task(1.0, "boss_beacon_effect", last_zombie_id) 
    
   static tname[32] 
   get_user_name(last_zombie_id, tname, charsmax(tname)) 
   set_hudmessage(255, 255, 255, -1.0, 0.17, 0, 6.0, 999.0, 0.1, 0.2, -1) 
   //show_hudmessage(0, "%s is the Boss!!!", tname) 
   ShowSyncHudMsg(0, g_hudSync3, "%s 是喪屍王!!!", tname) 
   log_amx("殭屍王出現了,目前第%d局!",g_level) 
    }
 else if (!g_endround)
  {
   set_hudmessage(255, 255, 255, -1.0, 0.17, 0, 6.0, 999.0, 0.1, 0.2, -1) 
   ShowSyncHudMsg(0, g_hudSync3, "%.2f秒後出現殭屍王!!!", xx.xx - (time_round_start - get_gametime()) ) 
  }
}


獻花 x0
引用 | 編輯 tw2twtw
2010-11-26 21:39
7樓
  
if 不是每秒判斷的

我不是要每秒判斷.......只是在某時某刻會出殭屍王.......((這樣會不會比較簡單?
如:SV回合設置3分鐘...在最後一分鐘時執行當屍王的指令.... ((不用顯示也可....

獻花 x0
引用 | 編輯 i-c0112
2010-11-27 11:21
8樓
  
下面是引用 tw2twtw 於 2010-11-26 21:39 發表的 : 到引言文
if 不是每秒判斷的

我不是要每秒判斷.......只是在某時某刻會出殭屍王.......((這樣會不會比較簡單?
如:SV回合設置3分鐘...在最後一分鐘時執行當屍王的指令.... ((不用顯示也可....
我當然知道if不是每秒判斷的= ="
只是這裡只給片段源碼不好改

可以在回合開始時用set_task
或是在RoundTime的event裡判斷時間

獻花 x0
引用 | 編輯 tw2twtw
2010-11-27 23:30
9樓
  
那我還是給全部原碼好了......
指令在2382行.......

順便問一下..... set_task(60.0, " " ) 後面的是執行的public ?

本帖包含附件
檔名: zip zombiehell20.rar   (2022-06-09 14:16 / 29 KB)   下載次數:2 需要威望:50


獻花 x0
引用 | 編輯 IGLA_VIP
2011-08-08 15:10
10樓
  
什麼文章?

獻花 x0