float argument - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (
https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: float argument (
/showthread.php?tid=267642)
float argument -
Terminator3 - 09.07.2011
how to return float as argument
Code:
void ReturnFloatArg(AMX* amx, cell param, double value)
{
cell *cptr;
amx_GetAddr(amx, param, &cptr);
*cptr = amx_ftoc(value);
}
and use
Code:
ReturnFloatArg(amx, params[1], atof(str));
str is "100.0"
what is wrong?
sorry for my bad English
Re: float argument -
Hiddos - 09.07.2011
https://sampforum.blast.hk/showthread.php?tid=69699
/endof
Re: float argument -
Terminator3 - 09.07.2011
@Hiddos omg this problem is from SDK sa:mp not from C++ !
if not here then where a will asking for help?
Rather few people familiar with the sa:mp SDK
Re: float argument -
BlueG - 09.07.2011
You should seriously have a look at the implementer's guide, otherwise you will never understand how it works. It explains you how to pass floats, strings and integers.
http://www.compuphase.com/pawn/Pawn_...nter_Guide.pdf
I'm going to quote some important paragraphs you probably need to learn, because your current structure is not going to work.
Quote:
The params argument points to an array that holds the parameter list of the function. The value of params[0] is the number of bytes passed to the function (divide by the size of a cell to get the number of parameters passed to the function); params[1] is the first argument, and so forth.
|
Quote:
The symbols amx_ctof and amx_ftoc are macros that cast a “cell” type into “float” and vice versa, but in contrast to the standard type casts of C/C++ they do not change the bit representation of the value that is cast.
|