Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

[Include] Data Convert (decimal / hexadecimal / binary)

$
0
0
Hello, I would like to present a simple include to convert numbers between systems, decimal, hexadecimal, binary.

PHP Code:

/****************************************************************************************************
 *                                                                                                  *
 *                                           Data Convert                                           *
 *                                                                                                  *
 * Copyright © 2016 Abyss Morgan. All rights reserved.                                              *
 *                                                                                                  *
 * Download: https://github.com/AbyssMorgan/SA-MP/tree/master/include/SAM                           *
 *                                                                                                  *
 * File Version: 1.7                                                                                *
 *                                                                                                  *
 * Functions:                                                                                       *
 * GetFileHandleID(File:handle);                                                                    *
 * GetFileID(File:handle);                                                                          *
 * bool:IsIdentical({AllTag,_}:variable1,{AllTag,_}:variable2);                                     *
 * BoolToInt(bool:boolean);                                                                         *
 * bool:IntToBool(value);                                                                           *
 * bool:StringToBool(string[]);                                                                     *
 * StringToInt(string[]);                                                                           *
 * BinToInt(string[]);                                                                              *
 * IntToBin(value);                                                                                 *
 * HexToInt(string[]);                                                                              *
 * IntToHex(int);                                                                                   *
 * IntToHexEx(int);                                                                                 *
 * HexToBin(string[]);                                                                              *
 * BinToHex(string[]);                                                                              *
 * BinToHexEx(string[]);                                                                            *
 * strcopy(input[],output[]);  //string copy for warning 224: indeterminate array size              *
 * fstrcopy(input[],output[],maxdest = sizeof(output));   //fast string copy                        *
 * ABCToCBA(input[],output[]);                                                                      *
 * AnyToInt(str[],type,&bool:flag);                                                                 *
 * IntToAny(value,output[],type);                                                                   *
 * rot13(string[]);                                                                                 *
 * code128(input[],output[]);                                                                       *
 * swap_int({Float,_}:int1,{Float,_}:int2);                                                         *
 * swap_string(string1[], string2[], dest1 = sizeof(string1), dest2 = sizeof(string2));             *
 * FloatToInt(Float:value); //Convert Float binary data to Integer binary data                      *
 * Float:IntToFloat(value); //Convert Integer binary data to Float binary data                      *
 *                                                                                                  *
 ****************************************************************************************************/ 

Examples:
PHP Code:

new File:edi fopen("test.txt",io_readwrite);
new 
id GetFileID(edi); //returns the number of open file: 1, 2, 3, 4, ...


new BinToInt("1010"); //return 10


new hex[10];
hex IntToHex(15); //return 00000F
hex IntToHexEx(15); //return F


new 15Float:15.0;
if(
IsIdentical(g,h)){ //This operator can only be used on variables
    
printf("YES");
} else {
    
printf("NO"); //<-- print this
}


new 
buf[128];
ABCToCBA("Hello",buf);
printf(buf); //print: olleH


new v1 15v2 19;
swap_int(v1,v2); //swapvars by Crayder
//after operation: v1 = 19, v2 = 15


new test FloatToInt(25666.000000); //return 1187546112

new Float:test2 IntToFloat(1084227584); //return 5.0


//http://www.rot13.com
new rot[64];
rot rot13("San Andreas Multiplayer"); //return "Fna Naqernf Zhygvcynlre" 

Download:
DataConvert.inc

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>