Re-loading a file?
#1

Well, I currently have two functions (Created by Leth4l)

pawn Code:
stock AddLabelsFromFile(LFileName[])
{
    if(!fexist(LFileName)) return 0;

    new File:LFile, Line[128], LabelInfo[128], Float:LX, Float:LY, Float:LZ, lTotal = 0;

    LFile = fopen(LFileName, io_read);
    while(fread(LFile, Line))
    {
        if(Line[0] == '/' || isnull(Line)) continue;
        unformat(Line, "p<,>s[128]fff", LabelInfo,LX,LY,LZ);
        CreateDynamic3DTextLabel(LabelInfo, 0xFFFFFFFF, LX, LY, LZ, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
        lTotal++;
    }
    fclose(LFile);
    return lTotal;
}

stock AddLabelToFile(LFileName[], LabelInfo[], Float:LX, Float:LY, Float:LZ)
{
    new File:LFile, Line[128];

    format(Line, sizeof(Line), "%s,%.2f,%.2f,%.2f\r\n",LabelInfo, LX, LY, LZ);
    LFile = fopen(LFileName, io_append);
    fwrite(LFile, Line);
    fclose(LFile);
    return 1;
}
Which are used in my dynamic 3DTextLabel system, which works perfectly; Now, i'm wondering if there's a way to make a reload command so it would destroy the pickups in the file, and then reload them.

Here's my add command:

pawn Code:
COMMAND:add(playerid, params[]) //Fixed by Frederick Wright - http://www.fwright.com
{
    new
        mapicon_id,
        mapicon_color,
        Float:MapIconX,
        Float:MapIconY,
        Float:MapIconZ,
        vModel,
        Float:VX,
        Float:VY,
        Float:VZ,
        Float:VA,
        vColor1,
        vColor2;

    /*snip*/
    else if(strcmp(params, "3DTextLabel", true, 11) == 0) {
        strdel(params, 0, 11);
        new
            LabelDesc[128],
            Float:YourPos[3];

        if(sscanf(params, "s[128]", LabelDesc)) {
            UsageMessage(playerid, "Add 3DTextLabel", "[Text]", "Creates a permanent 3DTextLabel viewable by all players at your position.");
            return 1;
        }
        if(PVar[playerid][AuthLvl] >= 3) {
            GetPlayerPos(playerid, YourPos[0], YourPos[1], YourPos[2]);
            AddLabelToFile(LABEL_FILE_NAME, LabelDesc, YourPos[0], YourPos[1], YourPos[2]);
            CreateDynamic3DTextLabel(LabelDesc, 0xFFFFFFFF, YourPos[0], YourPos[1], YourPos[2], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
            printf("[+] 3DTextLabel created at %f, %f, %f | Description: %s", YourPos[0], YourPos[1], YourPos[2], LabelDesc);
        }
        else return AuthError(playerid, 3);
    }
    else {
        UsageMessage(playerid, "Add", "[Parameters]", "MapIcon, Vehicle, Pickup, 3DTextLabel");
        return 1;
    }
    return 1;
}
Reply


Messages In This Thread
Re-loading a file? - by Skylar Paul - 29.05.2011, 01:31
Re: Re-loading a file? - by Calgon - 29.05.2011, 05:37

Forum Jump:


Users browsing this thread: 1 Guest(s)