Raised This Month: $ Target: $400
 0% 

How to make sure a variable is not unset


Post New Thread Reply   
 
Thread Tools Display Modes
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-18-2018 , 18:20   Re: How to make sure a variable is not unset
Reply With Quote #11

I just told you everything... And no you don't have to use create_cvar
__________________
stuff
maqi is offline
Cd5ssmffan
BANNED
Join Date: Feb 2017
Location: GB
Old 06-18-2018 , 19:11   Re: How to make sure a variable is not unset
Reply With Quote #12

Quote:
Originally Posted by maqi View Post
I just told you everything... And no you don't have to use create_cvar
You told me what the problems are and what solutions to apply, I am still stuck
could you point me to a good tutorial or something? thank you very much sir
I've read over most of the stuff on the tutorials and code snippets part of the site already though and there arent many good video tutorials for scripting in amx

Last edited by Cd5ssmffan; 06-18-2018 at 19:12.
Cd5ssmffan is offline
Send a message via ICQ to Cd5ssmffan Send a message via AIM to Cd5ssmffan Send a message via Yahoo to Cd5ssmffan Send a message via Skype™ to Cd5ssmffan
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-18-2018 , 19:46   Re: How to make sure a variable is not unset
Reply With Quote #13

Ill make you a tutorial:

PHP Code:
/* These will be our cvar pointers */
new     g_Cvar_TutorialInt,
        
g_Cvar_TutorialString;

public 
plugin_precache( )
{
        
/* We registered our cvars and asigned g_Cvar_Tutorial as our cvar pointers ( That means that everything we want to do with a cvar we do with that pointer ) */

        
g_Cvar_TutorialInt register_cvar"amx_tutorial_int""1" );                  
        
g_Cvar_TutorialString register_cvar"amx_tutorial_string""Hello World" ); 
        
}

public 
client_connectiIndex )
{
    new 
iTutorial   =   get_pcvar_numg_Cvar_TutorialInt ); // We get the integer value of our cvar using get_pcvar_num

    
new sTutorial[32];  get_pcvar_stringg_Cvar_TutorialStringsTutorialcharsmax(sTutorial) ) // We copied the string value of our cvar to a buffer

    // Do stuff with iTutorial and sTutorial...

}

/* Note: Cvars always have string values, its up to you how you are gonna retrieve it, ) get_pcvar_num, get_pcvar_float, get_pcvar_string etc ... ) */ 
__________________
stuff

Last edited by maqi; 06-18-2018 at 20:34.
maqi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-18-2018 , 22:33   Re: How to make sure a variable is not unset
Reply With Quote #14

It sounds like, at the very least, you need to read some of the really basic scripting tutorials like the first two under "Pawn Programming" here.
__________________

Last edited by fysiks; 06-18-2018 at 22:34.
fysiks is offline
Cd5ssmffan
BANNED
Join Date: Feb 2017
Location: GB
Old 06-19-2018 , 15:49   Re: How to make sure a variable is not unset
Reply With Quote #15

Quote:
Originally Posted by fysiks View Post
It sounds like, at the very least, you need to read some of the really basic scripting tutorials like the first two under "Pawn Programming" here.
Been over that multiple times before I posted this thread, I can't find exactly what I need

Quote:
Originally Posted by maqi View Post
Ill make you a tutorial:

PHP Code:
/* These will be our cvar pointers */
new     g_Cvar_TutorialInt,
        
g_Cvar_TutorialString;

public 
plugin_precache( )
{
        
/* We registered our cvars and asigned g_Cvar_Tutorial as our cvar pointers ( That means that everything we want to do with a cvar we do with that pointer ) */

        
g_Cvar_TutorialInt register_cvar"amx_tutorial_int""1" );                  
        
g_Cvar_TutorialString register_cvar"amx_tutorial_string""Hello World" ); 
        
}

public 
client_connectiIndex )
{
    new 
iTutorial   =   get_pcvar_numg_Cvar_TutorialInt ); // We get the integer value of our cvar using get_pcvar_num

    
new sTutorial[32];  get_pcvar_stringg_Cvar_TutorialStringsTutorialcharsmax(sTutorial) ) // We copied the string value of our cvar to a buffer

    // Do stuff with iTutorial and sTutorial...

}

/* Note: Cvars always have string values, its up to you how you are gonna retrieve it, ) get_pcvar_num, get_pcvar_float, get_pcvar_string etc ... ) */ 
I probably shouldn't expect people to "spoon feed" me code but thanks anyway, this solved my problems (except I didn't need the tutorialInt bit
Cd5ssmffan is offline
Send a message via ICQ to Cd5ssmffan Send a message via AIM to Cd5ssmffan Send a message via Yahoo to Cd5ssmffan Send a message via Skype™ to Cd5ssmffan
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-19-2018 , 15:59   Re: How to make sure a variable is not unset
Reply With Quote #16

Well you had problems with exactly the code above, I just tried to hell you. You can look at it as you want

And you did need the tutorial int bit, both for comparison and because you didn't undestand how pointers worked.
__________________
stuff

Last edited by maqi; 06-19-2018 at 16:00.
maqi is offline
Reply



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 19:04.


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