AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Constantly Check Something For 10 Seconds (https://forums.alliedmods.net/showthread.php?t=306831)

GoldNux 04-16-2018 03:11

[HELP] Constantly Check Something For 10 Seconds
 
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!

Natsheh 04-16-2018 06:08

Re: [HELP] Constantly Check Something For 10 Seconds
 
Why check it when you can hook it on buy and drop or throw

GoldNux 04-16-2018 11:05

Re: [HELP] Constantly Check Something For 10 Seconds
 
Quote:

Originally Posted by Natsheh (Post 2587958)
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!

klippy 04-16-2018 12:27

Re: [HELP] Constantly Check Something For 10 Seconds
 
You should post what you are really trying to do, this looks like an XY problem.

GoldNux 04-16-2018 13:43

Re: [HELP] Constantly Check Something For 10 Seconds
 
Quote:

Originally Posted by KliPPy (Post 2588000)
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 }

E1_531G 04-16-2018 14:43

Re: [HELP] Constantly Check Something For 10 Seconds
 
If AddPlayerItem doesn't work for you, try to hook Money event (when player buys item) and check if he has grenade now.


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

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