Rename DFF name on IPL map -
cellps - 26.06.2018
Hi everyone, I made this code to add the DFF names on each line, but it is not coming out correctly, when I add 2 lines to rename just rename 1, when I add 3 lines just rename 2 and so on.
Can anybody help me ?
Код:
#define dummy "dummy"
stock RenameIPL(FileName[], Code[])
{
new File:File, String[1000], String2[1000];
format(String,sizeof(String),"Object Renamed/%s.txt", FileName);
format(String2,sizeof(String2),"%s\r\n", Code);
File = fopen(String, io_append);
fwrite(File, String2);
fclose(File);
return 1;
}
stock RenameDummy(ID, DFFName[50], Interior, Float:X,Float:Y,Float:Z, Float:RX,Float:RY,Float:RZ,Float:RR)
{
if(ID == 1001) {DFFName = "House1";}
if(ID == 1002) {DFFName = "House2";}
new String[1000];
format(String,sizeof(String),"%d, %s, %d, %f,%f,%f, %f,%f,%f,%f, -1", ID, DFFName, Interior, X,Y,Z, RX,RY,RZ,RR);
RenameIPL("IPL_Renamed", String);
return 1;
}
public OnGameModeInit()
{
RenameDummy(1001, dummy, 0, 2760.900400, 1219.700200, 11.200000, 0, 0, 0.71937011, 0.69462698);
RenameDummy(1002, dummy, 0, 2760.900400, 1219.700200, 11.200000, 0, 0, 0.71937011, 0.69462698);
return 1;
}
Result:
https://imgur.com/a/dRd1cxk
Re: Rename DFF name on IPL map -
Sasino97 - 26.06.2018
I guess that the code is crashing before writing the last line, try to add a printf after the two calls.
PHP код:
public OnGameModeInit()
{
RenameDummy(1001, dummy, 0, 2760.900400, 1219.700200, 11.200000, 0, 0, 0.71937011, 0.69462698);
RenameDummy(1002, dummy, 0, 2760.900400, 1219.700200, 11.200000, 0, 0, 0.71937011, 0.69462698);
printf("Not crashed");
return 1;
}
Off topic: this is not related to your problem, but I suggest not to
fopen and
fclose continuously the file for each single call, I suggest you to implement the following:
PHP код:
IPL:OpenIPL(filename[]); // opens the file and returns a progressive int tagged IPL
CloseIPL(IPL:id); // closes the file opened by the specified IPL and frees that id
RenameIPL(IPL:id, code[]); // appends to the file what you need to write