Raised This Month: $ Target: $400
 0% 

New Plugin Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-14-2012 , 01:46   New Plugin Help
Reply With Quote #1

Hey there,
I want to know that how to make a cvar that will be changed according admin settings.
For example If we would like to display some text on screen using show_hudmessage,
Then we set a value for display time,But how to change it using cvar so anybody who does't know how to edit .sma file would easily change that thing using cvars,Also tell me how to register that cvar,Thanks....
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-14-2012 , 01:51   Re: New Plugin Help
Reply With Quote #2

http://www.amxmodx.org/funcwiki.php?go=func&id=1062

same shit as always, you just call it differently. You put the info in quotes.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-14-2012 , 01:56   Re: New Plugin Help
Reply With Quote #3

Quote:
Originally Posted by Liverwiz View Post
I still didn't get it....
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-14-2012 , 02:10   Re: New Plugin Help
Reply With Quote #4

register the CVAR
Code:
new SPS_pcvar
SPS_pcvar = register_cvar("Stupid_Plugin_String", "Yer duuumb")
in your amxx.cfg to set your CVAR
Quote:
Stupid_Plugin_String "This is stupid!"
Call and use the CVAR:
Code:
new stupidString[255]
get_pcvar_string(SPS_pcvar, stupidString, charsmax(stupidString) )
client_print(0, print_chat, stupidString)
This will print:
Quote:
This is stupid!
in everyone's chat.

Now...i don't usually answer so many remedial questions so nicely. So, in the future, make sure you read the documentation and wiki before you ask things that you should already know before you start scripting.

http://www.amxmodx.org/doc/index.htm...g%2Fprimer.htm
http://www.amxmodx.org/funcwiki.php?go=module&id=1

read them, love them, fap to them.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-14-2012 at 02:21.
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-14-2012 , 08:22   Re: New Plugin Help
Reply With Quote #5

You'll notice that he actually asked for the CVar to control the message timer.

Use a CVar pointer ... combine this into your plugin:
Code:
new g_pMsgTime; public plugin_init() {     g_pMsgTime = register_cvar( "amx_msg_time", "5.0" ); } public MyFunction() {     new Float: flTime = get_pcvar_float( g_pMsgTime );     set_hudmessage( 0, 0, 0, -1.0, 0.35, 0, 0.0, flTime, 1.0, 1.0 );     //show_hudmessage( ... ) }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-14-2012 , 12:10   Re: New Plugin Help
Reply With Quote #6

OH! I thought he wanted to change the string, not the time.
I was really tired.

The problem with that is i don't believe that will change on the fly. You'd need to re-call the set_hudmesage function with the new value. Depending on how you have it set up, i'd put it in a task that grabs the cvar with each iteration. Show some code and i would be able to help you better.

-OR- This is just a theory....you could hook amx_cvar (the admin command used to change a CVAR in game) and have that command refresh the set_hudmessage after the CVAR has been applied. But i'm not sure how that would work....
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-14-2012 at 12:46.
Liverwiz 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 06:06.


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