Raised This Month: $52 Target: $400
 13% 

If cvar is enabled, hide /custom command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MihailoZ
Member
Join Date: Aug 2013
Old 09-14-2019 , 17:13   If cvar is enabled, hide /custom command
Reply With Quote #1

Hello,

I am creating a plugin with /custom command with cvars.

I created a cvar that can hide or display /custom command but I always get an error:

Warning: Function should return a value on line 65.


What I want to do is:

IF cvar is enabled, hide /custom command and do the action.
IF cvar is disabled, show /custom command and do the action.


Even with a warning, my plugin works. But I don't want it to display any warning.


Thank you.
__________________
mhvtnns
MihailoZ is offline
MihailoZ
Member
Join Date: Aug 2013
Old 09-14-2019 , 17:18   Re: If cvar is enabled, hide /custom command
Reply With Quote #2

Okay. I solved the problem. I will write here how so I can help others.

If you have any return PLUGIN_HANDLED_MAIN; or return PLUGIN_HANDLED (I guess) as a cvar,

you MUST add return PLUGIN_CONTINUE; in the end of public blabla(id) {
__________________
mhvtnns
MihailoZ is offline
MihailoZ
Member
Join Date: Aug 2013
Old 09-14-2019 , 21:24   Re: If cvar is enabled, hide /custom command
Reply With Quote #3

Another question is:

if cvar (string) has no input, if it's empty, client_print(id,print_chat,"Custom message");

but if cvar has some input I want to print just that input.
__________________
mhvtnns
MihailoZ is offline
LearninG
Senior Member
Join Date: Apr 2019
Location: Iran
Old 09-15-2019 , 03:17   Re: If cvar is enabled, hide /custom command
Reply With Quote #4

It's useless in messages , because you can't do "space" in cvar :
Example :
"Type /menu to see game menu."
will be shown as ( in chat) :
"Type"

with cvar :
Code:
#include <amxmodx> new cvar_string public plugin_init() {         cvar_string = register_cvar("amx_message" , "Hello!")         register_clcmd("say /message" , "some_func") } public some_func(id) {         new My_Cvar[7]         get_pcvar_string(cvar_string , My_Cvar , charsmax(My_Cvar))         client_print(id , print_chat , "%s" , My_Cvar) }
another way without cvar :
Code:
#include <amxmodx> new const MESSAGE[] = "Welcome to server" public plugin_init() {         register_clcmd("say /message" , "some_func") } public some_func(id) {         client_print(id , print_chat , "%s" , MESSAGE) }

Last edited by LearninG; 09-15-2019 at 05:34.
LearninG is offline
AmXDusT
Member
Join Date: Feb 2019
Location: Italy / Albania
Old 09-15-2019 , 04:18   Re: If cvar is enabled, hide /custom command
Reply With Quote #5

Space works in cvars.

Create a big enough string in your function that can get all the cvar string and use get_pcvar_string to copy it there.

Check string's length to see if it has anything in it ( "strlen( your_string )" ) and print either the string or your custom message (through client_print, like LearninG's sample)
AmXDusT is offline
LearninG
Senior Member
Join Date: Apr 2019
Location: Iran
Old 09-15-2019 , 05:17   Re: If cvar is enabled, hide /custom command
Reply With Quote #6

Quote:
Originally Posted by AmXDusT View Post
Space works in cvars.
yes , i did :
Code:
amx_message Type /menu to see game menu
should be :
Code:
amx_message "Type /menu to see game menu"

Last edited by LearninG; 09-15-2019 at 05:35.
LearninG is offline
MihailoZ
Member
Join Date: Aug 2013
Old 09-15-2019 , 05:57   Re: If cvar is enabled, hide /custom command
Reply With Quote #7

Thank you guys. I will try that.

Is it possible to add IF cvar1 = something AND cvar2 = something { do this }
__________________
mhvtnns
MihailoZ is offline
AmXDusT
Member
Join Date: Feb 2019
Location: Italy / Albania
Old 09-15-2019 , 07:23   Re: If cvar is enabled, hide /custom command
Reply With Quote #8

https://www.amxmodx.org/api/string/equali or https://www.amxmodx.org/api/string/equal
AmXDusT 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 00:07.


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