|
Senior Member
Join Date: May 2009
Location: Lithuania
|

06-24-2009
, 13:17
[ZP]extra items adding toogle
|
#1
|
Who could add a toogle to this plugin because its very uncomfortable to hold the binded key
Quote:
/*
[ZP] Extra Item : 3rd Person View
(ability for both teams)
by Fry!
Description :
Have You ever wanted to know what is going on behind You, when You are left alone or with some people?
Now You can for a small fee You can buy this ability to see whats going on around You. Bind [key] +view .
Cvars :
zp_view_cost "6" - How much this ability will cost tou You.
Commands :
say /bview - to buy this ability or use
say_team /bview - to buy it.
Credits :
Throstur - for his Third Person(and others) Viewmode plugin
Changelog :
26/10/2008 - v1.0 - First release
26/10/2008 - v1.1 - fixed bug that if had bought this ability and didn't get it
28/10/2008 - v1.2 - Added ability that now You can reset Your 3rd person view and set it back to normal and fixed some bugs.
28/10/2008 - v1.2.2 - removed some client print messages due it spam server. Fixed some other bugs.
27/11/2008 - v1.2.4 - added posibility that now you can press binded buton any time you want, removed reset function.
17/06/2009 - v1.2.8 - removed toggle cvar, removed useless events, removed useless lines, optimized code.
*/
#include <amxmodx>
#include <engine>
#include <zombieplague>
#define PLUGIN "[ZP] Extra Item : 3rd Person View"
#define VERSION "1.2.8"
#define AUTHOR "Fry!"
new g_item_name[] = "3rd Person View"
new g_itemid_view, g_view_cost
new bool:g_hasView[33], bool:g_hasView_reset[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("zp_extra_3rd_person_view",VERS ION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED| FCVAR_SPONLY)
g_view_cost = register_cvar("zp_view_cost", "6")
register_clcmd("say /bview", "fnView_Thirdperson")
register_clcmd("say_team /bview", "fnView_Thirdperson")
register_concmd("+view","cmd_view", ADMIN_USER, "bind [key] +view")
register_clcmd("-view","cmd_off")
g_itemid_view = zp_register_extra_item(g_item_name, get_pcvar_num(g_view_cost), 0)
register_event("DeathMsg", "Death", "a")
register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
}
public client_connect(id)
{
g_hasView[id] = false
g_hasView_reset[id] = true
}
public client_disconnect(id)
{
g_hasView[id] = false
g_hasView_reset[id] = true
}
public Death()
{
new id = read_data( 2 )
if ( g_hasView[id] )
set_view(id, CAMERA_NONE)
}
public event_new_round()
{
for (new i = 1; i <= 32; i++)
if ( g_hasView[i] )
set_view(i, CAMERA_NONE)
}
public cmd_view(player)
{
if ( !is_user_alive(player) || !g_hasView[player] )
return PLUGIN_HANDLED
g_hasView[player] = true
set_view(player, CAMERA_3RDPERSON)
return PLUGIN_CONTINUE
}
public cmd_off(player)
{
if ( !is_user_alive(player) || !g_hasView_reset[player] )
return PLUGIN_HANDLED
g_hasView_reset[player] = true
set_task(1.0, "fnView_Firstperson", player)
return PLUGIN_HANDLED
}
public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_view)
{
g_hasView[player] = true
client_print(player, print_chat, "[ZP] You have purchased 3rd Person View")
client_print(player, print_chat, "[ZP] To active your ability just (Bind [key] +view)")
}
}
public fnView_Firstperson(id)
{
if ( !is_user_alive(id) )
{
g_hasView_reset[id] = true
set_view(id, CAMERA_NONE)
}
if ( is_user_alive(id) && g_hasView_reset[id] )
{
g_hasView_reset[id] = true
set_view(id, CAMERA_NONE)
}
return PLUGIN_HANDLED
}
public fnView_Thirdperson(id)
{
if ( !is_user_alive(id) )
{
g_hasView[id] = false
client_print(id, print_chat, "[ZP] Dead people can't buy this ability")
}
if ( g_hasView[id] )
{
client_print(id, print_chat, "[ZP] You already have 3rd Person View")
return PLUGIN_HANDLED
}
new money = zp_get_user_ammo_packs(id)
new cost = get_pcvar_num(g_view_cost)
if ( money < cost )
{
client_print(id, print_chat, "[ZP] You don't have enough ammo packs", cost)
return PLUGIN_HANDLED
}
zp_set_user_ammo_packs(id, money - cost)
g_hasView[id] = true
set_view(id, CAMERA_3RDPERSON)
client_print(id, print_chat, "[ZP] You have purchased 3rd Person View")
client_print(id, print_chat, "[ZP] To active your ability just (Bind [key] +view)")
return PLUGIN_CONTINUE
}
public plugin_precache()
{
precache_model("models/rpgrocket.mdl")
}
|
|
|