AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   New Plugin Help (https://forums.alliedmods.net/showthread.php?t=187502)

Waleed 06-14-2012 01:46

New Plugin Help
 
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....

Liverwiz 06-14-2012 01:51

Re: New Plugin Help
 
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.

Waleed 06-14-2012 01:56

Re: New Plugin Help
 
Quote:

Originally Posted by Liverwiz (Post 1728440)

I still didn't get it....:D

Liverwiz 06-14-2012 02:10

Re: New Plugin Help
 
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.

hornet 06-14-2012 08:22

Re: New Plugin Help
 
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( ... ) }

Liverwiz 06-14-2012 12:10

Re: New Plugin Help
 
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....


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

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