Raised This Month: $ Target: $400
 0% 

[HELP] How do I loop set_task for only a few seconds.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-21-2018 , 14:29   Re: [HELP] How do I loop set_task for only a few seconds.
Reply With Quote #1

1. Your register_event() is calling 'eventNewRound' and it should be 'FreezeTimeStart'.
2. You should call 1 set_task() in FreezeTimeStart and loop through all players within updatePlayerEconomy().
3. Include flags in get_players() to exclude bots and hltv and remove this check in updatePlayerEconomy().
4. Only call cs_get_user_team() once and set the value in a variable. Then do:
if ( CS_TEAM_T <= iTeam <= CS_TEAM_CT )
__________________

Last edited by Bugsy; 04-21-2018 at 14:31.
Bugsy is offline
GoldNux
Senior Member
Join Date: Mar 2018
Old 04-22-2018 , 07:32   Re: [HELP] How do I loop set_task for only a few seconds.
Reply With Quote #2

Quote:
Originally Posted by Bugsy View Post
1. Your register_event() is calling 'eventNewRound' and it should be 'FreezeTimeStart'.
2. You should call 1 set_task() in FreezeTimeStart and loop through all players within updatePlayerEconomy().
3. Include flags in get_players() to exclude bots and hltv and remove this check in updatePlayerEconomy().
4. Only call cs_get_user_team() once and set the value in a variable. Then do:
if ( CS_TEAM_T <= iTeam <= CS_TEAM_CT )
Thank you for being so helpful and patient!

It is working, but I can't test it with bots for some reason.
Even without the "ch" flags.

The idea is, that the chat can display a maximum of 5 chat messages.
So while playing 5 vs 5, as long as it prints every message in the same order it will look pretty good.
Very strange that my previously very similar code makes bots print it, but not this.. Oh well!

Here is the code for anyone else doing something similar in the future.
Thanks again @Bugsy I really appreciate it!
Code:
#include <amxmodx> #include <cstrike> new g_pFreezeTime; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("HLTV" , "FreezeTimeStart" , "a" , "1=0" , "2=0");     g_pFreezeTime = get_cvar_pointer("mp_freezetime"); } public FreezeTimeStart() {     set_task(1.0,"updatePlayerEconomy", .flags="a", .repeat=get_pcvar_num(g_pFreezeTime)); } public updatePlayerEconomy() {     new players[32];     new playercount, i;     get_players(players, playercount, "ch");     for (i=0; i<playercount; i++)         if (cs_get_user_team(players[i]) != CS_TEAM_SPECTATOR)         {             client_cmd(players[i],"say_team $ %d",cs_get_user_money(players[i]))         } }
__________________
Try my version of de_dust2, I think it's great and you should check it out!
https://gamebanana.com/mods/83731

Last edited by GoldNux; 04-22-2018 at 08:09.
GoldNux is offline
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 04:39.


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