AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   check client disconnect or team == 0 ? (https://forums.alliedmods.net/showthread.php?t=293333)

abdobiskra 01-29-2017 12:30

check client disconnect or team == 0 ?
 
Hi
i have problem here in round_think this code check if zombie or human won or dead (spectate) to end the round .. but when zombie or human disconnect (this mean zombie or human == 0 ) the round does not end
myb is there two way to check it ... as i think !
1) check evry teams when becom 0
2) check it in client_disconnect function

Can I find a particular example of this or myb other ways ..?
game: valve
PHP Code:

set_task(0.1" round_think")
........
.....
public 
round_think(){
    static 
minsmins roundtime/60
    
static secssecs roundtime-mins*60
    set_hudmessage
(02550, -1.00.3006.012.0)
    
show_hudmessage(0"%d:%.2d",mins,secs)    // help me pls
    
    
roundtime--
    
    if(!
g_zombies&&infection){
        
round_end(2)
        
        return 
PLUGIN_CONTINUE
    
}else if(!g_humans){
        
round_end(1)
        
        return 
PLUGIN_CONTINUE
    
}
    
    if(
roundtime)
        
set_task(1.0,"round_think")
    else
        
round_end(0)
        
    return 
PLUGIN_CONTINUE
}
public 
round_end(wins){
    
g_zombies 0
    g_humans 
0
    infection 
false
    
    set_hudmessage
(255255212, -1.00.3006.012.0)
    switch(
wins){
        case 
0show_hudmessage(0,"Round Draw")
        case 
1show_hudmessage(0,"Zombies wins!)
        case 2: show_hudmessage(0,"
Humans wins!")
    }
    
    set_task(5.0,"
round_start")



edon1337 01-29-2017 13:10

Re: check client deconnect or team == 0 ?
 
1) If the code is uncompleted, how can we help ?
2) Why to use tasks when you have events ?
3) Indent your code properly.
4) Your set_task usage is wrong, you have to use "b" flag to make it repeatable.
5) No need to return PLUGIN_CONTINUE.

If I understood right, you just want to check when Zombies/Humans win so you can display a HUD message ?

abdobiskra 01-29-2017 13:24

Re: check client deconnect or team == 0 ?
 
Quote:

Originally Posted by edon1337 (Post 2490894)
1) If the code is uncompleted, how can we help ?

I think I explained what the problem thing that is not clear?

Quote:

Originally Posted by edon1337 (Post 2490894)
2) Why to use tasks when you have events ?

bcz i said up :
Quote:

game: valve
dont have events
Quote:

Originally Posted by edon1337 (Post 2490894)
3) Indent your code properly.

i dont share the code to fix it ..only to illustrate the problem bcz the code work for me perfect only this problem as i said up (when players deconnected for any (teams == 0)
Quote:

Originally Posted by edon1337 (Post 2490894)
4) Your set_task usage is wrong, you have to use "b" flag to make it repeatable.

Yes myb but i used other way look in code :
Quote:

PHP Code:

    if(roundtime)
        
set_task(1.0,"round_think")
    else
        
round_end(0


Quote:

Originally Posted by edon1337 (Post 2490894)
5) No need to return PLUGIN_HANDLED.

I do not use it?

Quote:

Originally Posted by edon1337 (Post 2490894)
If I understood right, you just want to check when Zombies/Humans win so you can display a HUD message ?

no not exactly what you understood .. and about hud msg look in round_end i used it ?

I hope that the idea becomes clear

edon1337 01-29-2017 13:33

Re: check client deconnect or team == 0 ?
 
1) With that English? Yeah smoothly explained.
2) What kind of game is Valve ?
3) Nobody would want to work with a code indented like that.
4) "Round Think"
PHP Code:

set_task(0.1" round_think"

5) PLUGIN_CONTINUE**
6)
Quote:

no not exactly what you understood
Then help me understand it.

abdobiskra 01-29-2017 14:28

Re: check client deconnect or team == 0 ?
 
1) Ok Sorry im little ENG and translate is bad to
2) valve -> HL1
3) i was trying to set short way
4) I did not understand what you intend to hint to him exactly
5) ok thx i will try that also
Quote:

Then help me understand it.
The problem, as described at UP .
ex:

g_human == team 1
g_zombie == team 2

im using systeam if players killed switched to spectator mod (like in CS rounds)

in round_think up :

PHP Code:

    if(!g_zombies&&infection){ //when zombies dead (0 zombie) humans won but dose not work when  deconnecte  (0 zombie)
        
round_end(2)
        
        return 
PLUGIN_CONTINUE
    
}else if(!g_humans){ // when humans dead (0 humans) zombie won but dose not work when  deconnecte  (0 humans)
        
round_end(2)        round_end(1)
        
        return 
PLUGIN_CONTINUE
    
}
    
    if(
roundtime)
        
set_task(1.0,"round_think"// this time round chek events evry 1 sec
    
else
        
round_end(0)// if time round == 0 round draw 


edon1337 01-29-2017 16:06

Re: check client deconnect or team == 0 ?
 
4) You're creating a task to act like a think, so that means it should be repeatable, but you didn't add the "b" flag which makes it repeatable, the current task will execute only once in 0.1 seconds. To make it execute every 0.1 second, you need to add "b" flag.
PHP Code:

set_task(0.1" round_think"___"b"

Doesn't it automatically set CT win if there's no T players?

abdobiskra 01-30-2017 02:26

Re: check client deconnect or team == 0 ?
 
Quote:

You're creating a task to act like a think, so that means it should be repeatable
4) Yes, it is working
im said :
Quote:

PHP Code:

if(roundtime)
set_task(1.0,"round_think"// this time round chek events evry 1 sec 


so this task return to check round_think function evry 1 sec if roundtime found (roundtime = 2*60 so = 2mn) ... and this 1 sec its the time countdown of round i dont need to change that

Quote:

Doesn't it automatically set CT win if there's no T players?
Yes, and vice versa, but when it disconnect of the server not in the round (bcz my cod up cant check disconnect players to end the round) its clear ?

gabuch2 01-30-2017 08:00

Re: check client deconnect or team == 0 ?
 
Quote:

Originally Posted by edon1337 (Post 2490946)
Doesn't it automatically set CT win if there's no T players?

There are no rounds in HLDM. (neither CTs or Ts)

The best way to do it is to check if there are no more players in a team when a client disconnects.

edon1337 01-30-2017 08:02

Re: check client disconnect or team == 0 ?
 
Wait, HLDM scripting isn't the same as CS ? I have never scripted for HL lol.

gabuch2 01-30-2017 08:14

Re: check client disconnect or team == 0 ?
 
It's the same but most stocks are made for CS and thus they will not work properly, so one has to rely on Fakemeta/Engine.


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

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