下面是引用 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)
}