Post by Argon #Svng on Jan 2, 2015 18:39:47 GMT
# Help
# Image- I want knockback to Model g_Shield
In this code found knockback in player model
I mean, when I put this code remove_entity(entity) & remove_entity_name(entclas) cs is Crashed
I want to put knockback in Model g_Shield !
Help Me please ! Give Me Code !
PHP Code:
#include <amxmodx>
#include <engine>
#include <cstrike>
#include <fakemeta_util>
#include <Colorchat>
#include <hamsandwich>
new cvar_knockback, cvar_timer, Block, g_Shield
new const entclas[] = "antifurien_shield"
public plugin_init()
{
register_plugin("[AntiFurien] Shield", "1.0", "EaGle & Medox*")
register_clcmd("say /sh","get_user_shield") // Cmd Get Shield
register_touch(entclas, "player", "knockback_touch") // Shield knockback_touch
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
cvar_timer = register_cvar("Countdown", "60.0") // Time Remove Shield
cvar_knockback = register_cvar("knockback", "25.0") // Shield knockback
}
public event_round_start(id) {
remove_entity_name(entclas)
}
public plugin_precache()
{
g_Shield = precache_model("models/s_shield.mdl") // Model Shield
}
public fw_PlayerKilled(victim, attacker, shouldgib)
{
remove_task(victim)
Block = false
}
public get_user_shield(id)
{
if(!(cs_get_user_team(id) == CS_TEAM_CT))
{
ColorChat(id, GREEN, "^4[M#G][Shield] ^1Only AntiFurien ^4!")
return
}
if(Block)
{
ColorChat(id, GREEN, "^4[M#G][Shield] ^1You already have a force field ^4!");
return
}
else if(!Block)
{
Block = true // Block Cmd Of 1 Round
set_task(0.1, "TaskShow_mdl", id, _, _, "b") // Create Shield
ColorChat(id, GREEN, "^4[M#G][Shield] ^1You Bought a force field ^4[%d sec]", get_pcvar_num(cvar_timer))
}
return
}
public TaskShow_mdl(id)
{
if(!is_user_alive(id)){
remove_task(id)
return
}
new origin[3]
get_user_origin(id, origin)
message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
write_byte(TE_SPRITE) // TE_SPRITE
write_coord(origin[0]) // x coordinate
write_coord(origin[1]) // y coordinate
write_coord(origin[2]-5) // z coordinate
write_short(g_Shield)
write_byte(5) // Scale
write_byte(200) // Brightnessi
message_end()
entity_set_string(id, EV_SZ_model, entclas)
entity_set_int(id, EV_INT_solid, SOLID_TRIGGER)
set_task(get_pcvar_float(cvar_timer), "DeleteShield", id)
}
public DeleteShield(entity)
{
if(is_valid_ent(entity))
remove_entity(entity)
remove_task(entity)
}
public knockback_touch(touched, toucher)
{
if(cs_get_user_team(toucher) == CS_TEAM_T)
{
new Float:pos_ptr[3], Float:pos_ptd[3], Float:push_power = get_pcvar_float(cvar_knockback)
pev(touched, pev_origin, pos_ptr)
pev(toucher, pev_origin, pos_ptd)
for(new i = 0; i < 2; i++)
{
pos_ptd[i] -= pos_ptr[i]
pos_ptd[i] *= push_power
}
set_pev(toucher, pev_velocity, pos_ptd)
set_pev(toucher, pev_impulse, pos_ptd)
}
}
#include <engine>
#include <cstrike>
#include <fakemeta_util>
#include <Colorchat>
#include <hamsandwich>
new cvar_knockback, cvar_timer, Block, g_Shield
new const entclas[] = "antifurien_shield"
public plugin_init()
{
register_plugin("[AntiFurien] Shield", "1.0", "EaGle & Medox*")
register_clcmd("say /sh","get_user_shield") // Cmd Get Shield
register_touch(entclas, "player", "knockback_touch") // Shield knockback_touch
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
cvar_timer = register_cvar("Countdown", "60.0") // Time Remove Shield
cvar_knockback = register_cvar("knockback", "25.0") // Shield knockback
}
public event_round_start(id) {
remove_entity_name(entclas)
}
public plugin_precache()
{
g_Shield = precache_model("models/s_shield.mdl") // Model Shield
}
public fw_PlayerKilled(victim, attacker, shouldgib)
{
remove_task(victim)
Block = false
}
public get_user_shield(id)
{
if(!(cs_get_user_team(id) == CS_TEAM_CT))
{
ColorChat(id, GREEN, "^4[M#G][Shield] ^1Only AntiFurien ^4!")
return
}
if(Block)
{
ColorChat(id, GREEN, "^4[M#G][Shield] ^1You already have a force field ^4!");
return
}
else if(!Block)
{
Block = true // Block Cmd Of 1 Round
set_task(0.1, "TaskShow_mdl", id, _, _, "b") // Create Shield
ColorChat(id, GREEN, "^4[M#G][Shield] ^1You Bought a force field ^4[%d sec]", get_pcvar_num(cvar_timer))
}
return
}
public TaskShow_mdl(id)
{
if(!is_user_alive(id)){
remove_task(id)
return
}
new origin[3]
get_user_origin(id, origin)
message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
write_byte(TE_SPRITE) // TE_SPRITE
write_coord(origin[0]) // x coordinate
write_coord(origin[1]) // y coordinate
write_coord(origin[2]-5) // z coordinate
write_short(g_Shield)
write_byte(5) // Scale
write_byte(200) // Brightnessi
message_end()
entity_set_string(id, EV_SZ_model, entclas)
entity_set_int(id, EV_INT_solid, SOLID_TRIGGER)
set_task(get_pcvar_float(cvar_timer), "DeleteShield", id)
}
public DeleteShield(entity)
{
if(is_valid_ent(entity))
remove_entity(entity)
remove_task(entity)
}
public knockback_touch(touched, toucher)
{
if(cs_get_user_team(toucher) == CS_TEAM_T)
{
new Float:pos_ptr[3], Float:pos_ptd[3], Float:push_power = get_pcvar_float(cvar_knockback)
pev(touched, pev_origin, pos_ptr)
pev(toucher, pev_origin, pos_ptd)
for(new i = 0; i < 2; i++)
{
pos_ptd[i] -= pos_ptr[i]
pos_ptd[i] *= push_power
}
set_pev(toucher, pev_velocity, pos_ptd)
set_pev(toucher, pev_impulse, pos_ptd)
}
}
Attached Files:
Get Fill: model.zip (40.49 KB)