AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Add menu item only if it hasn't been add before (https://forums.alliedmods.net/showthread.php?t=156487)

FEELiFE 05-07-2011 08:26

Add menu item only if it hasn't been add before
 
Hey guys :).

I have a .ini file. I parse the lines, and add a menu items. But I want where it duplicates not to add, and just skip it. Any ideas?

reinert 05-07-2011 08:34

Re: Add menu item only if it hasn't been add before
 
hook trough all lines, and check isn't the line equal to any other line. if yes, just skip it with continue;

FEELiFE 05-07-2011 08:38

Re: Add menu item only if it hasn't been add before
 
Quote:

Originally Posted by reinert (Post 1464967)
hook trough all lines, and check isn't the line equal to any other line. if yes, just skip it with continue;

Yes, but can you give me an example, please?

ConnorMcLeod 05-07-2011 09:18

Re: Add menu item only if it hasn't been add before
 
Create a Trie before you parse the file, add any new item in the Trie if the key doesn't already exist, else don't create a new item.
When you have finished you can destroy the trie.


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

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