Wait.. solved what? Well, it all started with a simple "format" (format pawn strings) native to pawn. My friend sam told me that i could use the "strformat" in amxstring.c for use in pawn script. Tried that, but it wasn't so good, specially because it blocked all code from that line onwards. I tried doing another format native, which i putted in my "natives.h" header. Now, that failed. Everything keep crashing and i tried to solve it, but whent nowhere. I was trying to solve it for 2 days - combining sam's printf / the original format / code from googled search. And, suddently, it worked! I finally cracked the big question i had in my mind, why it didn't work, what do that line do, etc. And the happiness - i finally solved it. Now format works as it should. Without any help. Well, maybe a little from sam... But, i still feel so proud of myself. Not to brag, but i do.
Any poor humane searching their ass off for the code;
// native format(dest[], size=sizeof dest, const string[], ...);
static cell AMX_NATIVE_CALL n_format(AMX *amx,const cell *params)
{
cell *cstr = NULL;
AMX_FMTINFO info;
TCHAR output[MAX_FORMATSTR];
memset(&info,0,sizeof info);
info.params=params+4;
info.numparams=(int)(params[0]/sizeof(cell))-3;
info.skip=0;
info.length=MAX_FORMATSTR;
info.f_putchar = putchar;
info.f_putstr = putstr;
info.user = output;
output[0] = 0;
amx_GetAddr(amx, params[3], &cstr);
amx_printstring(amx,cstr,&info); //info contains "user" which points to output
//also format output(user) with cstr with params from info
amx_GetAddr(amx, params[1], &cstr); //the string in pawn to save to.
amx_SetString(cstr, (char*)output, 0, 0, (int)params[2]);
return 1;
}
MAX_FORMATSTR is 256.
In other news, i recently got chinatown wars to play with on the PSP. I must say it feels like GTA IV in the PSP. Other words, it rocks.
In and out,
Leopard
Hey man its Pghpunkid, its amazing how Sam can chime in and give a little assistance, and off you go huh?
ReplyDelete