How to fix this?
#1

I have made an object editing command but when i see the log,the object id is in other language

Код:
SaveObjectToFile(playerid, objectid, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	new
	File:file,
	line[100];
    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, %f, %f, %f);\r\n",objectid, fX, fY, fZ, fRotX, fRotY, fRotZ);
	fwrite(file, line);
	fclose(file);
}

CMD:createobject(playerid, params[])
{
	ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Objects", "Enter the object id you want to add", "OK", "Cancel");
    CreateObject(4206, -1683.190917, 704.806335, 30.829187, -55.900032, -0.300000, 0.000000);
}

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;
}

public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
    if(response == EDIT_RESPONSE_FINAL)
    {
    SaveObjectToFile(playerid, cobj, fX, fY, fZ, fRotX, fRotY, fRotZ);
	}
}
The real object id is 2406 and output is:

Код:
CreateObject(й›-ўљ, -1683.190917, 704.806335, 30.829187, -55.900032, -0.300000, 0.000000);
Reply
#2

Код:
SaveObjectToFile(playerid, objectid, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	new
	File:file,
	line[100];
    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, %f, %f, %f);\r\n",objectid, fX, fY, fZ, fRotX, fRotY, fRotZ);
	fwrite(file, line);
	fclose(file);
}
You used %s instead of %i - it's an integer. ('CreateObject(%s')
Reply
#3

Quote:
Originally Posted by rymax99
Посмотреть сообщение
Код:
SaveObjectToFile(playerid, objectid, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	new
	File:file,
	line[100];
    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, %f, %f, %f);\r\n",objectid, fX, fY, fZ, fRotX, fRotY, fRotZ);
	fwrite(file, line);
	fclose(file);
}
You used %s instead of %i - it's an integer. ('CreateObject(%s')
Dident worked,now it showed:

Код:
CreateObject(2, 2033.176879, 1343.862915, 10.454423, -33.100009, 0.000000, 0.000000);
Reply
#4

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
Dident worked,now it showed:

Код:
CreateObject(2, 2033.176879, 1343.862915, 10.454423, -33.100009, 0.000000, 0.000000);
Because it's %d .. Not %i


Try this:

PHP код:
SaveObjectToFile(playeridobjectidFloat:fXFloat:fYFloat:fZFloat:fRotXFloat:fRotYFloat:fRotZ) {
    new 
File:fileline[100];
    
GetPlayerName(playeridpnamsizeof(pnam));
    if(!
fexist(ANIM_SAVE_FILE)) {
        
file fopen(ANIM_SAVE_FILEio_write);
    } else {
        
file fopen(ANIM_SAVE_FILEio_append);
        
format(line100"CreateObject(%d, %f, %f, %f, %f, %f, %f);\r\n",objectidfXfYfZfRotXfRotYfRotZ);
        
fwrite(fileline);
        
fclose(file);
    }

Reply
#5

Quote:
Originally Posted by Prokill911
Посмотреть сообщение
Because it's %d .. Not %i


Try this:

PHP код:
SaveObjectToFile(playeridobjectidFloat:fXFloat:fYFloat:fZFloat:fRotXFloat:fRotYFloat:fRotZ) {
    new 
File:fileline[100];
    
GetPlayerName(playeridpnamsizeof(pnam));
    if(!
fexist(ANIM_SAVE_FILE)) {
        
file fopen(ANIM_SAVE_FILEio_write);
    } else {
        
file fopen(ANIM_SAVE_FILEio_append);
        
format(line100"CreateObject(%d, %f, %f, %f, %f, %f, %f);\r\n",objectidfXfYfZfRotXfRotYfRotZ);
        
fwrite(fileline);
        
fclose(file);
    }

With %d i get:
Код:
CreateObject(4, 2032.036010, 1342.500000, 9.852117, -88.600013, 0.000000, 0.000000);
Reply
#6

There is the whole filterscript:

Код:
#include <a_samp>
#include <zcmd>
#define FILTERSCRIPT
#define COL_WHITE "{FFFFFF}"
#define COL_GREEN "{00FF00}"
#define ANIM_SAVE_FILE "Objects.txt"
new object;
new cobj;
new pnam[MAX_PLAYER_NAME];

public OnFilterScriptInit()
{
	print("Map Editor Loaded");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

SaveObjectToFile(playerid, objectid, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	new
	File:file,
	line[100];
        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(%d, %f, %f, %f, %f, %f, %f);\r\n", objectid, fX, fY, fZ, fRotX, fRotY, fRotZ);
	fwrite(file, line);
	fclose(file);
}

CMD:createobject(playerid, params[])
{
	ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Objects", "Enter the object id you want to add", "OK", "Cancel");
        CreateObject(4206, -1683.190917, 704.806335, 30.829187, -55.900032, -0.300000, 0.000000);
}

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;
}

public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
    if(response == EDIT_RESPONSE_FINAL)
    {
    SaveObjectToFile(playerid, cobj, fX, fY, fZ, fRotX, fRotY, fRotZ);
    }
}
Reply
#7

Doesn't matter if it's %d or %i, cobj stores the object id not object model id! you have to save the input in another variable and save that to the file instead of cobj!

(sorry for the %s mistake with the file thing)

All you have to do is to change cobj to "object", like this

Код:
SaveObjectToFile(playerid, object, fX, fY, fZ, fRotX, fRotY, fRotZ);
Reply
#8

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
Dident worked,now it showed:

Код:
CreateObject(2, 2033.176879, 1343.862915, 10.454423, -33.100009, 0.000000, 0.000000);
What exactly are you wanting the code to accomplish?

Quote:
Originally Posted by Prokill911
Посмотреть сообщение
Because it's %d .. Not %i


Try this:

PHP код:
SaveObjectToFile(playeridobjectidFloat:fXFloat:fYFloat:fZFloat:fRotXFloat:fRotYFloat:fRotZ) {
    new 
File:fileline[100];
    
GetPlayerName(playeridpnamsizeof(pnam));
    if(!
fexist(ANIM_SAVE_FILE)) {
        
file fopen(ANIM_SAVE_FILEio_write);
    } else {
        
file fopen(ANIM_SAVE_FILEio_append);
        
format(line100"CreateObject(%d, %f, %f, %f, %f, %f, %f);\r\n",objectidfXfYfZfRotXfRotYfRotZ);
        
fwrite(fileline);
        
fclose(file);
    }

Incorrect - %d and %i are the exact same - https://sampwiki.blast.hk/wiki/Format

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
Doesn't matter if it's %d or %i, cobj stores the object id not object model id! you have to save the input in another variable and save that to the file instead of cobj!

(sorry for the %s mistake with the file thing)

All you have to do is to change cobj to "object", like this

Код:
SaveObjectToFile(playerid, object, fX, fY, fZ, fRotX, fRotY, fRotZ);
Given what it looks like, I'd assume you meant 'objectid' for the second param instead of 'object'. :P
Reply
#9

Код:
#include <a_samp>
#include <zcmd>
#define FILTERSCRIPT
#define COL_WHITE "{FFFFFF}"
#define COL_GREEN "{00FF00}"
#define ANIM_SAVE_FILE "Objects.txt"
new object;
new cobj;
new pnam[MAX_PLAYER_NAME];

public OnFilterScriptInit()
{
	print("Map Editor Loaded");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

SaveObjectToFile(playerid, objectid, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	new
	File:file,
	line[100];
    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(%d, %f, %f, %f, %f, %f, %f);\r\n", object, fX, fY, fZ, fRotX, fRotY, fRotZ);
	fwrite(file, line);
	fclose(file);
}

CMD:createobject(playerid, params[])
{
	ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Objects", "Enter the object id you want to add", "OK", "Cancel");
    CreateObject(4206, -1683.190917, 704.806335, 30.829187, -55.900032, -0.300000, 0.000000);
}

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;
}

public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
    if(response == EDIT_RESPONSE_FINAL)
    {
    SaveObjectToFile(playerid, object, fX, fY, fZ, fRotX, fRotY, fRotZ);
	}
}
I used the "object" variable but it showed:

Код:
CreateObject(8, 2029.585083, 1343.103027, 9.823666, -88.799987, 0.000000, 0.000000);
If i am wrong so can you show me how to do it?
Reply
#10

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
Код:
#include <a_samp>
#include <zcmd>
#define FILTERSCRIPT
#define COL_WHITE "{FFFFFF}"
#define COL_GREEN "{00FF00}"
#define ANIM_SAVE_FILE "Objects.txt"
new object;
new cobj;
new pnam[MAX_PLAYER_NAME];

public OnFilterScriptInit()
{
	print("Map Editor Loaded");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

SaveObjectToFile(playerid, objectid, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	new
	File:file,
	line[100];
    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(%d, %f, %f, %f, %f, %f, %f);\r\n", object, fX, fY, fZ, fRotX, fRotY, fRotZ);
	fwrite(file, line);
	fclose(file);
}

CMD:createobject(playerid, params[])
{
	ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Objects", "Enter the object id you want to add", "OK", "Cancel");
    CreateObject(4206, -1683.190917, 704.806335, 30.829187, -55.900032, -0.300000, 0.000000);
}

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;
}

public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
    if(response == EDIT_RESPONSE_FINAL)
    {
    SaveObjectToFile(playerid, object, fX, fY, fZ, fRotX, fRotY, fRotZ);
	}
}
I used the "object" variable but it showed:

Код:
CreateObject(8, 2029.585083, 1343.103027, 9.823666, -88.799987, 0.000000, 0.000000);
If i am wrong so can you show me how to do it?
Try replacing it with 'objectid' - the edited object ID variable for the 'OnPlayerEditObject' callback is 'objectid' and not 'object'.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)