This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Team Glowing Sentry Guns


Post New Thread Reply   
 
Thread Tools Display Modes
Drak
Veteran Member
Join Date: Jul 2005
Old 04-02-2007 , 13:11   Re: Glowing Sentry Guns
Reply With Quote #11

The hud message would spam... (It's showing it every server frame...)
It would probably be overall better if you just made a command to enable/disable it.

I try'ed something really quick, no idea if it works. Plus, I also changed it to fakemeta for anyone that likes FM over engine.
Code:
/* * * Glowing Sentry Guns v1.0 * * Use amx_sgglow ~ Toggles sg glowing. * * For use in noob servers. Requires engine module. * */ #include <amxmodx> #include <fakemeta> #define PLUGIN "Glowing Sentry Guns" #define VERSION "1.0" #define AUTHOR "Rapid1Fire" new glowsg new i_like_4chan public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         glowsg = register_cvar("amx_glowsg","1"); } public server_frame() {     switch(get_pcvar_num(glowsg))     {         case 1:         {             if(i_like_4chan = 1)                 return PLUGIN_HANDLED                             set_task(1.0, "turnGlowOn", 205, "", 0, "b");             set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 6.0, 12.0);             show_hudmessage(0, "Glowing sentry guns have been turned on.");                         i_like_4chan = 1         }         case 2:         {             remove_task(205);             turnGlowOff();             set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 6.0, 12.0);             show_hudmessage(0, "Glowing sentry guns have been turned off.");             i_like_4chan = 0         }     } } public turnGlowOn() {     new glow;     glow = -1;     while((glow = engfunc(EngFunc_FindEntityByString,glow,"classname","building_sentrygun")))     {         //set_rendering(glow, kRenderFxGlowShell, 255, 255, 255, kRenderNormal, 125);         set_pev(glow,pev_renderfx,kRenderFxGlowShell)         set_pev(glow,pev_rendermode,kRenderNormal)         set_pev(glow,pev_rendercolor,255,255,255)         set_pev(glow,pev_renderamt,125)     } } public turnGlowOff() {     new glow;     glow = -1;     while((glow = engfunc(EngFunc_FindEntityByString,glow,"classname","building_sentrygun")))     {         //set_rendering(glow, kRenderFxGlowShell, 255, 255, 255, kRenderNormal, 0);         set_pev(glow,pev_renderamt,0)     } }

Quote:
Originally Posted by AMXX Doc
server_frame - Called once every server frame, may cause lag.

Last edited by Drak; 04-02-2007 at 13:19.
Drak is offline
Send a message via MSN to Drak
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 04-02-2007 , 13:13   Re: Glowing Sentry Guns
Reply With Quote #12

hmm...why? :/
You'r right...maybe an cvar..or :/! Code looks nice
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 04-02-2007 at 13:25.
Alka is offline
Rapid1Fire
Junior Member
Join Date: Apr 2007
Old 04-02-2007 , 17:02   Re: Glowing Sentry Guns
Reply With Quote #13

My original code did not spam the hud message. It only showed up when you changed the cvar to on or off. I will test Alka's pcvars fix and see if it does it on that.
Rapid1Fire is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 04-02-2007 , 17:14   Re: Glowing Sentry Guns
Reply With Quote #14

Oh, and i just noticed you made a task. The task would have to be stopped when you stop the glowing, or it wont do anything... (It might stop/glow over and over)
Code:
public turnGlowOff() {     new glow;     glow = -1;     while((glow = engfunc(EngFunc_FindEntityByString,glow,"classname","building_sentrygun")))     {         if(task_exists(205)) remove_task(205) // Stop the 'glowing' task         //set_rendering(glow, kRenderFxGlowShell, 255, 255, 255, kRenderNormal, 0);         set_pev(glow,pev_renderamt,0)     } }
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Rapid1Fire
Junior Member
Join Date: Apr 2007
Old 04-02-2007 , 17:17   Re: Glowing Sentry Guns
Reply With Quote #15

It doesent im going to try the fakemeta code, thanks! Sheesh I might as well make Alka and SixTwin the author
Rapid1Fire is offline
Rapid1Fire
Junior Member
Join Date: Apr 2007
Old 04-02-2007 , 17:37   Re: Glowing Sentry Guns
Reply With Quote #16

Ok none of the examples have worked without spamming the hud message except for the first one. I will put that one back for now.
Rapid1Fire is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 04-02-2007 , 18:41   Re: Glowing Sentry Guns
Reply With Quote #17

Well, it's because of:
Code:
 if(g_newCvarStatus != g_oldCvarStatus)
So if it's zero, don't go on. (Thus, not calling it over again)
And you are removing the task like you should, I never saw this since you must of had the other example.
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Rapid1Fire
Junior Member
Join Date: Apr 2007
Old 04-02-2007 , 20:12   Re: Glowing Sentry Guns
Reply With Quote #18

Im going to just leave it like it is because theres no problems and it runs fine.
Rapid1Fire is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 04-04-2007 , 18:59   Re: Glowing Sentry Guns
Reply With Quote #19

I would register a console command instead of monitoring a cvar with server_frame.

http://www.amxmodx.org/funcwiki.php?go=func&id=260
http://www.amxmodx.org/funcwiki.php?go=func&id=593
http://www.amxmodx.org/funcwiki.php?go=func&id=175

Here's a small tutorial:

http://wiki.amxmodx.org/Intro_to_AMX...Admin_Commands
__________________
My AMXX plugins (content date 2007-03-29, link check 2017-04-26)

Plugins for the Royston Vasey TFC server - These are UNSUPPORTED, except those which have been published at AMX Mod X.

Last edited by pizzahut; 04-04-2007 at 20:02.
pizzahut is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 04-05-2007 , 08:44   Re: Glowing Sentry Guns
Reply With Quote #20

Implemented console command and team colours.

Note that neither owner id nor team number is stored in the sentry entity keys, so the team colour is determined by the colour map key.

Feel free to use this code in your plugin.

Edit: You can add following code to plugin_init, depending on preference:
Code:
    // Turn glow on by default:     set_task(1.0, "turnGlowOn", 1, "", 0, "b")
Attached Files
File Type: sma Get Plugin or Get Source (GlowingSentryGuns.sma - 709 views - 1.7 KB)
__________________
My AMXX plugins (content date 2007-03-29, link check 2017-04-26)

Plugins for the Royston Vasey TFC server - These are UNSUPPORTED, except those which have been published at AMX Mod X.

Last edited by pizzahut; 04-06-2007 at 08:42. Reason: Put code into an attachment.
pizzahut 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 13:06.


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