Raised This Month: $ Target: $400
 0% 

fgets, format (general messup)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
marky_uk
Junior Member
Join Date: Aug 2008
Old 04-10-2009 , 16:57   fgets, format (general messup)
Reply With Quote #1

Hey,
This should have been an easy plugin to make but incoporating a file to retrieve data from has been the hardest thing I've come across yet.

What its suppose to do is:
get mapname,
open mapfile associated with mapname,
read all the lines in the mapfile,
remove all the entities listed in the mapfile

What it does:
Compiles fine :p
Crashes on server start

Im guessing the crash is caused by the malformed find_ent_by_model/remove ent because fgets is not supplying the right data I wanted.

I have yet to find a decent tutorial on file reading, so if you could provide while helping me fix my code.

Code:
#include <amxmodx>
#include <engine>

#define PLUGIN "WepEntityRemover"
#define AUTHOR "Marky_UK"
#define VERSION "1.00"

#define FILEPATH "addons/amxmodx/configs/WepEntityRemover"

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)

    new mapfile[256]
    new mapname[256]
    get_mapname(mapname, 255)
    format(mapfile,255,"%s/%s.txt", FILEPATH, mapname)
    new filepointer = fopen(mapfile,"r")
    if(filepointer == 0)
    {
        return PLUGIN_HANDLED;
    }

    new mapfiledata[681],weapon[19]
    
    while(fgets(filepointer,mapfiledata,680))
    {
        parse(mapfiledata,weapon,18)
        new WeaponEnt[65]
        format(WeaponEnt,64,"find_ent_by_model(-1,'armoury_entity','models/%s')", weapon)
        while((WeaponEnt[0]) != 0)
        {
            remove_entity(WeaponEnt[0])
        }
    }
    return PLUGIN_HANDLED;
}
Thanks, +karma

Last edited by marky_uk; 04-10-2009 at 16:59. Reason: new mapfiledata[681],weapon[18] TO new mapfiledata[681],weapon[19]
marky_uk is offline
 



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 02:15.


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