SA-MP Forums Archive
Octal in PAWN - 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: Octal in PAWN (/showthread.php?tid=306357)



Octal in PAWN - Terminator3 - 26.12.2011

I want to write a function that changes 010 (10 in PAWN) to 8, 020 (20 in PAWN) to 16 etc.


Re: Octal in PAWN - [MG]Dimi - 26.12.2011

You mean 80% of something?

pawn Код:
stock GetOctal(value)
{
    new newvalue = value/100*80;
    return newvalue;
}



Re: Octal in PAWN - Terminator3 - 26.12.2011

no, octal from C/C++

00001 = 1
00002 = 2
00004 = 4
00010 = 8
00020 = 16
00040 = 32
00100 = 64
etc.


Re: Octal in PAWN - [MG]Dimi - 26.12.2011

Just explain me what does it do and I'll create you mathematics formula.


Re: Octal in PAWN - WooTFTW - 26.12.2011

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
Just explain me what does it do and I'll create you mathematics formula.
Dude, you can't create an formula for it.
****** it and read more about it.


Re: Octal in PAWN - Terminator3 - 26.12.2011

I write a plugin that has a 'chmod' function, in C/C++ using the octal number like 0777 0644 etc.
if i say, that people must use 1 2 4 8 16 (1 | 2 | 4) etc. it would be strange, would prefer to use the 0777 0644 etc.
000 = 0
010 = 8
020 = 16
030 = 24 (010 + 020)
040 = 32
050 = 40 (010 + 040)
060 = 48 (040 + 020)
070 = 56 (010 + 020 + 040)

like using 1 2 4 8 16 32 64 128 256 512 1024 etc.

//EDIT:
pawn Код:
stock OctalValue(x)
{
    new str[10], rn;
    valstr(str, x);
    for(new z, i = strlen(str) - 1; i >= 0; i--, z++)
        rn += (str[i] - '0') * floatround(floatpower(8.0, z));

    return rn;
}
is there any easier way?