Code:
cell AMX_NATIVE_CALL formatEx(AMX* amx, cell* params)
{
char string__[128];
sprintf(string__, (const char *) params[1], params[2]);
logprintf(string__);
return 1;
}
Code:
#include <a_samp>
native formatEx(const format[], {Float,_}:...);
public OnGameModeInit()
{
formatEx("test %s, %d", "abc", 11);
return 1;
}
main(){}
What could be the cause of the crash?
#edit
Code:
#include <a_samp>
native formatEx(const format[], {Float,_}:...);
public OnGameModeInit()
{
formatEx("My test: string: %s, int: %d", "blablabla", 123);
return 1;
}
main(){}
+
Code:
cell AMX_NATIVE_CALL formatEx(AMX* amx, cell* params)
{
char string__[128];
int
len = NULL,
ret = NULL,
argc = params[0]/4;
cell *addr = NULL;
amx_GetAddr(amx, params[1], &addr);
amx_StrLen(addr, &len);
if(len)
{
len++;
char* formats = new char[ len ];
amx_GetString(formats, addr, 0, len);
sprintf(string__, formats, ¶ms[2]);
logprintf("%d L: %s",argc, string__);
delete[] formats;
}
return 1;
}
=
Anyone know why bad formatting text?