Raised This Month: $32 Target: $400
 8% 

[HELP] Constantly Check Something For 10 Seconds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoldNux
Senior Member
Join Date: Mar 2018
Old 04-16-2018 , 03:11   [HELP] Constantly Check Something For 10 Seconds
Reply With Quote #1

I would like to know a good way to check if a player has a grenade every 0.5 second, but only during freezetime.

Thanks!
__________________
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-16-2018 at 03:11.
GoldNux is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-16-2018 , 06:08   Re: [HELP] Constantly Check Something For 10 Seconds
Reply With Quote #2

Why check it when you can hook it on buy and drop or throw
__________________
@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
GoldNux
Senior Member
Join Date: Mar 2018
Old 04-16-2018 , 11:05   Re: [HELP] Constantly Check Something For 10 Seconds
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Why check it when you can hook it on buy and drop or throw
I did not find any such event, I will look again.

edit: can I use this?
Ham_AddPlayerItem


Thanks!
__________________
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-16-2018 at 11:11.
GoldNux is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-16-2018 , 12:27   Re: [HELP] Constantly Check Something For 10 Seconds
Reply With Quote #4

You should post what you are really trying to do, this looks like an XY problem.
__________________
klippy is offline
GoldNux
Senior Member
Join Date: Mar 2018
Old 04-16-2018 , 13:43   Re: [HELP] Constantly Check Something For 10 Seconds
Reply With Quote #5

Quote:
Originally Posted by KliPPy View Post
You should post what you are really trying to do, this looks like an XY problem.
There will surely be a much better plugin released soon enough as Natsheh and others are working on it, but until then I am trying to make my own version of this plugin because I want it on my server.

I am a beginner and I'm trying to learn by doing, so to keep it simple my plugin only aims to display what grenades players have at the moment.

Code:
/*     BUGS:         Sprite still spawns after freezetime is over. */ #include <amxmodx> #include <amxmisc> #include <amxmodx> #include <hamsandwich> #include <cstrike> #include <engine> #include <fun> #define PLUGIN "gn_shownades" #define VERSION "0.1" #define AUTHOR "GoldNux" #define TEST_SPRITE "sprites/ic5.spr" //#define HE_SPRITE "sprites/HE.spr" //#define FLASH_SPRITE "sprites/FLASH.spr" //#define SMOKE_SPRITE "sprites/SMOKE.spr" new freezeTime = 0 new g_test_sprite; //new g_he_sprite; //new g_flash_sprite; //new g_smoke_sprite; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("HLTV", "eventNewRound", "a", "1=0", "2=0");     RegisterHam(Ham_AddPlayerItem, "player", "eventPurchase");     register_cvar("gn_shownades", "0") } public plugin_precache() {     g_test_sprite = precache_model(TEST_SPRITE);     //g_he_sprite = precache_model(HE_SPRITE);     //g_flash_sprite = precache_model(FLASH_SPRITE);     //g_smoke_sprite = precache_model(SMOKE_SPRITE); } public eventNewRound() {     if (!get_cvar_num("gn_shownades"))         freezeTime = 1         new players[32]         new playercount, i         get_players(players, playercount)         for (i = 0; i < playercount; i++)         set_task(9.0, "removeSprites", players[i]) //Remove sprites when freezetime is over         return PLUGIN_CONTINUE } public eventPurchase() {     if (!get_cvar_num("gn_shownades") && freezeTime == 1)         return PLUGIN_CONTINUE         new players[32]         new playercount, i         get_players(players, playercount)         for (i = 0; i < playercount; i++)         set_task(0.0, "nadeCheck", players[i])         return PLUGIN_CONTINUE } public nadeCheck(id) {     if (is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR && !is_user_hltv(id))     {         if (user_has_weapon(id, CSW_HEGRENADE))         {             new vec1[3]             get_user_origin(id, vec1)                         message_begin(MSG_ALL, SVC_TEMPENTITY);             write_byte(TE_PLAYERATTACHMENT);             write_byte(id);             write_coord(45); //Find out how to place sprites next to each other             write_short(g_test_sprite); //Change to g_he_sprite             write_short(200);             message_end();         }         else if (user_has_weapon(id, CSW_FLASHBANG))         {             new vec1[3]             get_user_origin(id, vec1)                         message_begin(MSG_ALL, SVC_TEMPENTITY);             write_byte(TE_PLAYERATTACHMENT);             write_byte(id);             write_coord(45); //Find out how to place sprites next to each other             write_short(g_test_sprite); //Change to g_flash_sprite             write_short(200);             message_end();         }         else if(user_has_weapon(id, CSW_SMOKEGRENADE))         {             new vec1[3]             get_user_origin(id, vec1)                         message_begin(MSG_ALL, SVC_TEMPENTITY);             write_byte(TE_PLAYERATTACHMENT);             write_byte(id);             write_coord(45); //Find out how to place sprites next to each other             write_short(g_test_sprite); //Change to g_smoke_sprite             write_short(200);             message_end();         }     }     return PLUGIN_CONTINUE } public removeSprites(id) {     message_begin(MSG_ALL, SVC_TEMPENTITY);     write_byte(TE_KILLPLAYERATTACHMENTS)     write_byte(id)     message_end();     freezeTime = 0 }
__________________
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-16-2018 at 13:47.
GoldNux is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 04-16-2018 , 14:43   Re: [HELP] Constantly Check Something For 10 Seconds
Reply With Quote #6

If AddPlayerItem doesn't work for you, try to hook Money event (when player buys item) and check if he has grenade now.
__________________
My English is A0
E1_531G is offline
Reply


Thread Tools
Display Modes

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 02:51.


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