Raised This Month: $ Target: $400
 0% 

Get mapname from config file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mlk27
Veteran Member
Join Date: May 2008
Old 09-09-2008 , 06:52   Get mapname from config file
Reply With Quote #1

well i want this script to use config file which contains list of map to remove weapon entities from.


weapon_stripper.cfg
Quote:
de_map1
de_map2
cs_map
Weapons Stripper
Code:
#include <amxmodx> #include <fakemeta> #define PLUGIN    "Weapons Stripper" #define AUTHOR    "Jim" #define VERSION    "1.0" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR) } public plugin_precache() {     register_forward(FM_Spawn, "fwd_spawn") } public fwd_spawn(ent) {     new classname[32]     pev(ent, pev_classname, classname, 31)     if(classname[0] == 'a' && classname[1] == 'r')     {         engfunc(EngFunc_RemoveEntity, ent)         return FMRES_SUPERCEDE     }     return FMRES_IGNORED }

thanks in advanced and +1 karma
Mlk27 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-09-2008 , 07:19   Re: Get mapname from config file
Reply With Quote #2

Just use per-map feature for plugins. Read up on the AMXX Changelog and you will see it.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Mlk27
Veteran Member
Join Date: May 2008
Old 09-09-2008 , 07:27   Re: Get mapname from config file
Reply With Quote #3

i know that but i prefer this way since config in one file is more simple to manage
Mlk27 is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 09-09-2008 , 07:35   Re: Get mapname from config file
Reply With Quote #4

You can use this stock
Code:
stock bool:is_map_in_file(const file[], const map[]) {  new iFile = fopen(file, "rt");    if(!iFile)   return false;    new szBuffer[32];  while(!feof(iFile))  {   fgets(iFile, szBuffer, sizeof szBuffer - 1);   trim(szBuffer);     if(!sBuffer[0] || sBuffer[0] == ';')    continue;     if(equali(szBuffer, map, strlen(map)))    return true;  }  fclose(iFile);  return false; }

if(is_map_in_file("../file path", "de_dust2"))
{
//map de_dust2 is in file.
}
Alka is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-09-2008 , 15:19   Re: Get mapname from config file
Reply With Quote #5

@Alka, you had a few errors:
Code:
stock bool:is_map_in_file(const file[], const map[]) {  new iFile = fopen(file, "rt");    if(!iFile)   return false;    new szBuffer[64], szMap[32];  // I think it's better to parse the map and other text in case of a comment next to it?  while(!feof(iFile))  {   fgets(iFile, szBuffer, sizeof szBuffer - 1);   trim(szBuffer);     if(!szBuffer[0] || szBuffer[0] == ';') // you put sBuffer, not szBuffer    continue;     parse(szBuffer, szMap, sizeof szMap - 1);     if(equali(szMap, map, strlen(map)))   {    fclose(iFile); // you forgot to close    return true;   }  }  fclose(iFile);  return false; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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