Raised This Month: $ Target: $400
 0% 

STR DEFINE to INTEGER


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-09-2010 , 19:35   STR DEFINE to INTEGER
Reply With Quote #1

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];
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 06-09-2010 , 19:39   Re: STR DEFINE to INTEGER
Reply With Quote #2

Define it as an integer? o.o
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-09-2010 , 19:40   Re: STR DEFINE to INTEGER
Reply With Quote #3

Quote:
Originally Posted by mysticssjgoku4 View Post
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]; 
__________________
Bugsy is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-09-2010 , 19:43   Re: STR DEFINE to INTEGER
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
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.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-09-2010 , 19:43   Re: STR DEFINE to INTEGER
Reply With Quote #5

Quote:
Originally Posted by mysticssjgoku4 View Post
I need that define as a string.
Tell me why and Ill give you a solution.
__________________
Bugsy is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-09-2010 , 19:53   Re: STR DEFINE to INTEGER
Reply With Quote #6

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.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-09-2010 , 19:56   Re: STR DEFINE to INTEGER
Reply With Quote #7

Quote:
Originally Posted by mysticssjgoku4 View Post
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 ); 
__________________

Last edited by Bugsy; 06-09-2010 at 20:01.
Bugsy is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-09-2010 , 19:59   Re: STR DEFINE to INTEGER
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
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.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-10-2010 , 01:25   Re: STR DEFINE to INTEGER
Reply With Quote #9

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.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-10-2010 , 07:00   Re: STR DEFINE to INTEGER
Reply With Quote #10

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.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
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 05:26.


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