Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Make stock to remove line from file

$
0
0
Code:

stock AddObjectFromFile(DFileName[])
{
        if(!fexist(DFileName)) return 0;

        new File:ObjectFile, Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT, oTotal, Line[128];

        ObjectFile = fopen(DFileName, io_read);
        while(fread(ObjectFile, Line))
        {
            if(Line[0] == '/' || isnull(Line)) continue;
            unformat(Line, "ffffffiii", OX, OY, OZ, ORX, ORY, ORZ, OVW, OINT, oModel);
            CreateDynamicObject(oModel, Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT, -1, 200.0);
            oTotal++;
        }
        fclose(ObjectFile);
        return oTotal;
}

So, the code above adds a line to a .txt file for any furniture items that are added in. I'm trying to add a command to delete a specific line of code based on the object he selects:
Code:

CMD:deletefurn(playerid, params[])
{
    new holder[1000];

        new hworld = GetPlayerVirtualWorld(playerid);
        new house = PlayerInfo[playerid][HouseID];
        if(house == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't own a house.");

        for(new h = 1; h < sizeof(HouseInfo); h++)
        {
                if(hworld == HouseInfo[h][hInsideWorld])
                  {
                        if(house == HouseInfo[h][hInsideWorld])
                          {
                            SelectObject(playerid);
                            DeletingFurn[playerid] = 1;
                        }
                }
        }
        return 1;
}

Code:

public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y, Float:z)
{
        new holder[1000];

        new hworld = GetPlayerVirtualWorld(playerid);
        new house = PlayerInfo[playerid][HouseID];
        if(house == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't own a house.");

        for(new h = 1; h < sizeof(HouseInfo); h++)
        {
                if(hworld == HouseInfo[h][hInsideWorld])
                  {
                        if(house == HouseInfo[h][hInsideWorld])
                          {
                              if(DeletingFurn[playerid] == 1)
                              {
                                      EDIT_OBJECT[playerid] = objectid;
                                    ShowPlayerDialog(playerid, DIALOG_DELETE_FURNITURE, DIALOG_STYLE_MSGBOX, "{FFFFFF}Furniture Deletion", "{FFFFFF}You are about to delete a furniture object, are you sure you want to?", "Yes", "No");
                    DeletingFurn[playerid] = 0;
                                }
                                if(EditingFurn[playerid] == 1)
                                {
                                    EditDynamicObject(playerid, objectid);
                                    EditingFurn[playerid] = 0;
                                }
                        }
                }
        }
        return 1;
}

Code:

if(dialogid == DIALOG_DELETE_FURNITURE)
        {
                if(!response)
                {
                    SendClientMessage(playerid, COLOR_LIGHTRED, "You cancelled deleting the furniture!");
                    return 1;
                }
                switch(listitem)
                {
                    case 0:
                    {
                                DestroyDynamicObject(EDIT_OBJECT[playerid]);
                                DestroyObject(EDIT_OBJECT[playerid]);
                    }
                    case 1:
                    {
                        SendClientMessage(playerid, COLOR_LIGHTRED, "You cancelled deleting the furniture!");
                    }
                }
        }


When it reaches the dialog, it pops up. When I click yes, nothing happens. Any ideas??? I'm stuck.

Viewing all articles
Browse latest Browse all 18226

Trending Articles