SA-MP Forums Archive
floatsqroot - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: floatsqroot (/showthread.php?tid=297593)



floatsqroot - STMatt - 16.11.2011

Hi , I have some problems. I created an calculator script so I came to the root cmd. I created it but i don't know what's wrong with the code whatever the number I enter it always gives me the results like 10821082 and that stuff.

So can somebody make my code working?

pawn Код:
YCMD:root(playerid,params[],help) {
            #pragma unused help
            new sq,Float:res,str[128];
            if(sscanf(params, "i", sq)) return SendClientMessage(playerid,-1,"USAGE: /root [number]");
            res = floatsqroot(sq);
            format(str,sizeof str,"RESULT: %i",res);
            SendClientMessage(playerid,-1,str); return true; }



Re: floatsqroot - oliverrud - 16.11.2011

pawn Код:
YCMD:root(playerid,params[],help) {
            #pragma unused help
            new sq,Float:res,str[128];
            if(sscanf(params, "i", sq)) return SendClientMessage(playerid,-1,"USAGE: /root [number]");
            res = floatsqroot(sq);
            format(str,sizeof str,"RESULT: %f",res);
            SendClientMessage(playerid,-1,str); return true; }



Re: floatsqroot - STMatt - 16.11.2011

Thanks ! I forgot that %f is for floats ! Silly mistake Thanks again.