Page 1 of 2

abaut waittill usage

Posted: Thu Apr 30, 2009 5:41 pm
by SilentAngel
can I do that:

Code: Select all

$PlayerListener.player waittill ($PlayerListener.player.status = "alive")
where $PlayerListener.player is the player and $PlayerListener.status is checked by a function that return it's status(alive or dead)
:?: :?: :?: :?:

more exactly my case is that:

Code: Select all

...
...
            if($PlayerListener[local.i].player.status == "dead")
            {
                $PlayerListener[local.i].player thread force_spectate
            }
        }
    }    
end
    
force_spectate:
    
    $PlayerListener.player waittill ($PlayerListener.player.status = "alive")
    
    switch($PlayerListener.player.team)
    {
        case "spectator":
            break
        case "allies":
            $PlayerListener.player spectator
...
...

Posted: Thu Apr 30, 2009 5:52 pm
by $oldier Of Ra
There's no such thing as the "status" command for players unless you wrote a script which defines and handles it.
Also there are only a few waittill commands and unlike CoD, the waittill command cannot wait for something you will define or have defined yourself. Only internal (= hard-coded) and defined changes for specific classes.

I once collected them all in one list:
http://www.modtheater.com/forum/showthr ... t=waittill

As you can see, most waittill commands for players only work in SP.

Posted: Thu Apr 30, 2009 6:47 pm
by SilentAngel

Code: Select all

    if(isAlive $PlayerListener[local.i].player)
    {
        $PlayerListener[local.i].player.status = "alive"
    }
    else if(!isAlive $PLayerListener[local.i].player && $PLayerListener[local.i].player.team != "spectator")
    {
        $PlayerListener[local.i].player.status = "dead"
        $PlayerListener[local.i].player.pool--
    }
that's how I defined .status...I did not posted the compleare scr couse it's too big, almost 500 lines..hard to read it online..
so how can I fix that, I need the player, after death, when he respawn again he becames a spectator..I'm thinking over that since 2 days but I can't get it to work! :evil:

Posted: Thu Apr 30, 2009 6:53 pm
by SilentAngel
well, I think I've a good idea!
I make a trigger that is linked to player and when he die the trigger is not triggerable, then, when he's alive the trigger becomes triggerable, and when triggerable change a var(for exemple local.player_spawned) to 1..of course when he die the var will return 0...humm I think it's gonna works..aint it?! :twisted:

Posted: Fri May 01, 2009 8:54 am
by $oldier Of Ra
What about something simpler ;)

Code: Select all

while($PlayerListener[local.i].player.health > 0)
       waitframe

println "he's dead"
Btw, why do you have a seperate array of all the players? $PlayerListener, does it have a function or advantage?

Posted: Fri May 01, 2009 9:38 am
by SilentAngel
I used listeners to players to detect players who left, join, die and everithing..well do you remember what I was trying to do with struct(when I asked if it's possible use it in moh scripts), whell I've used another way...this one:

Code: Select all

....
....
....
players_list_connector:       //connection between players and list

    for(local.i = 1; local.i <= $player.size; local.i++)
    {
        if($player[local.i].listener == NIL)
        {
            $player[local.i] waitthread list_creation
        }
    }        
end

list_creation:     // creating the listener
    
    local.player = self
    
    local.listener = spawn listener
    local.listener.targetname = "PlayerListener"
    local.listener.player = local.player
    local.player.listener = local.listener
    local.listener.player.name = local.player.netname
    local.listener.player.team = ""
    local.listener.player.status = ""
    local.listener.player.team = local.player.dmteam
    if(level.spawnpool_mode == 1)
        local.listener.player.pool = 10
    else
        local.listener.player.pool = NIL
    //player joined
end
....
....
....
that's the first time I use listeners, and I also used them to underseand them...hope to have done everything good! :)

Code: Select all

Code: 
while($PlayerListener[local.i].player.health > 0) 
       waitframe 
 
ahahah lol, you're right! that's simpler..and more efficient! :wink:

Posted: Fri May 01, 2009 9:41 am
by $oldier Of Ra
Ah, I see. But you don't even need listeners. Just make every player thread a thread that follows their state. But I guess everyone has their methods. I prefer using the statefiles.

Are you using Breakthrough? Or a patched SH?

Posted: Fri May 01, 2009 10:16 am
by SilentAngel
I've got a server in SH and one in AA..but since when I started scripting I no longer run them......just in case I got to test a mod..
however, I'm trying to make a mod similar to spawnpool in PA..have you ever seen it? however it's killing me, I still can't get it to work! I've problem in displaying pools with huddraw(that's the less importatnt problem), and checking the team win in all cases..it's almost all done now, bit still don't know how to detect the score of allies and axis...that's the last step..then it should work pretty good..I hope! if not I think I crash the PC out of the window! ahah :twisted:

Posted: Fri May 01, 2009 10:40 am
by $oldier Of Ra
Can you explain this 'game mode' or mod; spawnpool?

Posted: Fri May 01, 2009 11:35 am
by SilentAngel
ok..
so..
spawnpool stands for a max number of spawn that a team(allies/axis) has got.
the mod dipend on a cvar that you set on the cfg:
spawnpool 1 is automatic
spawnpool 2 is manual
automatic:
there's a spawnpool initial, when there's no player on the server, it's set to 1 for each team so that the first player who comes in can spawn.
then everytime someone join the game the spawnpool is increased of 10 for the team he join.
if a player leaves the spawnpool is decreased of a certain number:
when the player cames in he gives the team 10 spawns so when he leaves the team spawnpool is decreased of 10(I think I'm gonna change this part).
everytimes a player of a team dies and spawn the spawnpool of the team is -1.
manual:
if you set the cvar to 2(manual) you activate another cvar(s_pool_size) where you set the spawnpool size, this size will be the same for both teams.
in manual mode the size of the pool is not increased if a a player join the game.
but still decrease(for his own team) when a player dies.

then, is declared the cases in witch a team can win the match:
- if both spawnpool are finished:
the winner team is the one who kills all the other team's players.
- if time is finished:
the winner is the team with the higher spool remaning.
- time is 0 and both spool sizes are != 0, and there are still players alive in both teams:
the winner is the team with the higher score.

well, that's almost all, even if I would make something different in case of a gametipe != TDM

...I hope I've been clear enough to let you understeand(becouse of my english lol)

Posted: Fri May 01, 2009 12:17 pm
by $oldier Of Ra
I don't see any problem with detecting wins? You said you deduct and add from the "spawnreserves variable" when a player dies/leaves. So just check those 2 variables (I assume you have 1 per team.)

Posted: Fri May 01, 2009 12:22 pm
by SilentAngel
I've done it but I dunno how to detect teams socres..

Posted: Fri May 01, 2009 1:16 pm
by $oldier Of Ra
Aren't those the 'scores' or did I misunderstood some part?

Posted: Sat May 02, 2009 10:27 am
by SilentAngel
not exacrly..these are the cases where a team can win the match, with scores I mean the yellow number on the right top of the screen in TDM..I think it's calcolated..humm simething like kills/deaths of a team..but not sure, however that's what I have to detect and use to check a team winner in a particular case...

Posted: Sat May 02, 2009 11:00 am
by $oldier Of Ra
That's the fraglimit. You cannot retrieve any information from it. Except the fraglimit cvar but it won't help you.

Why do you need that? To determine the winning team with the highest kills when the time runs out? If that's the case then all you have to do just make sure level.clockside it set to "kills".