Skip to content

Instantly share code, notes, and snippets.

View ziggi's full-sized avatar
🏠
Working from home

Sergei Marochkin ziggi

🏠
Working from home
View GitHub Profile
@ziggi
ziggi / sq_api_example.pwn
Last active July 3, 2018 15:09 — forked from Westie/gist:234209
SampQueryAPI (for sa-mp 0.3.7) example
<?php
include "SampQueryAPI.php";
$query = new SampQueryAPI('127.0.0.1', '7777');
if ($query->isOnline()) {
$aInformation = $query->getInfo();
$aServerRules = $query->getRules();
@ziggi
ziggi / orgsys.pwn
Last active October 11, 2017 07:54
Organization System
#include <a_samp>
#define ORGANIZATION_MAX_NAME 32
#define ORGANIZATION_MAX_RANK_NAME 32
enum {
ORGANIZATION_NONE,
ORGANIZATION_LSPD,
ORGANIZATION_FBI,
ORGANIZATION_AVIA,
@ziggi
ziggi / regsys.pwn
Last active June 21, 2021 18:39
MySQL ORM Register System
/*
About: mysql orm register system
Author: ziggi
*/
#include <a_samp>
#include "a_mysql"
@ziggi
ziggi / GetCoordsBefore.pwn
Last active August 29, 2015 14:20
GetCoordsBefore functions collection
stock GetCoordsBefore(Float:x, Float:y, Float:a, Float:distance, &Float:res_x, &Float:res_y)
{
res_x = x + (distance * floatsin(-a, degrees));
res_y = y + (distance * floatcos(-a, degrees));
}
stock ReturnRandomSymbol(bool:uppercase = true, bool:lowercase = true)
{
new value = -1;
if (uppercase && lowercase) {
value = random(2);
}
if (uppercase && (value == 0 || value == -1)) {
value = mathrandom('A', 'Z');
@ziggi
ziggi / IsIpAddress.pwn
Last active October 1, 2018 13:09
Return 1 if string is ip address else 0
#if !defined IS_IN_RANGE
#define IS_IN_RANGE(%0,%1,%2) (((%0) - ((%1) + cellmin)) < (((%2) + 1) - ((%1) + cellmin)))
#endif
stock IsIpAddress(const string[])
{
new
octet,
j = 100;
@ziggi
ziggi / GetWeekName.pwn
Last active January 27, 2016 07:36
return week name by date
enum WeekLang {
WEEK_LANG_ENGLISH,
WEEK_LANG_RUSSIAN,
}
static const
gDaysOfWeek[WeekLang][][] = {
{
!"Thursday",
!"Friday",
@ziggi
ziggi / crop_str.pwn
Created April 24, 2015 09:49
Crop string
stock crop_string(const input_str[], output_str[], const length = 60, const size = sizeof(output_str))
{
new
buffer[1024],
i = 0,
j = 0;
while (input_str[i] != '\0') {
if (i % length == 0) {
buffer[j] = '\n';
@ziggi
ziggi / parents.js
Last active August 11, 2022 16:10
Vanilla JS jQuery.parents() realisation (npm module: https://github.com/ziggi/dom-parents)
Element.prototype.parents = function(selector) {
var elements = [];
var elem = this;
var ishaveselector = selector !== undefined;
while ((elem = elem.parentElement) !== null) {
if (elem.nodeType !== Node.ELEMENT_NODE) {
continue;
}
@ziggi
ziggi / example.php
Last active December 23, 2015 14:59
Usage arrays with OOP
<?php
inculde 'oop_config.php';
echo Config::get()->site->path;
// result: some_path/
$cfg = new Config;
echo $cfg->site->path;
// result: some_path/