SA-MP Forums Archive
How to save it? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to save it? (/showthread.php?tid=580551)



How to save it? - Mouiz - 06.07.2015

I have a code:

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(response)
        {
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid, x, y, z);
		object = strval(inputtext);
		cobj = CreateObject(object, x, y, z, 0.0, 0.0, 0.0);
		EditObject(playerid, cobj);
        }
    }
    return 1;
}
But when it create and save the object,i want to save it in script files in Object.txt as CreateDynamicObject(...) or CreateObject(...)

But how to do it?

Код:
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
    	if(response == EDIT_RESPONSE_FINAL)
	{
		// The player clicked on the save icon
		// Do anything here to save the updated object position (and rotation)
	}
}



Re: How to save it? - bigtigerbeee - 06.07.2015

Text or MYSQL ?


Re: How to save it? - Mouiz - 06.07.2015

Quote:
Originally Posted by bigtigerbeee
Посмотреть сообщение
Text or MYSQL ?
Text


Re: How to save it? - JaydenJason - 06.07.2015

Код:
#define ANIM_SAVE_FILE "Objects.txt"

SaveObjectToFile(playerid, objectid, Float:x, Float:y, Float:z)
{
	new
		File:file,
		line[100]
		pnam[MAX_PLAYER_NAME];

        GetPlayerName(playerid, pnam, sizeof(pnam));

	if(!fexist(ANIM_SAVE_FILE))file = fopen(ANIM_SAVE_FILE, io_write);
	else file = fopen(ANIM_SAVE_FILE, io_append);

	format(line, 100, "CreateObject(%s, %f, %f, %f, 0.0, 0.0, 0.0); // %s\r\n",
		objectid,
		x,
		y,
		z,
		pnam);

	fwrite(file, line);
	fclose(file);
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(response)
        {
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid, x, y, z);
		object = strval(inputtext);
		cobj = CreateObject(object, x, y, z, 0.0, 0.0, 0.0);
		SaveObjectToFile(playerid, object, x, y, z);
		EditObject(playerid, cobj);
        }
    }
    return 1;
}



Re: How to save it? - Mouiz - 06.07.2015

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
Код:
#define ANIM_SAVE_FILE "Objects.txt"

SaveObjectToFile(playerid, objectid, Float:x, Float:y, Float:z)
{
	new
		File:file,
		line[100]
		pnam[MAX_PLAYER_NAME];

        GetPlayerName(playerid, pnam, sizeof(pnam));

	if(!fexist(ANIM_SAVE_FILE))file = fopen(ANIM_SAVE_FILE, io_write);
	else file = fopen(ANIM_SAVE_FILE, io_append);

	format(line, 100, "CreateObject(%s, %f, %f, %f, 0.0, 0.0, 0.0); // %s\r\n",
		objectid,
		x,
		y,
		z,
		pnam);

	fwrite(file, line);
	fclose(file);
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(response)
        {
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid, x, y, z);
		object = strval(inputtext);
		cobj = CreateObject(object, x, y, z, 0.0, 0.0, 0.0);
		SaveObjectToFile(playerid, object, x, y, z);
		EditObject(playerid, cobj);
        }
    }
    return 1;
}
It saved "CreateObject(fф"


Re: How to save it? - Mouiz - 06.07.2015

Thanks for the help!
But i made a fixed one.