Skip to content

Instantly share code, notes, and snippets.

/*----------------------------------------------------------------------------*\
==========================
y_colours - X11 colours!
==========================
Description:
This holds the colour information that used to be part of the text system
but which is far more useful than just for text. This now supports the full
set of X11 colours, both by name and by definition. You can also define
your own if you so choose (up to 32 - should be enough given that this
includes the X11 colours).
<?php
foreach ($amx as $k => $v) {
if (is_object($v)) {
foreach ($v as $_k => $_v) {
if (is_object($_v))
continue;
else if (is_array($_v))
$_v = "Array(" . count($_v) . ")";
$pad = str_repeat(' ', 16 - strlen($_k));
diff --git a/y_dohooks.inc b/y_dohooks.inc
index 0adf841..b39ed71 100644
--- a/y_dohooks.inc
+++ b/y_dohooks.inc
@@ -62,6 +62,7 @@ Changelog:
#include <YSI\internal\y_version>
#include <a_samp>
#include <YSI\y_debug>
+#include <YSI\y_stringhash>
@oscar-broman
oscar-broman / gist:2358595
Created April 11, 2012 10:47
y_dohooks.inc
/*----------------------------------------------------------------------------*\
==============================
y_hooks - Hook any callback!
==============================
Description:
Automatically hooks any callbacks with a very simple syntax.
Legal:
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
@oscar-broman
oscar-broman / notepad++.php
Created July 14, 2012 22:30
Generate Notepad++ configuration
<?php
// Requires PAWN-Scanner
// Get it here: https://github.com/oscar-broman/PAWN-Scanner
// Include path to scan
define('INCLUDE_PATH', './', 'a_npc.inc');
// Where to save the files
define('PAWN_XML', './PAWN.xml');
define('USER_DEF_LANG', './userDefineLang.xml');

Built-in modules

PBP comes with a few modules by default. These are not mandatory in any way, you can simply remove those you don't need.

Core module 

The core module doesn't do much.. yet.

StaticGroups module 

You can declare groups as global variables with the following syntax:

@oscar-broman
oscar-broman / gist:3653399
Created September 6, 2012 09:05
UTF8 encode array/object structure in PHP
<?php
function utf8_encode_deep(&$input) {
if (is_string($input)) {
$input = utf8_encode($input);
} else if (is_array($input)) {
foreach ($input as &$value) {
utf8_encode_deep($value);
}
unset($value);
@oscar-broman
oscar-broman / gist:4545758
Created January 16, 2013 09:13
Fetch MySQLi results properly typed.
<?php
function mysqli_fetch_all_typed($result, $resulttype = MYSQLI_NUM)
{
if (!$result)
return null;
$fields = $result->fetch_fields();
if (method_exists($result, 'fetch_all')) {
$rows = $result->fetch_all($resulttype);
@oscar-broman
oscar-broman / free-port.js
Created May 26, 2013 12:14
Find a free port in Node.js
/*
Much better approach than trying to connect to a range of ports.
*/
var net = require('net');
getFreePort(function(err, port) {
if (err) throw err;
console.log('Port: ' + port);
@oscar-broman
oscar-broman / db-errors.inc
Last active December 24, 2015 21:39
db_query error reporting
#include <a_samp>
#tryinclude "amx_assembly\amx_header"
#if !defined _inc_amx_header
#error amx_assembly is required. Get it here: github.com/zeex/amx_assembly
#endif
#include "amx_assembly\dynamic_call"
#include "amx_assembly\phys_memory"