Raised This Month: $51 Target: $400
 12% 

Solved how to reset money on new round?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 05-29-2021 , 01:30   how to reset money on new round?
Reply With Quote #1

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)
    }


Last edited by kww; 05-29-2021 at 17:17.
kww is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 05-29-2021 , 04:53   Re: how to set money?
Reply With Quote #2

Where are you calling resetMoney() from? Judging by tyour question... Shouldn't you call it inside roundStart() hook?
redivcram is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 05-29-2021 , 05:40   Re: how to set money?
Reply With Quote #3

Quote:
Originally Posted by redivcram View Post
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()

Last edited by kww; 05-29-2021 at 05:56.
kww is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-29-2021 , 06:46   Re: how to set money?
Reply With Quote #4

How are you hooking round start?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 05-29-2021 , 07:05   Re: how to set money?
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
How are you hooking round start?
Code:
register_event("HLTV", "onRoundStart", "a", "1=0", "2=0")
kww is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-29-2021 , 09:06   Re: how to set money?
Reply With Quote #6

Alright add a delay of 2 seconds or more since there might be a conflict with round win money.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-29-2021 , 12:05   Re: how to set money?
Reply With Quote #7

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")
__________________

Last edited by Bugsy; 05-29-2021 at 12:10.
Bugsy is online now
Old 05-29-2021, 16:43
kww
This message has been deleted by kww. Reason: TYSM for help
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 17:44.


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