Raised This Month: $ Target: $400
 0% 

[SOLVED] Read Multiple Words From One Line?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 11-11-2013 , 17:40   [SOLVED] Read Multiple Words From One Line?
Reply With Quote #1

Atm my file setup is this

Code:
NADE=HE
NADE=SMOKE
NADE=FLASH
with this code
Code:
else if( equali( szWeaponType, "NADE" ) )         {             g_bWeaponItems[ iTeam ][ GRENADE ] = true;             if( equali( szWeaponName, "HE" ) )             {                 g_bGrenades[ iTeam ][ 0 ] = true;             }             else if( equali( szWeaponName, "SMOKE" ) )             {                 g_bGrenades[ iTeam ][ 1 ] = true;             }             else if( equali( szWeaponName, "FLASH" ) )             {                 g_bGrenades[ iTeam ][ 2 ] = true;             }         }
but im trying to get it to read like this

NADES=HE|SMOKE|FLASH

but my code atm only seems to get flash and smoke out of this and not he

Code:
else if( equali( szWeaponType, "NADE" ) )         {             g_bWeaponItems[ iTeam ][ GRENADE ] = true;                         replace_all( szWeaponName, cm( szWeaponName ), "|", " " );                         console_print( 0, "%s", szWeaponName );                         if( contain( szWeaponName, "HE" ) )             {                 g_bGrenades[ iTeam ][ 0 ] = true;             }             if( contain( szWeaponName, "SMOKE" ) )             {                 g_bGrenades[ iTeam ][ 1 ] = true;             }             if( contain( szWeaponName, "FLASH" ) )             {                 g_bGrenades[ iTeam ][ 2 ] = true;             }         }

i know it is proberly something easy im doing wrong just cant see it.

EDIT: Solved

was forgetting the !=-1 in the contain
__________________

Last edited by Blizzard_87; 11-11-2013 at 17:58.
Blizzard_87 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-12-2013 , 01:40   Re: [SOLVED] Read Multiple Words From One Line?
Reply With Quote #2

You remove | for nothing in that string, '|' is a char as well as space is a char.
Also, you could find usefull to use strtok
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 11-12-2013 , 02:10   Re: [SOLVED] Read Multiple Words From One Line?
Reply With Quote #3

Ok thanks ConnorMcLeod.
__________________
Blizzard_87 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 23:23.


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