AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved how to reset money on new round? (https://forums.alliedmods.net/showthread.php?t=332724)

kww 05-29-2021 01:30

how to reset money on new round?
 
trying to reset money on round start but nothing happens other than resetting the variable swapTeamsQueried.
No errors are thrown
PHP Code:

public onRoundStart()
    if(
swapTeamsQueried) {
        
swapTeamsQueried false
        set_task
(0.1"resetMoney")
    }
    
public 
resetMoney() {
    new 
players[32], playerCount
    get_players
(playersplayerCount"h"// exclude hltv, but is needed?
    
new money get_pcvar_num(mp_startmoney)
    for(new 
0playerCounti++) {
        
cs_set_user_money(players[i], money)
    }



redivcram 05-29-2021 04:53

Re: how to set money?
 
Where are you calling resetMoney() from? Judging by tyour question... Shouldn't you call it inside roundStart() hook?

kww 05-29-2021 05:40

Re: how to set money?
 
Quote:

Originally Posted by redivcram (Post 2748151)
Where are you calling resetMoney() from? Judging by tyour question... Shouldn't you call it inside roundStart() hook?

maybe, but if i want to execute this code from somewhere else? why can't I call this 0.1 seconds after the start of the round? It's not working even if I calling it from onRoundStart()

Natsheh 05-29-2021 06:46

Re: how to set money?
 
How are you hooking round start?

kww 05-29-2021 07:05

Re: how to set money?
 
Quote:

Originally Posted by Natsheh (Post 2748159)
How are you hooking round start?

Code:

register_event("HLTV", "onRoundStart", "a", "1=0", "2=0")

Natsheh 05-29-2021 09:06

Re: how to set money?
 
Alright add a delay of 2 seconds or more since there might be a conflict with round win money.

Bugsy 05-29-2021 12:05

Re: how to set money?
 
That event is for new round, not round start so you are getting the conflict as this is when the game distributes money (it's between new round and round start). Either instead call it at round start, or add a larger delay, like 0.5 or 1.0.

This is the round start event:
register_logevent("logevent_round_start", 2, "1=Round_Start")


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

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