Raised This Month: $32 Target: $400
 8% 

[HELP] Optimize/rewtire plugin for ss2 jail


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 04-07-2012 , 13:53   [HELP] Optimize/rewtire plugin for ss2 jail
Reply With Quote #1

The main goal of this plugin is to open surf_ski_2 cell in X (Cvar) seconds is also done when a player is squatting he jumps because when a player is squatting, the cell can not be opened and bugs. All this work, the only thing that does not work with is the timer, my goal is when a player falls into his cell to go with this hud timer how many seconds remain until opened, and this timer starts after the closing of the cell.

For example, cvar-a is 30 seconds, 10 seconds pass and the player falls, it strikes him ... 20-19-18 1 and open, and only when close, restart the timer.

This is code:

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <engine>

new cvar_removetimejail_counterjaildoor_ent,syncFloat:jailopen_time

public plugin_init() 
{
    
register_plugin("Surf Ski 2 Auto Jail Opener""2.0""<VeCo>")
    
    new 
mapname[11]
    
get_mapname(mapname,10)
    
    if(!
equal(mapname,"surf_ski_2"))
    {
        
pause("ad")
        return
    }
    
    
cvar_removetime register_cvar("ss2_jail_remove_time","10")
    
    
jaildoor_ent find_ent_by_tname(-1,"jdoor")
    
    
sync CreateHudSyncObj()
    
    
register_touch("trigger_teleport","player","player_teleport")
    
    
RegisterHam(Ham_Blocked,"func_door_rotating","jdoor_blocked",1)
    
    
set_task(1.0,"jailent_counter",.flags "b")
}

public 
jdoor_blocked(ent)
{
    if(
ent != jaildoor_ent) return
    
    
jailopen_time get_gametime()
}

public 
jailent_counter()
{
    if((
get_gametime() - jailopen_time) <= 4.0) return
    
    ++
jail_counter
    
    
if(jail_counter != (get_pcvar_num(cvar_removetime) - 1))
    {
        static 
players[32],num
        get_players
(players,num)
        
        static 
i,ii
        
for(i=0;i<num;i++)
        {
            
ii players[i]
            
            static 
Float:origin[3]
            
entity_get_vector(ii,EV_VEC_origin,origin)
            
            if((-
628.0 origin[0] < -286.0) && (2996.0 origin[1] < 3298.0) && (596.0 origin[2] < 876.0))
            {
                
set_hudmessage(2552550, -1.0, -1.006.01.0)
                
ShowSyncHudMsg(ii,sync"Time before opening the jail: %i",get_pcvar_num(cvar_removetime) - jail_counter)
            }
        }
    }
    
    if(
jail_counter == get_pcvar_num(cvar_removetime))
    {
        
jail_counter 0
        open_jailent
()
    }
}

public 
open_jailent()
{
    
force_use(jaildoor_ent,jaildoor_ent)
    
    
jailopen_time get_gametime()
}

public 
player_teleport(ent,id)
{
    if(!
is_valid_ent(ent)) return
    
    static 
ent_name[6]
    
    
entity_get_string(ent,EV_SZ_targetname,ent_name,5)
    
    if(!
equal(ent_name,"j") && !equal(ent_name,"floor")) return
    
    
set_hudmessage(2552550, -1.0, -1.006.01.0)
    
ShowSyncHudMsg(id,sync"Time before opening the jail: %i",get_pcvar_num(cvar_removetime) - jail_counter)
}

public 
client_PreThink(id)
{
    if(!
is_user_alive(id)) return
    
    static 
ent
    ent 
entity_get_edict(id,EV_ENT_groundentity)
    
    if(!
is_valid_ent(ent)) return
    
    static 
ent_name[6]
    
    
entity_get_string(ent,EV_SZ_targetname,ent_name,5)
    
    if(!
equal(ent_name,"jdoor")) return
    
    static 
user_flags
    user_flags 
entity_get_int(id,EV_INT_flags)
    
    if((
user_flags FL_DUCKING) && (user_flags FL_ONGROUND))
    {
        
entity_set_edict(id,EV_ENT_groundentity,0)
        
        static 
Float:velocity[3]
        
entity_get_vector(id,EV_VEC_velocity,velocity)
        
        
velocity[2] += 300.0
                velocity
[0] = 0.0
                velocity
[1] = 0.0
        
        entity_set_vector
(id,EV_VEC_velocity,velocity)
    }

Lolz0r is offline
Reply


Thread Tools
Display Modes

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 19:01.


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