Make stock to remove line from file
#1

Код:
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:
pawn Код:
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;
}
pawn Код:
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;
}
pawn Код:
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.
Reply
#2

bump
Reply
#3

listitem is -1 in that case
Reply
#4

There's no listitem for a dialog type MSGBOX

Instead use the code as like below

PHP код:
if(dialogid == DIALOG_DELETE_FURNITURE)
    {
        if(!
response)
        {
                    
// PRESSED NO.
            
SendClientMessage(playeridCOLOR_LIGHTRED"You cancelled deleting the furniture!");
            return 
1;
        }
                 
//PRESSED YES.
         
DestroyDynamicObject(EDIT_OBJECT[playerid]);
         
DestroyObject(EDIT_OBJECT[playerid]);
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)