PDA

View Full Version : How to fix this?


Mouiz
06/07/2015, 12:27 PM
I have made an object editing command but when i see the log,the object id is in other language :confused:

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

rymax99
06/07/2015, 12:44 PM
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')

Mouiz
06/07/2015, 01:35 PM
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);

Prokill911
06/07/2015, 01:46 PM
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:


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

Mouiz
06/07/2015, 01:51 PM
Because it's %d .. Not %i


Try this:


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

With %d i get:
CreateObject(4, 2032.036010, 1342.500000, 9.852117, -88.600013, 0.000000, 0.000000);

Mouiz
06/07/2015, 01:54 PM
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);
}
}

JaydenJason
06/07/2015, 01:55 PM
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);

rymax99
06/07/2015, 01:58 PM
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?

Because it's %d .. Not %i


Try this:


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

Incorrect - %d and %i are the exact same - https://wiki.sa-mp.com/wiki/Format

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

Mouiz
06/07/2015, 02:01 PM
#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?

rymax99
06/07/2015, 02:13 PM
#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'.

Mouiz
06/07/2015, 02:17 PM
Try replacing it with 'objectid' - the edited object ID variable for the 'OnPlayerEditObject' callback is 'objectid' and not 'object'.

It cant be changed otherwise it will give an error:

C:\Users\Mouiz\Desktop\FreeRoam\filterscripts\obje ctedit.pwn(57) : error 025: function heading differs from prototype

Ok now i changed it and i dident got an error but it shows objectid 16

rymax99
06/07/2015, 02:43 PM
You are aware that it's going to return the ID of the object edited, the internal ID, not the model ID of the object, right?

Mouiz
06/07/2015, 02:47 PM
You are aware that it's going to return the ID of the object edited, the internal ID, not the model ID of the object, right?
I am trying to get the numbers which are entered in the Input box

DarkLouis
06/07/2015, 03:08 PM
Here you're :)



new model[MAX_OBJECTS];

stock SaveObjectToFile(playerid, modelid, 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", modelid, fX, fY, fZ, fRotX, fRotY, fRotZ);
fwrite(file, line);
fclose(file);
return 1;
}

CMD:createobject(playerid, params[])
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Objects", "Enter the object id you want to add", "OK", "Cancel");
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
{
if(response)
{
new Float:x, Float:y, Float:z, object = strval(inputtext);
GetPlayerPos(playerid, x, y, z);
cobj = CreateObject(object, x, y, z, 0.0, 0.0, 0.0);
EditObject(playerid, cobj);
model[cobj] = object;
}
}
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, model[objectid], fX, fY, fZ, fRotX, fRotY, fRotZ);
}
return 1;
}

Mouiz
06/07/2015, 03:19 PM
Here you're :)



new model[MAX_OBJECTS];

stock SaveObjectToFile(playerid, modelid, 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", modelid, fX, fY, fZ, fRotX, fRotY, fRotZ);
fwrite(file, line);
fclose(file);
return 1;
}

CMD:createobject(playerid, params[])
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Objects", "Enter the object id you want to add", "OK", "Cancel");
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
{
if(response)
{
new Float:x, Float:y, Float:z, object = strval(inputtext);
GetPlayerPos(playerid, x, y, z);
cobj = CreateObject(object, x, y, z, 0.0, 0.0, 0.0);
EditObject(playerid, cobj);
model[cobj] = object;
}
}
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, model[objectid], fX, fY, fZ, fRotX, fRotY, fRotZ);
}
return 1;
}



Still showing invalid objectid

Mouiz
06/07/2015, 06:11 PM
I fixed it by my self