How to save it?
#1

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)
	}
}
Reply
#2

Text or MYSQL ?
Reply
#3

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

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

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ф"
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)