PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
new CLASSNAME[] = "info_target"
new FILE[96]
new score[33]
new const WBMODEL[] = { "models/w_weaponbox.mdl" }
public plugin_init()
{
register_plugin("WB", "1.0", "redivcram")
register_touch("info_target", "player", "FwdPlayerTouchWeaponBox")
register_clcmd("wpbox_spawn", "cmd_wpboxspawn")
register_clcmd("wpbox_remove", "cmd_wpboxremove")
register_clcmd("wpbox_score", "cmd_score")
}
public plugin_precache()
{
precache_model(WBMODEL)
}
public cmd_wpboxspawn(id)
{
new origin[3]
get_user_origin(id, origin, 3)
wb_spawn(origin)
return PLUGIN_HANDLED
}
public cmd_wpboxremove(id)
{
new weaponbox = -1
while((weaponbox = find_ent_by_class(weaponbox, CLASSNAME)))
remove_entity(weaponbox)
return PLUGIN_HANDLED
}
wb_spawn(origin[3])
{
new weaponbox = create_entity(CLASSNAME)
if(!weaponbox)
return PLUGIN_HANDLED
new Float:vec[3]
IVecFVec(origin, vec)
entity_set_origin(weaponbox, vec)
entity_set_model(weaponbox, WBMODEL)
DispatchSpawn(weaponbox)
return PLUGIN_HANDLED
}
public FwdPlayerTouchWeaponBox(weaponbox, id)
{
score[id]++
client_print(id, print_chat, "You got 1 score for picking up a Weapon Box")
remove_entity(weaponbox)
return PLUGIN_HANDLED
}
Entity successfully spawns, whenever player touches it, doesn't do anything