AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   STR DEFINE to INTEGER (https://forums.alliedmods.net/showthread.php?t=129172)

mysticssjgoku4 06-09-2010 19:35

STR DEFINE to INTEGER
 
So this is irritating. Why doesn't this work, and is there an alternative?

Code:
#define A_SG_Marines_3_val          "30" new g_Scans_Needed = str_to_num(A_SG_Marines_3_val); new g_Scans[33][g_Scans_Needed];

wrecked_ 06-09-2010 19:39

Re: STR DEFINE to INTEGER
 
Define it as an integer? o.o

Bugsy 06-09-2010 19:40

Re: STR DEFINE to INTEGER
 
Quote:

Originally Posted by mysticssjgoku4 (Post 1204538)
So this is irritating. Why doesn't this work, and is there an alternative?

Code:
#define A_SG_Marines_3_val          "30" new g_Scans_Needed = str_to_num(A_SG_Marines_3_val); new g_Scans[33][g_Scans_Needed];

PHP Code:

#define A_SG_Marines_3_val          30

new g_Scans[33][A_SG_Marines_3_val]; 


mysticssjgoku4 06-09-2010 19:43

Re: STR DEFINE to INTEGER
 
Quote:

Originally Posted by Bugsy (Post 1204542)
PHP Code:

#define A_SG_Marines_3_val          30

new g_Scans[33][A_SG_Marines_3_val]; 


I need that define as a string.

Bugsy 06-09-2010 19:43

Re: STR DEFINE to INTEGER
 
Quote:

Originally Posted by mysticssjgoku4 (Post 1204545)
I need that define as a string.

Tell me why and Ill give you a solution.

mysticssjgoku4 06-09-2010 19:53

Re: STR DEFINE to INTEGER
 
The function I use requires a string for the entire system of plugins I am coding, and I don't feel like editing through 1000's of lines of code changing it over, and unnecessarily converting over each number to a string before use just because I need just this one define as an integer.

Bugsy 06-09-2010 19:56

Re: STR DEFINE to INTEGER
 
Quote:

Originally Posted by mysticssjgoku4 (Post 1204552)
The function I use requires a string for the entire system of plugins I am coding, and I don't feel like editing through 1000's of lines of code changing it over, and unnecessarily converting over each number to a string before use just because I need just this one define as an integer.

PHP Code:

#define g_Scans_Needed          30

new A_SG_Marines_3_val]
new 
g_Scans[33][ g_Scans_Needed ];

public 
plugin_init() 
     
num_to_strg_Scans_Needed A_SG_Marines_3_val ); 


mysticssjgoku4 06-09-2010 19:59

Re: STR DEFINE to INTEGER
 
Quote:

Originally Posted by Bugsy (Post 1204554)
PHP Code:

#define THENUMBER     30

new TheVar33 ][ THENUMBER ];
new 
A_SG_Marines_3_val];  //Use this for all other functions that need the string

//plugin_init 
    
num_to_strTHENUMBER A_SG_Marines_3_val ); 


Hmm. Thanks, ill mess around and figure something out I suppose. I am trying to keep the system uniform in style.

ConnorMcLeod 06-10-2010 01:25

Re: STR DEFINE to INTEGER
 
Problem is that you can only use str_to_num(A_SG_Marines_3_val) in a function, and other problem is that you can only set an array size with a const.
That's why Bugsy took the problem in the other way, so you build the string from the const integer instead of retrieve the integer from the string.

Alucard^ 06-10-2010 07:00

Re: STR DEFINE to INTEGER
 
Use Bugsy code, is better than mine, cuz my code is only an example starting with string (only to understand why your code doesn't work):

Code:
new const A_SG_Marines_3_val[] = "30"; new g_Scans_Needed = str_to_num(A_SG_Marines_3_val); new g_Scans[33][g_Scans_Needed];

Also, maybe the num_to_str() is useless, depends on where you will use the string num... where? maybe in the function that you want to the num as string, you can use %d.

Sry for my english.


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

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