Raised This Month: $169 Target: $400
 42% 

set_task help2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Senior Member
Join Date: Nov 2020
Old 01-14-2021 , 00:42   set_task help2
Reply With Quote #1

Hello guys. I have this plugin. it's a plugin that create a barrier on mid and don't let counter-strike pass for 25 seconds of round(anti-rush plugin), but sometimes, for some players, don't work.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <ColorChat>
#include <hamsandwich>
#include <cstrike>

//Used for create_middle functions
#define tag_sprite_size_horizontal    4000
#define tag_sprite_size_vertical    600
#define tag_sprite_vertical_increments    15

#define MINNUM        2

new bool:stopplugin
new bool:rtime

static beamsprite

static CTspawn_loc[3]
static 
Tspawn_loc[3]

static 
plugin_enabledplugin_fenceplugin_2pplplugin_checktimeplugin_redrawtimeplugin_fencecolorplugin_fencealpha

static Float:farthest_point1[3]
static 
Float:farthest_point2[3]
static 
alivenummaxplayers

static Float:oldtime


static multiplier

public plugin_init()
{
    
register_plugin("No Rush","2.0","GHW_Chronic")
    
    
plugin_enabled register_cvar("NR_enabled","1")
    
plugin_fence register_cvar("NR_fence","1")
    
plugin_2ppl register_cvar("NR_twopeople","0")
    
plugin_checktime register_cvar("NR_checktime","0.5")
    
plugin_redrawtime register_cvar("NR_redrawtime","5.0")
    
plugin_fencecolor register_cvar("NR_fencecolor","red")
    
plugin_fencealpha register_cvar("NR_fencealpha","75")
    
    
stopplugin=true
    
new mapname[32]
    
get_mapname(mapname,31)
    new 
configfile[200]
    
get_configsdir(configfile,199)
    
format(configfile,199,"%s/no_rush_maps.ini",configfile)
    if(
file_exists(configfile))
    {
        new 
read[32], trash
        
for(new i=0;i<file_size(configfile,1);i++)
        {
            
read_file(configfile,i,read,31,trash)
            if(
equali(mapname,read))
            {
                
set_task(0.1,"spawn_locs")
                
set_task(0.2,"create_middle1")
                
oldtime get_pcvar_float(plugin_redrawtime)
                
stopplugin=false
                rtime
=true
                
break;
            }
        }
    }
    
    
register_event("DeathMsg","checknum","a")
    
register_event("ResetHUD","checknum","b")
    
//register_event("ResetHUD","roundstart","b")
    //register_event("HLTV", "roundstart", "a", "1=0", "2=0") 
    
register_logevent("roundstart"2"1=Round_Start"
    
register_logevent("client_task2"2"1=Round_Start")
    
register_clcmd("amx_try""count_down_warmup")

    
    
maxplayers get_maxplayers()
}

public 
client_task2(id){
    
    if(
rtime && !(task_exists(5012)) )
    {    
        
set_task(get_pcvar_float(plugin_checktime),"prethink",5012,"",0,"b")
    }
    
}

public 
roundstart(id){
    if(
get_pcvar_num(plugin_enabled) == && rtime){
        
stopplugin=false
        remove_task
1024 );
        
set_task25.0 "antirushoff" 1024);
        
ColorChat(idGREEN"^4[JoiNET]^1 Anti-rush plugin is ^4enabled^1!")
        
ColorChat(idGREEN"^4[JoiNET]^1 Counter-Terrorists can't rush for^4 25 seconds^1.")
    } 
}

public 
antirushoff(id){
    
    
stopplugin=true
    ColorChat
(0GREEN"^4[JoiNET]^1 Counter-Terrorists can rush now!")
    
}


public 
plugin_precache()
{
    
beamsprite precache_model("sprites/dot.spr")
}

public 
client_authorized(id)
{
    if(!
stopplugin)
    {
        
set_task(get_pcvar_float(plugin_checktime),"prethink",5012,"",0,"b")
    }
}

public 
client_disconnected(id)
{
    
remove_task(id)
}

public 
checknum()
{
    if(
get_pcvar_num(plugin_enabled) && !stopplugin)
    {
        static 
newnum
        
for(new i=0;i<=maxplayers;i++)
        {
            if(
is_user_alive(i)) newnum++
        }
        if(
alivenum>MINNUM && newnum<=MINNUM && get_pcvar_num(plugin_2ppl))
        {
            
ColorChat(0GREEN"^4[JoiNET]^1 You can now cross over to the other side since only 2 people remain.")
        }
        
alivenum=newnum
    
}
}

public 
prethink(id)
{
    if(
is_user_alive(id) && !stopplugin && get_pcvar_num(plugin_enabled) && !(alivenum<=MINNUM && get_pcvar_num(plugin_2ppl)) )
    {
        static 
origin[3]
        
get_user_origin(id,origin)
        if( 
get_distance(origin,Tspawn_loc)<get_distance(origin,CTspawn_loc) && cs_get_user_team(id) == CS_TEAM_CT )
        {
            
            static 
origin[3]
            
get_user_origin(id,origin)
            static 
Float:vector1[3]
            
            
vector1[0] = float(CTspawn_loc[0]) - origin[0]
            
vector1[1] = float(CTspawn_loc[1]) - origin[1]
            
vector1[2] = float(CTspawn_loc[2]) - origin[2]
            static 
Float:fNum;
            
fNum floatmax(floatsqroot( (vector1[0]*vector1[0] + vector1[1]*vector1[1] + vector1[2]*vector1[2]) ), 1.0
            
vector1[0] = (vector1[0] / fNum) * 700.0;
            
vector1[1] = (vector1[1] / fNum) * 700.0;
            
vector1[2] = (vector1[2] / fNum) * 700.0;
            
set_user_velocity(id,vector1)    
            
ColorChat(idGREEN"^4[JoiNET]^1 You^4 can't rush^1 when you are playing as a^4 Counter-Terrorist^1!")
            
            
        }
    }
}

public 
spawn_locs()
{
    new 
ent1 find_ent_by_class(0,"info_player_start")
    new 
ent2 find_ent_by_class(0,"info_player_deathmatch")
    if(!
ent1)
    {
        
log_amx("No info_player_start found")
        
stopplugin=true
    
}
    if(!
ent2)
    {
        
log_amx("No info_player_deathmatch found")
        
stopplugin=true
    
}
    static 
Float:CTspawn_loc_F[3]
    static 
Float:Tspawn_loc_F[3]
    
entity_get_vector(ent1,EV_VEC_origin,CTspawn_loc_F)
    
entity_get_vector(ent2,EV_VEC_origin,Tspawn_loc_F)
    
CTspawn_loc[0] = floatround(CTspawn_loc_F[0])
    
CTspawn_loc[1] = floatround(CTspawn_loc_F[1])
    
CTspawn_loc[2] = floatround(CTspawn_loc_F[2])
    
Tspawn_loc[0] = floatround(Tspawn_loc_F[0])
    
Tspawn_loc[1] = floatround(Tspawn_loc_F[1])
    
Tspawn_loc[2] = floatround(Tspawn_loc_F[2])
}

public 
create_middle1()
{
    
//***
    //Simple Algebra to calculate the location of the middle line(s).
    //***
    
    
new Float:CTspawn_loc_F[3]
    new 
Float:Tspawn_loc_F[3]
    
IVecFVec(CTspawn_loc,CTspawn_loc_F)
    
IVecFVec(Tspawn_loc,Tspawn_loc_F)
    
    new 
Float:line1_slope = (CTspawn_loc_F[1] - Tspawn_loc_F[1]) / (CTspawn_loc_F[0] - Tspawn_loc_F[0])
    new 
Float:line2_slope = -1.0 * (1.0 line1_slope)
    
    static 
Float:midpoint[3]
    
midpoint[0] = (CTspawn_loc_F[0] + Tspawn_loc_F[0]) / 2
    midpoint
[1] = (CTspawn_loc_F[1] + Tspawn_loc_F[1]) / 2
    midpoint
[2] = (CTspawn_loc_F[2] + Tspawn_loc_F[2]) / 2
    
    
if(floatabs(line2_slope)>1.0)
    {
        
farthest_point1[1] = midpoint[1] + (tag_sprite_size_horizontal 2)
        
farthest_point2[1] = midpoint[1] - (tag_sprite_size_horizontal 2)
        
        
farthest_point1[0] = (farthest_point1[1] - midpoint[1] + (line2_slope midpoint[0])) / line2_slope
        farthest_point2
[0] = (farthest_point2[1] - midpoint[1] + (line2_slope midpoint[0])) / line2_slope
    
}
    
    if(
floatabs(line2_slope)<=1.0)
    {
        
farthest_point1[0] = midpoint[0] + (tag_sprite_size_horizontal 2)
        
farthest_point2[0] = midpoint[0] - (tag_sprite_size_horizontal 2)
        
        
farthest_point1[1] = line2_slope*(farthest_point1[0]-midpoint[0]) + midpoint[1]
        
farthest_point2[1] = line2_slope*(farthest_point2[0]-midpoint[0]) + midpoint[1]
    }
    
    
farthest_point1[2] = midpoint[2] - (tag_sprite_size_vertical 2)
    
    
set_task(get_pcvar_float(plugin_redrawtime),"create_middle2",1337,"",0,"b")
}

public 
create_middle2()
{
    if(!
stopplugin && get_pcvar_num(plugin_fence) && get_pcvar_num(plugin_enabled) && !(alivenum<=MINNUM && get_pcvar_num(plugin_2ppl)))
    {
        
set_task(0.1,"create_middle3",0,"",0,"a",(tag_sprite_size_vertical tag_sprite_vertical_increments))
        
multiplier=1
    
}
    if(
oldtime!=get_pcvar_float(plugin_redrawtime))
    {
        
remove_task(1337)
        
set_task(get_pcvar_float(plugin_redrawtime),"create_middle1",1337,"",0,"b")
        
oldtime=get_pcvar_float(plugin_redrawtime)
    }
}

public 
create_middle3()
{
    new 
zpoint floatround(farthest_point1[2]) + (multiplier tag_sprite_vertical_increments)
    
multiplier++
    static 
color[32], redgreenblue
    get_pcvar_string
(plugin_fencecolor,color,31)
    if(
equali(color,"red"))
    {
        
red=255
        green
=0
        blue
=0
    
}
    else if(
equali(color,"blue"))
    {
        
red=0
        green
=0
        blue
=255
    
}
    else if(
equali(color,"white"))
    {
        
red=255
        green
=255
        blue
=255
    
}
    else if(
equali(color,"random"))
    {
        
red=random_num(0,255)
        
green=random_num(0,255)
        
blue=random_num(0,255)
    }
    else if(
equali(color,"Yellow"))
    {
        
red 255
        green 
255
        blue 
0
    
}
    else if(
equali(color,"Orange"))
    {
        
red 255
        green 
128
        blue 
64
    
}
    else if(
equali(color,"Pink"))
    {
        
red 255
        green 
0
        blue 
128
    
}
    else if(
equali(color,"Indigo"))
    {
        
red 0
        green 
255
        blue 
255
    
}
    else
    {
        
red=0
        green
=255
        blue
=0
    
}
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY
    
write_byte(0)        //TE_BEAMPOINTS
    
write_coord(floatround(farthest_point1[0]))
    
write_coord(floatround(farthest_point1[1]))
    
write_coord(zpoint)
    
write_coord(floatround(farthest_point2[0]))
    
write_coord(floatround(farthest_point2[1]))
    
write_coord(zpoint)
    
write_short(beamsprite)
    
write_byte(1)        // framestart
    
write_byte(1)        // framerate
    
write_byte(get_pcvar_num(plugin_redrawtime) * 10)// life in 0.1's
    
write_byte(5)        // width
    
write_byte(0)        // noise
    
write_byte(red)        // red
    
write_byte(green)    // green
    
write_byte(blue)    // blue
    
write_byte(get_pcvar_num(plugin_fencealpha))// brightness
    
write_byte(0)        // speed
    
message_end()

first time i was thinking that is a problem with task which don t set task on players when they join the server, so i made this
PHP Code:
public client_task2(id){    
    if(
rtime && !(task_exists(5012)) )
    {    
        
set_task(get_pcvar_float(plugin_checktime),"prethink",5012,"",0,"b")
    }    

but i still have same problem.

What's the problem and do you have some solutions for it?
lexzor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-14-2021 , 00:54   Re: set_task help2
Reply With Quote #2

Did you change 'id' to '5012' in set_task()?
PHP Code:
public client_authorized(id)
{
    if(!
stopplugin)
    {
        
set_task(get_pcvar_float(plugin_checktime),"prethink",5012,"",0,"b")
    }

__________________
Bugsy is offline
lexzor
Senior Member
Join Date: Nov 2020
Old 01-14-2021 , 01:34   Re: set_task help2
Reply With Quote #3

Yes, i was trying to resolve this bug
lexzor is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-14-2021 , 03:19   Re: set_task help2
Reply With Quote #4

Well you've kind ruined it.

Also why you have created Boolean rtime when it has the same purpose as Boolean stopplugin

And why do you have two hook functions for roundstart
__________________
@Jailbreak Main Mod v2.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Last edited by Natsheh; 01-14-2021 at 03:21.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
lexzor
Senior Member
Join Date: Nov 2020
Old 01-14-2021 , 06:39   Re: set_task help2
Reply With Quote #5

because stopplugin is called in another fuction and i needed a new boolean that check if the map is in no_rush_maps.ini and disable roundstart mesagge

if i wouldn t use that variable i couldn t disable roundstart
lexzor is offline
Old 01-17-2021, 04:03
lexzor
This message has been deleted by asherkin. Reason: Bump
Old 01-19-2021, 05:43
lexzor
This message has been deleted by asherkin. Reason: Bump
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 11:12.


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