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

Solved amxx 1.9 crash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-16-2018 , 23:12   amxx 1.9 crash
Reply With Quote #1

Hello, does anyone know why the code below crashes the sv? No log, clean crash.

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

new Var1Var2Var3

public plugin_init()
{
    
bind_pcvar_num(create_cvar("var1_test","1", .description ""), Var1)
    
bind_pcvar_num(create_cvar("var2_test""1", .description ""), Var2)
    
bind_pcvar_num(create_cvar("var3_test""1", .description ""), Var3)
    
set_task_ex(3.0"Enabled", .flags SetTask_Once)
    
AutoExecConfig(.autoCreate true, .name "Test")
}

public 
Enabled()
{
    
set_pcvar_num(Var1,0)    
    
set_pcvar_num(Var20)
    
set_pcvar_num(Var30)

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.

Last edited by iceeedr; 10-17-2018 at 08:52.
iceeedr is offline
Send a message via Skype™ to iceeedr
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-17-2018 , 03:43   Re: amxx 1.9 crash
Reply With Quote #2

You misunderstand the use of bind_pcvar_* natives.
They bind a cvar to a variable. Meaning that variable will contain the actual cvar's value in real time. This is NOT a cvar handle. You can't set a value from that.

To set a cvar with set_pcvar_num(), you still need to retrieve the handle from create_cvar() and using that value.
You can also use set_cvar_num(), it doesn't matter.
__________________

Last edited by Arkshine; 10-17-2018 at 03:45.
Arkshine is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-17-2018 , 08:21   Re: amxx 1.9 crash
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
You misunderstand the use of bind_pcvar_* natives.
They bind a cvar to a variable. Meaning that variable will contain the actual cvar's value in real time. This is NOT a cvar handle. You can't set a value from that.

To set a cvar with set_pcvar_num(), you still need to retrieve the handle from create_cvar() and using that value.
You can also use set_cvar_num(), it doesn't matter.
I had not really understood then, the correct use of the native bind_pcvar_ *, with the example quoted by me, how could I assign a value to pcvar? Or do I have to create just the pcvar with create_cvar and use it normally?
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
iceeedr is offline
Send a message via Skype™ to iceeedr
Kushfield
Member
Join Date: Jan 2017
Location: Estonia
Old 10-17-2018 , 08:48   Re: amxx 1.9 crash
Reply With Quote #4

Quote:
Originally Posted by iceeedr View Post
I had not really understood then, the correct use of the native bind_pcvar_ *, with the example quoted by me, how could I assign a value to pcvar? Or do I have to create just the pcvar with create_cvar and use it normally?
That's right, if you need to change the cvar's value, you have to store the return value from create_cvar and pass that to the set_pcvar_* functions as you normally would.

The bind_pcvar_* functions just set the passed in variable to the cvar's value and keep it automatically updated. That saves you from using get_pcvar_*/get_cvar_* every time you need to use the cvar's value.
Kushfield is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-17-2018 , 08:52   Re: amxx 1.9 crash
Reply With Quote #5

Thanks for all the clarifications.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
iceeedr is offline
Send a message via Skype™ to iceeedr
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 20:35.


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