samp.directory
← Scripts and libraries

hpq-dev/bigInt

bigInt for sa-mp

Library★ 8updated Apr 2022No licencePawn
Open on GitHub

This repository has no licence file. It is public to read, but that alone does not give permission to reuse it.

Try it in the Pawn compiler →

Adds its include files, with the libraries it depends on, to the Pawn compiler in your browser, ready to include in a script.

README.md

BIGINT for SAMP!

Installation

Include in your code and begin using the library:

#include <BigInt>

Usage

To create a variable

new BigInt:var_name;

This function adds numbers in bigint (max 2147483647/callback)

addBytes32(var_name, 1231231231);

With this function you can add over the limit of 2147483647. It is recommended to use this function only when large numbers are needed.

addBytes64(var_name, #3453453453453525534);

This function formats your bigint variable.

formatBytes(var_name);

output example:
// 312.123.512.523

This function sets the variable to 0.

resetBigInt(var_name);

This function returns the number as a string.

valueBigInt(var_name);

This function converts from 64 bits to 32 bits.

bytes32(var_name);

With this function you can do some operations for the bigint variable.

OPByte(var_name, operator, oper1);

// Operators:
>=
<=
==
!=
<
>

// example:
if(OPByte(var_name, <=, #10000)) return true;

This function checks for string numbers.

isBigInt(const string[]);

This function transforms from a string to bigint. (be careful there are numbers in that string!).

converBytes(var_name, const string[]);

These functions are compatible on mysql r41-4 and r-39-6

cache_get_value_name_bigint(var_name, row, column[]); // r41-4
cache_get_field_content_bigint(var_name, row, column[]); // r39-6

To make it compatible with a money system:

new BigInt:cash[MAX_PLAYERS];

#define GivePlayerCash(%0,%1) addBytes32(cash[%0],%1)
#define GetPlayerCash(%0) bytes32(cash[%0])

// show money
new str[50];
format(str, sizeof str, "%s", formatBytes(cash[playerid]));

// login
cache_get_value_name_bigint(cash[playerid],0,"Money");

// disconect save
public OnPlayerDisconect(playerid) {
    new query[128];
    mysql_format(handle, query, "UPDATE `users` SET `Money` = '%s' ...", valueBigInt(cash[playerid]));
    mysql_tquery(handle, query);
    return true;
}

This page is built from what GitHub publishes about the repository. samp.directory does not host the code. Report a problem with this listing

hpq-dev/bigInt: SA-MP Library | samp.directory