How to check if an array has that string or not?

Topic created ยท 5 Posts ยท 56 Views
  • As the title says, "How to check if an array has that string or not."

    Let me show you a scenario:

    In the array i have, [0] - Hello and [1] - Purple.
    How can i check if i have the string "purple" in the array?

    NOTE: Is there any GSC Resources to learn from? I know GSC (a bit) although i really have hard time to learn it cause there is no good tutorials. I would like to create other COD Mods also.

    Thanks,
    Ayresia

  • level.example[0] = "Green";
    level.example[1] = "Purple";
    level.example[2] = "Yellow";
    level.example[3] = "Red";
    level.example[4] = "Blue";
    level.example[5] = "Orange";
    
    findPurple()
    {
    	for( i = 0; i < 5; i++ ) //<- Loops 5 times from 0 - 5
    	{
    		if ( level.example[i] == "Purple" )
    		{
    		
    			self iPrintln ( "Array : " + i + "has the string :" +  level.example[i]  );
    				break;
    		}
            }
    	
    }
    

    it should print you ingame:
    Array : 1 has the string : Purple

  • @Enki Thanks man! How did you learn GSC by any chance? I'm very interested to learn this language!

  • I learned it just by looking at raw files and changing little stuff in a gsc files and see what changed....
    sounds stupid i know ๐Ÿ˜Œ

    and i started with mw2 you have alot more you can do on on that game because you have access to all the raw files

  • @Enki Do you have discord or something, i would like to help/learn from you ๐Ÿ˜„ . If you don't wanna add it's all good.

Log in to reply