AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Client_death and round_end (https://forums.alliedmods.net/showthread.php?t=220438)

GuskiS 07-10-2013 17:00

Client_death and round_end
 
I have a plugin that gives money to killer via client_death event. Other plugin checks money @ round_end event. But if is killed last player, round_end happens before client_death, so money isn't counted correctly. So the question is - should I use set_task in round_end or should I use other funcion to determine if player was killed and give him the money which happens before round_end?

EDIT: Or, could you tell me how long does new round starts after round_end is called? Because found new bug.

ConnorMcLeod 07-10-2013 17:21

Re: Client_death and round_end
 
You can use HLTV event (search for VEN tutorial), it happens 5.0 seconds after round end on normal ends, and 3.0 seconds after Game Commencing event.

GuskiS 07-10-2013 17:37

Re: Client_death and round_end
 
I've tried using HLTV event, but I cant give money with. Thx for the seconds.

ConnorMcLeod 07-11-2013 04:11

Re: Client_death and round_end
 
Sure you can, write what you want to do, show your code.

GuskiS 07-11-2013 05:16

Re: Client_death and round_end
 
PHP Code:

register_logevent("Round_Start"2"1=Round_Start")

public 
Round_Start()
{
    if(
RoundCount 2)
        return
    new 
players[32], pnum
    get_players
(playerspnum)
    for(--
pnumpnum >= 0pnum--)
    {
        new 
id players[pnum]
        if(!
is_user_connected(id))
            return
        new 
win get_pcvar_num(rm_win)
        new 
lose get_pcvar_num(rm_lose)

        if(
g_DidWin[id])
            
addMoney(idg_EndMoney[id], win)
        else 
addMoney(idg_EndMoney[id], lose)
        
g_DidWin[id] = false
    
}


Basicly, my script will check money player is carrying during round_end event, block any new round money and give exact money for victory or loss last round.

ConnorMcLeod 07-11-2013 15:25

Re: Client_death and round_end
 
Use HLTV event to store players money.
Block Money message from there.
Hook PlaybackEvent from HLTV event.
When PlaybackEvent is called, unhook it and unblock Money message, and set Players money to the value you want.

HLTV is called at new round, before player spawns and before money is given.
PlaybackEvent is called after that.

GuskiS 07-11-2013 18:51

Re: Client_death and round_end
 
Im new to all this, how do I hook it? And after that, unhook? Also, I blocked the money, how to unblock it?

ConnorMcLeod 07-12-2013 01:04

Re: Client_death and round_end
 
un/register_forward
set_msg_block(gmsgMoney, BLOCK_NOT/BLOCK_SET)

kungfulon 07-12-2013 01:14

Re: Client_death and round_end
 
Quote:

Originally Posted by GuskiS (Post 1987968)
But if is killed last player, round_end happens before client_death, so money isn't counted correctly.

Try using Ham_Killed forward.

GuskiS 07-12-2013 10:55

Re: Client_death and round_end
 
Ok, I finally got it to work, thank you for your help.
One more question. I have HLTV event, for cycle with get_players to get all players, after cycle there is register_forward. Problem is that register_forward is being executed before the cycle has stopped. Thats what my debug showed me:
PHP Code:

HLTVEvent()
{
  for(
blabla)
  
console_print(debug1)
console_print(debug2)
register_forward
}

fwPlaybackEvent()
{
for(
blabla)
  
console_print(debug3)
console_print(debug4)
unregister_forward


The output was:
debug2
debug4
debug1
debug3

Why is that?


All times are GMT -4. The time now is 06:24.

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