How to use new line(Enter) with SetObjectMaterialText -
ikey07 - 27.02.2013
Hello
Today after messing around abit with SetObjectMaterialText, I thought about some idea and it worked, with this you can set text in many lines on the object, in short this tutorial show you how to use \n with SetObjectMaterialText function.
The trick is hidding in the HTTP function, so you will need a_http include.
Result:
pawn Код:
#include <a_samp>#include <a_http>forward Response
(index, response_code, data
[]);
//forward http response ( https://sampwiki.blast.hk/wiki/HTTP )new MyObj;
//Define object for global usepublic OnFilterScriptInit
(){ HTTP
(-1, HTTP_GET,
"localhost/text.txt",
" ",
"Response");
//using HTTP_GET to read text file ( https://sampwiki.blast.hk/wiki/HTTP ) MyObj
= CreateObject
(objectid,
1211.9685,
-1344.7974,
14.1289,
0.0,
0.0,
0.0,
50.0);
//Create object ( https://sampwiki.blast.hk/wiki/CreateObject)}public Response
(index, response_code, data
[])//getting http response ( https://sampwiki.blast.hk/wiki/HTTP ){ SetObjectMaterialText
(MyObj ,data,
2,
140,
"Arial",
250,
1,0xFF000000,
-1,OBJECT_MATERIAL_TEXT_ALIGN_CENTER
);
//Set text from the file to the object ( https://sampwiki.blast.hk/wiki/SetObjectMaterialText ) return 1;
}
Text file contains:
AW: How to use new line(Enter) with SetObjectMaterialText -
Kwashiorkor - 27.02.2013
why dont you use \n instead?
Re: How to use new line(Enter) with SetObjectMaterialText -
ikey07 - 27.02.2013
For some reason \n doesnt work there.
AW: How to use new line(Enter) with SetObjectMaterialText -
Kwashiorkor - 27.02.2013
sure? whatever data[] contains - it will also work if you use it directly with SetObjectMaterialText without your HTTP method?
Re: How to use new line(Enter) with SetObjectMaterialText -
ikey07 - 27.02.2013
At some cases, for example when you use IG map editor, with bult-in SetObjectMaterialText, and you enter the text in the dialog, it wont apply \n
Re: How to use new line(Enter) with SetObjectMaterialText -
LarzI - 27.02.2013
Well then the in-game editor isn't optimal.
AW: How to use new line(Enter) with SetObjectMaterialText -
Kwashiorkor - 27.02.2013
inputdialogs will never ever accept "\n" - it will be "\\n" in the callback
Re: How to use new line(Enter) with SetObjectMaterialText -
Yves - 27.02.2013
so the HTT include hides the box?? if not i really need to know but awsome anyways
Re: How to use new line(Enter) with SetObjectMaterialText -
Vince - 27.02.2013
Quote:
Originally Posted by ikey07
At some cases, for example when you use IG map editor, with bult-in SetObjectMaterialText, and you enter the text in the dialog, it wont apply \n
|
Because \n isn't \n. When used directly in the script, it is a Line Feed (LF) character with ASCII code 10. That's right, a single character! When input into a dialog box, they're just two characters \ (ASCII 92) and n (ASCII 110), with no special meaning whatsoever.
http://www.asciitable.com/
Re: How to use new line(Enter) with SetObjectMaterialText -
chuck100 - 14.05.2013
Everything good but how to write on the object , I dont see where did you write 12 es in the full code :P