下面是引用 784063999 於 2010-11-04 17:34 發表的 :
我明白native怎用
但不明forward的用途"特定時機傳遞引數"
你能舉例說明一下
就以寫ZP插件最常用到的一個為例好了
zombieme(id, infector, nemesis, silentmode, rewards) //ZP中把人變殭屍的函數
{
......
......
// Post user infect forward
//就是在處理完一大堆關於變殭屍的過程後
//於此時告訴其他插件 id已被 infector感染,且是否變為復仇者(決定復仇者也是用此函數)
ExecuteForward(g_fwUserInfected_post, g_fwDummyResult, id, infector, nemesis)
// Last Zombie Check
fnCheckLastZombie()
}
對照到 .inc 檔
/**
* Called when a player gets infected.
*
* @param id Player index who was infected.
* @param infector Player index who infected him (if applicable).
* @param nemesis Whether the player was turned into a nemesis.
*/
forward zp_user_infected_post(id, infector, nemesis)
使用此forward的插件就會被執行
#include <amxmodx>
#include <zombieplague>
public zp_user_infected_post(id, infector, nemesis)
{
//控制台分別輸出此3個值就會是zp所傳過來的值
server_print("%d", id)
server_print("%d", infector)
server_print("%d", nemesis)
}