AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   on map (https://forums.alliedmods.net/showthread.php?t=333036)

MacL 06-15-2021 15:36

on map
 
hey alliedmodders, How do I make the plugin work only on specific maps? ( i do not mean make cfg files). i want something like this :
Code:

if(map("de_" , "fy_") return Plugin_Handled;

Supremache 06-15-2021 16:50

Re: on map
 
Quote:

Originally Posted by MacL (Post 2749813)
hey alliedmodders, How do I make the plugin work only on specific maps? ( i do not mean make cfg files). i want something like this :
Code:

if(map("de_" , "fy_") return Plugin_Handled;

PHP Code:

new szMapName[64]
get_mapname(0szMapName63)
If(
szMapNameequal ("de_")) return; 


fysiks 06-15-2021 21:21

Re: on map
 
Quote:

Originally Posted by Supremache (Post 2749819)
PHP Code:

new szMapName[64]
get_mapname(0szMapName63)
If(
szMapNameequal ("de_")) return; 


No. You may want to test code before posting.

_____________________________________________ ____________

@MacL, this is a Scripting Help question so you should post things like this in Scripting Help in the future.

You would use get_mapname() and equal() to compare only the first X number of characters (because both examples given only have 3 characters, you would set argument 'c' to 3).

If you have differing sizes of prefixes, you may want to consider breaking the string with something like strtok() using the underscore as a tocken and comparing the first result to your prefixes.

_____________________________________________ ____________

For others who might want it: No plugin code modification required, simply configure the plugin to only load on the maps you want: https://wiki.alliedmods.net/Configur...ecific_Plugins

Celena Luna 06-15-2021 21:48

Re: on map
 
Spoiler


Edit:
If you want to start plugins on specific map type:
1. Go to addons/amxmodx/configs/maps (if the folder haven't exists, create it)
2. create the file with the name like plugins-fy.ini (replace fy with any prefix of the map like de, cs,...)
3. Input any plugins you want to run on those specific map type.

Supremache 06-16-2021 00:29

Re: on map
 
Quote:

Originally Posted by fysiks (Post 2749863)
No. You may want to test code before posting.
[/url]

I know, I was on the phone when I typed that code and I was want to give him an example for how to do that "calling native get_mapname and using equal"

MacL 06-16-2021 08:01

Re: on map
 
Thank you guys.

fysiks 06-16-2021 22:16

Re: on map
 
Quote:

Originally Posted by Supremache (Post 2749819)
PHP Code:

new szMapName[64]
get_mapname(0szMapName63)
If(
szMapNameequal ("de_")) return; 


Quote:

Originally Posted by Supremache (Post 2749895)
I know, I was on the phone when I typed that code and I was want to give him an example for how to do that "calling native get_mapname and using equal"

If you don't know the functions, provide only psuedo code or a description (like you just did in this post) so that the requester doesn't think that your code is accurate. Or better yet, wait until you can test it and then post.


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

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