AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Read Multiple Words From One Line? (https://forums.alliedmods.net/showthread.php?t=229660)

Blizzard_87 11-11-2013 17:40

[SOLVED] Read Multiple Words From One Line?
 
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

ConnorMcLeod 11-12-2013 01:40

Re: [SOLVED] Read Multiple Words From One Line?
 
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

Blizzard_87 11-12-2013 02:10

Re: [SOLVED] Read Multiple Words From One Line?
 
Ok thanks ConnorMcLeod.


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

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