Raised This Month: $2 Target: $400
 0% 

Solved set_lights in cvar


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-30-2020 , 06:23   Re: set_lights in cvar
Reply With Quote #11

PHP Code:
new buffer[size]
get_pcvar_string(cvarbuffercharsmax(buffer))
//do something with buffer 
This is more or less pseudocode, adapt it to your situation. The idea is you do not pass the size of a string manually, you use charsmax() to determine it automatically. This way, you don't pass a wrong value and if you ever change the string size then you do not need to change it in every function that uses it.
__________________

Last edited by HamletEagle; 06-30-2020 at 06:25.
HamletEagle is offline
chickez
Junior Member
Join Date: Jun 2020
Location: Slovakia
Old 06-30-2020 , 06:38   Re: set_lights in cvar
Reply With Quote #12

Quote:
Originally Posted by HamletEagle View Post
PHP Code:
new buffer[size]
get_pcvar_string(cvarbuffercharsmax(buffer))
//do something with buffer 
This is more or less pseudocode, adapt it to your situation. The idea is you do not pass the size of a string manually, you use charsmax() to determine it automatically. This way, you don't pass a wrong value and if you ever change the string size then you do not need to change it in every function that uses it.
I understood. So in this situation, I can set size of string, because It will be one char always.

Other question to this situation. When I change the value of cvar (amxx_lights) in example, to "m" on the server, it will change the light without waiting to next round. How can I do this?
chickez is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 06-30-2020 , 06:45   Re: set_lights in cvar
Reply With Quote #13

set_task
ZaX is offline
chickez
Junior Member
Join Date: Jun 2020
Location: Slovakia
Old 06-30-2020 , 10:23   Re: set_lights in cvar
Reply With Quote #14

I did this:

PHP Code:
#include <amxmodx>
#include <engine>

#define PLUGIN "Server Lights"
#define VERSION "0.1"
#define AUTHOR "chick"

new g_cvarLight

public plugin_init()
{
    
register_plugin PLUGIN VERSION AUTHOR )
    
    
g_cvarLight register_cvar "server_light""m"//"m" - default light
    
    
if (!task_exists(g_cvarLight))
    
set_task (0.1"setServerLight"g_cvarLight__"b")
}

public 
setServerLight(g_cvarLight)
{    
    new 
pLight [2]
    
    
get_pcvar_string (g_cvarLightpLightcharsmax(pLight))
    
set_lights (pLight)

It's correct? That task will not bugging?

Last edited by chickez; Yesterday at 08:16. Reason: edit code
chickez is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-30-2020 , 11:14   Re: set_lights in cvar
Reply With Quote #15

Quote:
Originally Posted by Natsheh View Post
Which amxx version are you using ?

If you're using amxx version 183 or latter which most recommended vers is the latest you can hook cvar change and change the lights instantly rather than waiting for round HLTV event to be called.
I did this because I use 1.8.2
__________________
Private Work! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
Old 06-30-2020 , 20:19   Re: set_lights in cvar
Reply With Quote #16

Quote:
Originally Posted by supertrio17 View Post
I did this because I use 1.8.2
Even so you can hook cvar change using orpheu or arkshine cvar hook module
__________________
@Jailbreak MOD [Alot of features + API] 100% done !
@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
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-30-2020 , 23:32   Re: set_lights in cvar
Reply With Quote #17

Quote:
Originally Posted by chickez View Post
Other question to this situation. When I change the value of cvar (amxx_lights) in example, to "m" on the server, it will change the light without waiting to next round. How can I do this?
Answering questions that were asked of you is very helpful so you should consider doing so. Often this will save a lot of time and prevent people from wasting their time doing things that you're not actually requesting.

Quote:
Originally Posted by fysiks View Post
You need to read the cvar at some point and use it when you call set_lights(). When do you want this action to occur?
__________________

Last edited by fysiks; 06-30-2020 at 23:39.
fysiks is online now
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 07-01-2020 , 02:01   Re: set_lights in cvar
Reply With Quote #18

Well it's true that you can use orpheu, but it doesn't work on rehlds, and I don't really want to have many unnecessary includes, but if you are making this plugin for yourself and you don't use rehlds, you should consider.
__________________
Private Work! || Discord:
Mr_Boopsy_#2066

Last edited by supertrio17; 07-01-2020 at 02:02.
supertrio17 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-01-2020 , 03:12   Re: set_lights in cvar
Reply With Quote #19

Quote:
Originally Posted by supertrio17 View Post
Well it's true that you can use orpheu, but it doesn't work on rehlds, and I don't really want to have many unnecessary includes, but if you are making this plugin for yourself and you don't use rehlds, you should consider.
If you need instant cvar changes for 1.8.2 and only orpheu can do it, then how is it "unnecessary"? Please do not start again the "I only want to include one module" syndrome.
There is absolutely no reason not to have "many includes".
__________________

Last edited by HamletEagle; 07-01-2020 at 03:13.
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
Old 07-01-2020 , 04:13   Re: set_lights in cvar
Reply With Quote #20

Who said orpheu doesn't work for ReHLDS?

You only need to find amxmodx cvar change signatures.
__________________
@Jailbreak MOD [Alot of features + API] 100% done !
@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
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 14:53.


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