AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [H3LP] Check portion of mapname (https://forums.alliedmods.net/showthread.php?t=296238)

DarthMan 04-15-2017 15:19

[H3LP] Check portion of mapname
 
Hello. I know that I can use if(contain(szMap, szCurMap)) , but how can I check exactly for example if I have a map ab1_1_1 and ab2_2_1 the stuff will be executed on both maps, and I only want it to be executed on the map specified in the ini file. If I have specified ab2_2 as the map in the ini file, it should execute on all maps containing only ab2_2 and not also ab2_1. Thanks !

DarthMan 04-15-2017 18:42

Re: [H3LP] Check portion of mapname
 
Any ideas? I hope that someone will come with a good solution. Basically szMap has a smaller name than szCurMap :)

OciXCrom 04-15-2017 20:07

Re: [H3LP] Check portion of mapname
 
PHP Code:

if(equal(szCurMapszMapstrlen(szMap))) 


LegacyCode 04-16-2017 01:26

Re: [H3LP] Check portion of mapname
 
Quote:

Originally Posted by OciXCrom (Post 2512577)
PHP Code:

if(equal(szCurMapszMapstrlen(szMap))) 


He said szMap (from the .ini file) is smaller than szCurMap, e.g. only a portion or "prefix" of the maps he wants to target.

This code checks if szCurMap contains szMap at position 0, so the beginning of szCurMap (contain & containi both return the position of where the string was found in the source string):

PHP Code:

if ( containszCurMapszMap ) == 

If szCurMap is ab2_2_1 and szMap is ab2_2, it should return 0 and therefore work as expected.

I hope I understood your problem, if not feel free to share more detailed info.

- LegacyCode

klippy 04-16-2017 05:46

Re: [H3LP] Check portion of mapname
 
Quote:

Originally Posted by LegacyCode (Post 2512603)
He said szMap (from the .ini file) is smaller than szCurMap, e.g. only a portion or "prefix" of the maps he wants to target.

This code checks if szCurMap contains szMap at position 0, so the beginning of szCurMap (contain & containi both return the position of where the string was found in the source string):

PHP Code:

if ( containszCurMapszMap ) == 

If szCurMap is ab2_2_1 and szMap is ab2_2, it should return 0 and therefore work as expected.

I hope I understood your problem, if not feel free to share more detailed info.

- LegacyCode

Actually OciXCrom's code does the same thing. Take a look at what the third param does and what he passed as an argument to it. :)

DarthMan 04-16-2017 07:31

Re: [H3LP] Check portion of mapname
 
Quote:

Originally Posted by OciXCrom (Post 2512577)
PHP Code:

if(equal(szCurMapszMapstrlen(szMap))) 


Thanks !


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

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