-
|
I am wondering if native interoperability is possible for this kind of native(s)? |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 1 reply
-
|
Yes, that is already possible, see the wiki. The tag is |
Beta Was this translation helpful? Give feedback.
-
|
Hello, an update to this. I just read this part:
and it answered my question. I am asking about the variadic arguments. |
Beta Was this translation helpful? Give feedback.
-
|
Then see the example below that paragraph, about Do you have any particular code or native function you are trying to adapt? I am not aware of any variadic functions that would use output buffers. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I don't think that using As per native function, I want to use it on |
Beta Was this translation helpful? Give feedback.
-
|
Why? Have you tried it? |
Beta Was this translation helpful? Give feedback.
-
|
Yes. It works like for this: native MyNative(id, output[], size = sizeof output, ...);
native MyNativeImpl(id, AmxString:output, size, ...) = MyNative;but in my case (returning PawnPlus string) it won't work (or is there a way to do this?): native MyNative(id, output[], size = sizeof output, ...);
native MyNativeImpl(id, AmxString:output, size, ...) = MyNative;
stock String:MyNativeStr(Template:id, ...) // <-- this
{
new String:output = str_new_buf(8192);
MyNativeImpl(id, output, 8192, ...);
return output;
} |
Beta Was this translation helpful? Give feedback.
-
|
That one should work in theory (just prefer |
Beta Was this translation helpful? Give feedback.
-
|
Hi, the deficieny in samp-rs is now gone and this line of code below is working fine: #include <open.mp>
#include <PawnPlus>
#include <templates>
main()
{
new Template:templateBanned = CreateTemplate(
"Your account {{ name }} has been banned!\n\n\
Reason: {{ reason }}\n\
Duration: {{ days }} days\n\
If you disagree, please file an appeal at: {{ forum }}");
new String:dest = str_new_buf(1024);
RenderTemplateStr(templateBanned, dest, 1024,
PAIR_STR("name", "playerName"),
PAIR_STR("reason", "Hello World"),
PAIR_INT("days", 30),
PAIR_STR("forum", "https://forum.website.com")
);
str_resize(dest, str_findc(dest, '\0'));
print_s(dest);
}what I mean is not working is this: native RenderTemplateImpl(Template:id, AmxStringBuffer:dest, len, ...) = RenderTemplate;
stock String:RenderTemplateStr(Template:id, ...)
{
new String:dest = str_new_buf(1024);
RenderTemplateImpl(id, dest, 1024, ...); // this will throw a compilation error
str_resize(dest, str_findc(dest, '\0'));
return dest;
}Link to my pawn-templates repo: https://github.com/Tiaansu/pawn-templates |
Beta Was this translation helpful? Give feedback.
-
|
Don't confuse me like that. 😄 I thought the There are a few options ‒ use |
Beta Was this translation helpful? Give feedback.
Don't confuse me like that. 😄 I thought the
...was meant to be a placeholder. Of course you can't use it like that, that is a limitation of Pawn.There are a few options ‒ use
#emitto call it manually or y_va for nicer syntax. PawnPlus also offers a solution ‒list_get_args("+"),list_new_argsin combination with a macro, andpawn_call_nativeto call the native with thelspecifier. This however won't work if the argument is supposed to be a reference.