Raised This Month: $ Target: $400
 0% 

problem with task


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 12-17-2009 , 12:08   problem with task
Reply With Quote #1

hey,

i added a counter in
Code:
register_logevent("startround",2,"0=World triggered","1=Round_Start")
but my counter plays a little silly.

it should work every 1 sec. but the counter willbe for example : 30, 25, 18,10,5,2,1,0!

i dont realy know why its so

PHP Code:
register_logevent("startround",2,"0=World triggered","1=Round_Start")

public 
startround() 
{
    if(
enable
    {            
        if(
trueround)
            
round++
            
        
trueround false
        counter 
floatround(30.0);
        
set_task(1.0"countdown"412566""0"b")
    }
}

public 
countdown(id)
{
    
set_hudmessage(2552000.100.5001.01.00.20.29);
    
counter--;
    if(
counter >= 0)
    {
        
show_hudmessage(0"%d"counter);
    }
    else
    {
        
remove_task(id)
        for(
id 1id <= maxplayersid++)
        {
            if(
team[id-1] == 1)
            {
                if(
is_user_alive(id))
                {
                    
give_item(id"weapon_knife");
                    
give_item(id"weapon_deagle");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"weapon_m4a1");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
set_user_godmode(id,1)
                }
            }
            else
            {
                if(
is_user_alive(id))
                {
                    
set_user_health(id,10)
                    
strip_user_weaponsid );
                    
give_itemid"weapon_knife" );
                    
client_print(id,print_chat,"freeze!")
                }
            }
        }
        
    }

ps. tried the task so too :

PHP Code:
set_task(1.0"countdown"id""0"b")

set_task(1.0"countdown"0""0"b")

set_task(1.0"countdown"412566""0"b"
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-17-2009 , 13:29   Re: problem with task
Reply With Quote #2

Make sure no task exists when you set a new one (just send remove_task)

Also, use get_players and cstrike module avaible natives (cs_set_user_bpammo).

PHP Code:
register_logevent("startround",2,"0=World triggered","1=Round_Start")

public 
startround() 
{
    if(
enable
    {            
        if(
trueround)
            
round++
            
        
trueround false
        counter 
30;
        
remove_task(412566)
        
set_task(1.0"countdown"412566""0"b")
    }
}

public 
countdown(task_id)
{
    
set_hudmessage(2552000.100.5001.01.00.20.21);

    
//if(counter-- >= 0)
    
if(--counter 0)
    {
        
show_hudmessage(0"%d"counter);
    }
    else
    {
        
remove_task(task_id)
        new 
players[32], inumid
        get_players
(playersinum)
        for(new 
ii<inumi++)
        {
            
id players[i]
            if( 
is_user_alive(id) )
            {
                if( 
cs_get_user_team(id) == CS_TEAM_T )
                {
                    
give_item(id"weapon_knife");
                    
give_item(id"weapon_deagle");
                    
cs_set_user_bpammo(idCSW_DEAGLE35);
                    
give_item(id"weapon_m4a1");
                    
cs_set_user_bpammo(idCSW_M4A190);
                    
set_user_godmode(id,1);
                }
                else
                {
                    
set_user_health(id,10);
                    
strip_user_weaponsid );
                    
give_item(id"weapon_knife");
                    
client_print(id,print_chat,"freeze!");
                }
            }
        }
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 12-17-2009 , 14:20   Re: problem with task
Reply With Quote #3

ok thanks. but i cant understand why i dont have to - my counter?

i mean my counter is 30..
so i have to - my counter every sec.

counter--

can you please explain this for me?

EDIT: and i cant catch users team with cs_get_user_team because i defined my own teams.

team hiders and team catchers.
1 round are the Terrors the seekers/catchers
next round are the CTs the seekers/catchers.

here is the fullcode. can maybe help.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <screenfade_util>

#define HNS_FLAG ADMIN_KICK

new team_ct 1
new team_t 0
new bool:enable false    
new team[32]    
new 
points[2]        
new 
bool:trueround true
new round 0
new bool:firstspawn[32]
new 
statusMsg
new counter
new maxplayers
public plugin_init() 
{
    
register_plugin("Hide'n'Seek","6.0.1","One")
    
register_cvar("Hide'n'Seek","6.0.1",FCVAR_SERVER)
    
set_task(0.3,"load_cfg",0)
    
maxplayers get_maxplayers()
    
register_clcmd("say /hns_on","hns_enable",HNS_FLAG)
    
register_clcmd("say /hns_off","hns_off",HNS_FLAG)
    
register_srvcmd("hns_on","hns_enable")
    
register_srvcmd("hns_off","hns_off")
    
register_event("ResetHUD","resethud","be")
    
register_logevent("startround",2,"0=World triggered","1=Round_Start")
    
register_logevent("endround",2,"0=World triggered","1=Round_End")
    
register_logevent("gamestart",2,"0=World triggered","1=Game_Commencing")
    
register_logevent("restartround",2,"1&Restart_Round_")
    
statusMsg get_user_msgid("StatusText")
}
public 
reset_stats(id
{
    
team[id-1] = 0
}
public 
Seeker_Nums() 
{
    new 
count 0
    
for(new i=1;i<33;i++)
        if(
team[i-1] == && is_user_connected(i) && is_user_alive(i))
            
count++
    
    return 
count
}
public 
Hider_Num() 
{
    new 
count 0
    
for(new i=1;i<33;i++)
        if(
team[i-1] == && is_user_connected(i) && is_user_alive(i))
            
count++
    
    return 
count
}
public 
The_teams(id
{
    if(
get_user_team(id) == 1)
        
team[id-1] = team_t
    
else if(get_user_team(id) == 2)
        
team[id-1] = team_ct
}
public 
remove_hossis() 
{    
    new 
ent find_ent(0,"monster_hostage")
    while(
ent != 0
    {    
        
cs_set_hostage_foll(ent,0)
        
ent find_ent(ent,"monster_hostage")
    }
    
    
ent find_ent(0,"hostage_entity")
    while(
ent != 0
    {            
        
cs_set_hostage_foll(ent,0)
        
ent find_ent(ent,"hostage_entity")
    }
}
public 
hns_enable(id,level,cid
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    hns_on
(id)
    
    return 
PLUGIN_HANDLED
}
public 
load_cfg()
{
    new 
hns_cfg[256], cfgdir[128]
        
    
get_configsdir(cfgdir,127)    
    
format(hns_cfg,255,"%s/hns.cfg",cfgdir)
    if(
file_exists(hns_cfg)) 
    {
        
server_cmd("exec %s",hns_cfg)
        
server_exec()
    }
}
public 
hns_on(id
{
    if(
enable == true)
    {
        
client_print(id,print_chat,"[ hns 6.0.1 ] The Mod is active !")
    }
    else 
    {
        
enable true
        
        
        
for(new i=1;i<33;i++) 
        {
            
team_ct 1
            team_t 
0
            reset_stats
(i)
        }
        
        
points[0] = 0
        points
[1] = 0
        
        
for(new i=1;i<=get_maxplayers();i++)
            if(
is_user_connected(i)) 
            {
                
client_cmd(i,"cl_forwardspeed 9999")
                
client_cmd(i,"cl_sidespeed 9999")
                
client_cmd(i,"cl_backspeed 9999")
                
client_cmd(i,"hud_centerid 0")
            }
        
set_cvar_num("sv_restartround",1)
    }
}
public 
hns_off(id,level,cid
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
    
    
if(enable == false)
        
client_print(id,print_chat,"[ hns 6.0.1 ] The Mod is deactive!")
    else 
    {
        
enable false
        remove_task
(1000)
        
remove_task(6000)
        
remove_task(7000)
        
remove_task(8000)
        
        
trueround true
        round 
0
        
        
for(new i=1;i<33;i++)
            if(
is_user_connected(i))
                
set_user_rendering(i)
            
        
set_cvar_num("sv_restartround",1)
    }
        
    return 
PLUGIN_HANDLED
}
public 
show_message(id,text[]) 
{
    
message_begin(MSG_ONE,statusMsg,{0,0,0},id)
    
write_byte(0)
    
write_string(text)
    
message_end()
}
public 
resethud(id
{
    if(
enable
    {
        
client_cmd(id,"cl_forwardspeed 9999")
        
client_cmd(id,"cl_sidespeed 9999")
        
client_cmd(id,"cl_backspeed 9999")
        
client_cmd(id,"hud_centerid 0")
        
        
set_task(0.1,"apply",id)
        
        if(
firstspawn[id-1]) 
        {
            
client_print(id,print_chat,"[ hns 6.0.1 ] Welcome, [H]ave [F]un & [G]ood [L]uck !")
            
client_print(id,print_chat,"[ hns 6.0.1 ] Say '!stats' for see the Statesboard and '!help' if you need HELP!")
        }
    }
    
    
firstspawn[id-1] = false
}
public 
apply(id
{
    
The_teams(id)

    if(
team[id-1] == 1)
    {
        
UTIL_ScreenFade(id_1.030.0255FFADE_OUT
        
client_print(id,print_chat,"[ hns 6.0.1 ] You are now a SEEKER. You have to hns. Go,Go,Go...")
    }
    else
    {
        
client_print(id,print_chat,"[ hns 6.0.1 ] You have now to HIDE,Take care...")
    }
}
public 
client_PreThink(id
{
    if(
enable)
    {
        
//Give B-Hop?
    
}
}
public 
gamestart() 
{
    
restartround()
}
public 
restartround() 
{
    for(new 
i=1;i<33;i++) 
    {
        
team_ct 1
        team_t 
0
        reset_stats
(i)
    }
        
    
points[0] = 0
    points
[1] = 0
    
    round 
0
    trueround 
true
}
public 
countdown(id)
{
    
set_hudmessage(2552000.100.5001.01.00.20.29);
    
counter--;
    if(
counter >= 0)
    {
        
show_hudmessage(0"%d"counter);
    }
    else
    {
        
remove_task(id)
        for(
id 1id <= maxplayersid++)
        {
            if(
team[id-1] == 1)
            {
                if(
is_user_alive(id))
                {
                    
give_item(id"weapon_knife");
                    
give_item(id"weapon_deagle");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"ammo_50ae");
                    
give_item(id"weapon_m4a1");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
give_item(id"ammo_556nato");
                    
set_user_godmode(id,1)
                }
            }
            else
            {
                if(
is_user_alive(id))
                {
                    
set_user_health(id,10)
                    
strip_user_weaponsid );
                    
give_itemid"weapon_knife" );
                    
client_print(id,print_chat,"freeze!")
                }
            }
        }
        
    }
}
public 
startround() 
{
    if(
enable
    {            
        if(
trueround)
            
round++
            
        
trueround false
        counter 
floatround(30.0);
        
set_task(1.0"countdown"412566""0"b")
    }
}
public 
endround()
{
    if(
enable
    {
        if(
team_ct == 1
        {
            
team_ct 0
            team_t 
1
        
}
        else 
        {
            
team_ct 1
            team_t 
0
        
}
        

        
trueround true
    
}
}
public 
client_disconnect(id
{
    
client_cmd(id,"cl_forwardspeed 400")
    
client_cmd(id,"cl_backspeed 400")
    
client_cmd(id,"cl_sidespeed 400")
    
reset_stats(id)
    
remove_task(id+10000)
    
firstspawn[id-1] = true
}
public 
client_putinserver(id
{
    
reset_stats(id)
    
firstspawn[id-1] = true

__________________

Last edited by One; 12-17-2009 at 14:31.
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 12-17-2009 , 15:34   Re: problem with task
Reply With Quote #4

Hey One,

Connor - the Counter in the

PHP Code:
if(--counter >
part. so its running. and for ur team problem why u use: id-1 and i-1 ? Oo u havn't -1 the id or i parts ;)
otherwise u getting wrong id nums


and instead of using: i<33 u may use

PHP Code:
maxplayers get_maxplayers() 
PHP Code:
for(new i=1;i<maxplayers;i++) 


this way u dont run till 32 players in the for loop

Last edited by platzpatrone; 12-17-2009 at 15:38.
platzpatrone is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 12-17-2009 , 15:43   Re: problem with task
Reply With Quote #5

ty. i tested the counter but only 1 min.! its the same.

and i tried to do it but i got every time any errors with teams.

new team[32]
new team[33]
new team[31]

the only 1 way to get the correct teams was to do 32-1 idk why. btw ill try again then i want to release my mod and dont like to see that the mod willbe unapproved or somthing else. ill test it again. ty.
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 12-17-2009 , 15:48   Re: problem with task
Reply With Quote #6

PHP Code:
new team[33

PHP Code:
public The_teams(id
{
    if(
get_user_team(id) == 1)
        
team[id] = team_t
    
else if(get_user_team(id) == 2)
        
team[id] = team_ct

if u use id-1 then u got for player id 1 -> 0

now u have some basics, just try and change ur code where id and i is with -1 lol

Last edited by platzpatrone; 12-17-2009 at 15:52.
platzpatrone is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 12-18-2009 , 08:12   Re: problem with task
Reply With Quote #7

yup this works but the same problem with task
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 12-18-2009 , 08:14   Re: problem with task
Reply With Quote #8

hmm what is the exactly problem ?
platzpatrone is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 12-18-2009 , 08:16   Re: problem with task
Reply With Quote #9

de : task spinnt oO die zeit geht manchmal so schnell. anstat 30 sekunden counter, habe ich 10 sekunden counter. geht zb. von 30 auf 20 und dann 15 dann 13. dann 2 dann 0 und counter ist fertig.

en : see first post

PS. there is the full code, you can try it by your self. wehen you are alone on server, its ok. or 1 bot ...but when you have more then 3-4 players/bots on server , the counter get crazy
__________________

Last edited by One; 12-18-2009 at 08:18.
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
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 18:24.


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