Raised This Month: $51 Target: $400
 12% 

Trap item for humans


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 12-16-2014 , 19:58   Trap item for humans
Reply With Quote #1

Can someone make extra item for humans,from this zombie class:

PHP Code:
/*================================================
Name: Quark Zombie
Description: Can Make a Trap. And Trap the Human.
Author: Dias
For: Zombie Plague Mod 4.3
================================================*/

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <fun>
#include <zombieplague>

new const zclass_name[] = "Quark Zombie"
new const zclass_info[] = "(G) To Put a Trap"
new const zclass_model[] = "zombie_classic1"
new const zclass_clawmodel[] = "v_knife_classic1.mdl"
const zclass_health 2000
const zclass_speed 250
const Float:zclass_gravity 1.0
const Float:zclass_knockback 1.0

// Main Trap Vars
new g_zquark
new bool:can_make_trap[33]
new 
bool:player_trapped[33]

new const 
trap_string[] = "trap"
new const trap_model[] = "models/zombie_plague/zombie_trap.mdl"

new cvar_cooldown
new cvar_trap_hp
new cvar_trap_time

public plugin_init()
{
    
register_plugin("[ZP] Zombie Class: Quark""1.2""Dias")
    
register_clcmd("drop""use_skill")
    
register_logevent("event_roundend"2"1=Round_End")
    
register_touch(trap_string"*""fw_touch")
    
register_forward(FM_PlayerPreThink"fw_think"0);

    
cvar_register()
}

public 
cvar_register()
{
    
cvar_cooldown register_cvar("qz_cooldown""45")
    
cvar_trap_time register_cvar("qz_trap_time""25")
    
cvar_trap_hp register_cvar("qz_trap_hp""2500")
}

public 
plugin_precache()
{
    
g_zquark zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)    
    
precache_model(trap_model)
}

public 
event_roundend(id)
{
    
can_make_trap[id] = false
    player_trapped
[id] = false
    
    remove_entity_name
(trap_string)
}

public 
zp_user_infected_post(victimattacker)
{
    if(
zp_get_user_zombie_class(victim) == g_zquark)
    {
        
client_print(victimprint_chat"[Quark Zombie] Press (G) to Put a Trap !!!")
        
can_make_trap[victim] = true
    
}
    if(
player_trapped[victim] == true)
    {
        
player_trapped[victim] = false
        remove_entity_name
(trap_string)
        
remove_task(victim)
    }
}

public 
use_skill(id)
{
    if(
is_user_alive(id) && zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zquark)
    {
        if(
can_make_trap[id])
        {
            
create_trap(id)
            } else {
            
client_print(idprint_chat"[Quark Zombie] You can't put the trap Now. Please Wait For %i"get_pcvar_num(cvar_cooldown))
        }
    }
}

public 
create_trap(id)
{
    new 
Float:Origin[3]
    
entity_get_vector(idEV_VEC_originOrigin)
    
    
Origin[2] -= 35.0
    
    
new trap create_entity("info_target")
    
entity_set_vector(trapEV_VEC_originOrigin)
    
//Origin[2] += 70.0
    //entity_set_vector(id, EV_VEC_origin, Origin)
    
    
entity_set_float(trapEV_FL_takedamage1.0)
    
entity_set_float(trapEV_FL_healthget_pcvar_float(cvar_trap_hp))
    
    
entity_set_string(trapEV_SZ_classnametrap_string)
    
entity_set_model(traptrap_model)    
    
entity_set_int(trapEV_INT_solid1)
    
    
entity_set_byte(trap,EV_BYTE_controller1,125);
    
entity_set_byte(trap,EV_BYTE_controller2,125);
    
entity_set_byte(trap,EV_BYTE_controller3,125);
    
entity_set_byte(trap,EV_BYTE_controller4,125);
    
    new 
Float:size_max[3] = {5.0,5.0,5.0}
    new 
Float:size_min[3] = {-5.0,-5.0,-5.0}
    
entity_set_size(trapsize_minsize_max)
    
    
entity_set_float(trapEV_FL_animtime2.0)
    
entity_set_float(trapEV_FL_framerate1.0)
    
entity_set_int(trapEV_INT_sequence0)
    
    
drop_to_floor(trap)
    
    
can_make_trap[id] = false
    set_task
(get_pcvar_float(cvar_cooldown), "reset_cooldown"id)
}

public 
reset_cooldown(id)
{
    if(
is_user_alive(id) && zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zquark)
    {
        if(
can_make_trap[id] == false)
        {
            
can_make_trap[id] = true
            client_print
(idprint_chat"[Quark Zombie] Now you can use your ability. Press (G)")
        }
    }    
}

public 
fw_touch(trapid)
{
    if(!
pev_valid(trap))
        return    
    
    if(
is_user_alive(id) && !zp_get_user_zombie(id))
    {
        new 
ent find_ent_by_class(0trap_string)
        
entity_set_int(entEV_INT_sequence1)
        
        
player_trapped[id] = true
        set_task
(get_pcvar_float(cvar_trap_time), "remove_trap"id)
    }
}

public 
remove_trap(id)
{
    
set_user_maxspeed(id, -1.0)
    
set_user_gravity(id1.0)
    
player_trapped[id] = false
    
    
new ent find_ent_by_class(0trap_string)
    
    
remove_entity(ent)
    
remove_task(id)
    
client_print(idprint_chat"Now. You are out of Trap")
}

public 
spawn_post(id)
{
    if(
is_user_alive(id))
    {
         
player_trapped[id] = false
         
    
}
}  

public 
fw_think(id)
{
    if(
is_user_alive(id) && player_trapped[id] == true)
    {
        
set_user_maxspeed(id0.1)
        
set_user_gravity(id10000.0)
    }

Krtola is offline
Send a message via Skype™ to Krtola
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-17-2014 , 01:10   Re: Trap item for humans
Reply With Quote #2

Just try below:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <fun>
#include <zombieplague>

new bool:buy_trap[33]
new 
bool:can_make_trap[33]
new 
bool:player_trapped[33]

new const 
trap_string[] = "trap"
new const trap_model[] = "models/zombie_plague/zombie_trap.mdl"

new g_itemid_trap
new cvar_cooldown
new cvar_trap_hp
new cvar_trap_time

public plugin_init()
{
    
register_plugin("[ZP] Trap""1.2""Dias")
    
    
g_itemid_trap zp_register_extra_item("Trap"25ZP_TEAM_HUMAN)
    
    
register_clcmd("drop""use_skill")
    
    
register_event("HLTV""event_round""a""1=0""2=0")
    
register_logevent("event_round"2"1=Round_End"
    
    
register_touch(trap_string"*""fw_touch")
    
register_forward(FM_PlayerPreThink"fw_think"0);

    
cvar_cooldown register_cvar("qz_cooldown""45")
    
cvar_trap_time register_cvar("qz_trap_time""25")
    
cvar_trap_hp register_cvar("qz_trap_hp""2500")
}

public 
plugin_precache()
{
    
precache_model(trap_model)
}

public 
event_round()
{
    
remove_entity_name(trap_string)
    
    new 
iPlayers[32], iPlayerCountiid
    get_players
(iPlayersiPlayerCount"a"
    for(
0iPlayerCounti++)
    {
        
id iPlayers[i]
        
        
buy_trap[id] = false
        can_make_trap
[id] = false
        player_trapped
[id] = false
    
}
}

public 
zp_extra_item_selected(iditemid)
{
    if (
itemid == g_itemid_trap)
    {
        
client_print(idprint_chat"[ZP] Press [G] to put a trap!")
        
buy_trap[id] = true
        can_make_trap
[id] = true
    
}
}

public 
zp_user_humanized_pre(idsurvivor)
{
    if(
player_trapped[id])
    {
        
player_trapped[id] = false
        remove_entity_name
(trap_string)
        
remove_task(id)
    }
}

public 
use_skill(id)
{
    if(
is_user_alive(id) && !zp_get_user_zombie(id) && buy_trap[id])
    {
        if(
can_make_trap[id])
        {
            
create_trap(id)
        } 
        else 
        {
            
client_print(idprint_chat"[ZP] You can't put the trap now! Please wait for %i!"get_pcvar_num(cvar_cooldown))
        }
    }
}

public 
create_trap(id)
{
    new 
Float:Origin[3]
    
entity_get_vector(idEV_VEC_originOrigin)
    
    
Origin[2] -= 35.0
    
    
new trap create_entity("info_target")
    
entity_set_vector(trapEV_VEC_originOrigin)
    
//Origin[2] += 70.0
    //entity_set_vector(id, EV_VEC_origin, Origin)
    
    
entity_set_float(trapEV_FL_takedamage1.0)
    
entity_set_float(trapEV_FL_healthget_pcvar_float(cvar_trap_hp))
    
    
entity_set_string(trapEV_SZ_classnametrap_string)
    
entity_set_model(traptrap_model)    
    
entity_set_int(trapEV_INT_solid1)
    
    
entity_set_byte(trap,EV_BYTE_controller1,125);
    
entity_set_byte(trap,EV_BYTE_controller2,125);
    
entity_set_byte(trap,EV_BYTE_controller3,125);
    
entity_set_byte(trap,EV_BYTE_controller4,125);
    
    new 
Float:size_max[3] = {5.0,5.0,5.0}
    new 
Float:size_min[3] = {-5.0,-5.0,-5.0}
    
entity_set_size(trapsize_minsize_max)
    
    
entity_set_float(trapEV_FL_animtime2.0)
    
entity_set_float(trapEV_FL_framerate1.0)
    
entity_set_int(trapEV_INT_sequence0)
    
    
drop_to_floor(trap)
    
    
can_make_trap[id] = false
    set_task
(get_pcvar_float(cvar_cooldown), "reset_cooldown"id)
}

public 
reset_cooldown(id)
{
    if(
is_user_alive(id) && !zp_get_user_zombie(id))
    {
        if(
can_make_trap[id] == false)
        {
            
can_make_trap[id] = true
            client_print
(idprint_chat"[ZP] Now you can use your ability. Press [G]!")
        }
    }    
}

public 
fw_touch(trapid)
{
    if(!
pev_valid(trap))
        return    
    
    if(
is_user_alive(id) && zp_get_user_zombie(id))
    {
        new 
ent find_ent_by_class(0trap_string)
        
entity_set_int(entEV_INT_sequence1)
        
        
player_trapped[id] = true
        
        set_task
(get_pcvar_float(cvar_trap_time), "remove_trap"id)
    }
}

public 
remove_trap(id)
{
    
player_trapped[id] = false
     
    set_user_gravity
(id1.0)
    
    new 
ent find_ent_by_class(0trap_string)
    
    
remove_entity(ent)
    
remove_task(id)
    
client_print(idprint_chat"Now. You are out of Trap")


public 
fw_think(id)
{
    if(
is_user_alive(id) && player_trapped[id])
    {
        
set_user_gravity(id10000.0)
    }


Last edited by zmd94; 12-17-2014 at 10:04.
zmd94 is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 12-17-2014 , 04:04   Re: Trap item for humans
Reply With Quote #3

Not working as expected.
[ZP] You can't put the trap now! Please wait for...This occurs,but I have not bought this extra item.
Trap stay on ground in next round.
Krtola is offline
Send a message via Skype™ to Krtola
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-17-2014 , 05:06   Re: Trap item for humans
Reply With Quote #4

I have updated the code.

Last edited by zmd94; 12-17-2014 at 05:07.
zmd94 is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 12-17-2014 , 05:14   Re: Trap item for humans
Reply With Quote #5

Quote:
Originally Posted by zmd94 View Post
I have updated the code.
I can set trap only if buy this extra item,and that is ok.
But I constantly getting that message, but I have not bought traps.

PHP Code:
client_print(idprint_chat"[ZP] You can't put the trap now! Please wait for %i!"get_pcvar_num(cvar_cooldown)) 

Last edited by Krtola; 12-17-2014 at 05:15.
Krtola is offline
Send a message via Skype™ to Krtola
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-17-2014 , 05:33   Re: Trap item for humans
Reply With Quote #6

I have fixed that problem. Feel free to test it again.

Last edited by zmd94; 12-17-2014 at 05:37.
zmd94 is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 12-17-2014 , 05:58   Re: Trap item for humans
Reply With Quote #7

Quote:
Originally Posted by zmd94 View Post
I have fixed that problem. Feel free to test it again.
Ok.
But maybe we dont need public reset_cooldown(id)
That function is important for zombie class but for extra item i think no.
Krtola is offline
Send a message via Skype™ to Krtola
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-17-2014 , 06:41   Re: Trap item for humans
Reply With Quote #8

Cooldown is important to prevent player from continuously make a trap as we don't have a code to limit the trap usage.

Last edited by zmd94; 12-17-2014 at 06:41.
zmd94 is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 12-17-2014 , 06:56   Re: Trap item for humans
Reply With Quote #9

Quote:
Originally Posted by zmd94 View Post
Cooldown is important to prevent player from continuously make a trap as we don't have a code to limit the trap usage.
Main problem is - zombie stay in trap FOREVER
Krtola is offline
Send a message via Skype™ to Krtola
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-17-2014 , 07:54   Re: Trap item for humans
Reply With Quote #10

Alright. Just try to change this:
PHP Code:
public fw_touch(trapid)
{
    if(!
pev_valid(trap))
        return    
    
    if(
is_user_alive(id) && zp_get_user_zombie(id))
    {
        new 
ent find_ent_by_class(0trap_string)
        
entity_set_int(entEV_INT_sequence1)
        
        
player_trapped[id] = true
        set_task
(get_pcvar_float(cvar_trap_time), "remove_trap"id)
    }
}

public 
remove_trap(id)
{
    
set_user_maxspeed(id, -1.0)
    
set_user_gravity(id1.0)
    
player_trapped[id] = false
    
    
new ent find_ent_by_class(0trap_string)
    
    
remove_entity(ent)
    
remove_task(id)
    
client_print(idprint_chat"Now. You are out of Trap")

-->
PHP Code:
public fw_touch(trapid)
{
    if(!
pev_valid(trap))
        return    
    
    if(
is_user_alive(id) && zp_get_user_zombie(id))
    {
        new 
ent find_ent_by_class(0trap_string)
        
entity_set_int(entEV_INT_sequence1)
        
        
player_trapped[id] = true
        set_task
(get_pcvar_float(cvar_trap_time), "remove_trap"id)
    }
}

public 
remove_trap(id)
{
    if(
is_user_alive(id) && zp_get_user_zombie(id))
    {
        
player_trapped[id] = false
        
        set_user_maxspeed
(id, -1.0)
        
set_user_gravity(id1.0)
       
        new 
ent find_ent_by_class(0trap_string)
        
        
remove_entity(ent)
        
remove_task(id)
        
client_print(idprint_chat"Now. You are out of Trap")
    }

zmd94 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode