[Include] Useful Functions v1.0 (MySQL)
#1

Useful Functions v1.0
Based on MySQL
Introduction
Useful functions is based on MySQL, wich uses just functions, no queries. It gots 10 functions, based on a log that can be activated and dezactivated, with them you can set all what you need, by strings.
Theres nothing copied, all these fuctions are made from scratch. The author is PAWN++ Team (Romania), we usually make scripts for money, this is a free script.

Features
Using the following systems and plugins.
  • [REL] MySQL Plugin (R7 released) - Used for the DataBase (extracting/setting/deleting) *recommanded.
  • Wampp Server or Xampp - Used for edit the DataBase *recommanded.
Functions
  • MySQL_Log (bool:active = true)
    Код:
    bool active    - To activate choose true and to deactivate choose false.
  • MySQL_SetInt(char var[], int is, char where[], char condition[], char table[])
    Код:
    char var       - The table wich will be set.
    int is         - The number that will be set in the 'var'.
    char where     - Where it will be set.
    char condition - The condition to be set.
    char table     - The table with the information.
    Returns with 1.
  • MySQL_SetFloat(char var[], Float:is, char where[], char condition[], char table[])
    Код:
    char var       - The table wich will be set.
    float is       - The float that will be set in the 'var'.
    char where     - Where it will be set.
    char condition - The condition to be set.
    char table     - The table with the information.	
    Returns with 1.
  • MySQL_SetString(char var[], char is[], char where[], char condition[], char table[])
    Код:
    char var       - The table wich will be set.
    char is        - The float that will be set in the 'var'.
    char where     - Where it will be set.
    char condition - The condition to be set.
    char table     - The table with the information.	
    Returns with 1.
  • MySQL_GetFloat(char selected[], char var[], char condition[], char table[])
    Код:
    char selected  - The table from where it will be take.
    char var       - The row from where it will be take.
    char condition - The condition to be take
    char table     - The table with the information.
    Returns with the extracted float variable.
  • MySQL_GetInt(char selected[], char var[], char condition[], char table[])
    Код:
    char selected  - The table from where it will be take.
    char var       - The row from where it will be take.
    char condition - The condition to be take
    char table     - The table with the information.
    Returns with the extracted integer variable.
  • MySQL_GetString(char selected[], char var[], char condition[], char table[])
    Код:
    char selected  - The table from where it will be take.
    char var       - The row from where it will be take.
    char condition - The condition to be take
    char table     - The table with the information.
    Returns with the extracted string variable.
  • MySQL_Delete(char var[], char condition[], char table[])
    Код:
    char var       - The table from where it will be deleted.
    char condition - The condition to delete the row.
    char table     - The table with the information.
    Returns with 1.
  • MySQL_Count(char get[], char table[])
    Код:
    char get       - The table where the rows will be counted.
    char table     - The table with the information.
    Returns with number of rows
  • MySQL_If(char var[], char condition[], char table[])
    Код:
    char var       - The table wich will be rerified.
    char condition - The row will be take with a condition.
    char table     - The table with the information.
    Returns 0 if it exists or 1 if it doesen`t exists.
Install

1. Place it to the top of the script:

pawn Код:
#include <useful_functions>
2. Add these defines and fill them:

pawn Код:
#define PAWN_HOST "" // The IP of the server
#define PAWN_USER "" // The user of the server
#define PAWN_PASSWORD "" // The password of the server
#define PAWN_DATABASE "" // The name of the DataBase
2. Add the folder 'UF' with 'log.ini' in the directory scriptfiles.

Examples
  • MySQL_Log
    pawn Код:
    public OnGameModeInit()
    {
        MySQL_Log ( true );
        return 1;
    }
  • MySQL_SetInt
    pawn Код:
    YCMD:setint ( playerid, params[], help )
    {
        new
            giveplayerid,
            where [ 25 ],
            value;

        if ( sscanf ( params, "us[25]i", giveplayerid, where, value ) ) return SendClientMessage ( playerid, 0xFFFFFFAA, "{C8C8C8}USE: {FFFFFF}/setint (PartOfName/playerid) (where) (value)");

        MySQL_SetInt ( where, value, "username", GetName ( giveplayerid ), "players" );
        return 1;
    }
  • MySQL_SetFloat
    pawn Код:
    YCMD:setfloat ( playerid, params[], help )
    {
        new
            giveplayerid,
            where [ 25 ],
            Float:value;

        if ( sscanf ( params, "us[25]f", giveplayerid, where, value ) ) return SendClientMessage ( playerid, 0xFFFFFFAA, "{C8C8C8}USE: {FFFFFF}/setint (PartOfName/playerid) (where) (value)");

        MySQL_SetInt ( where, value, "username", GetName ( giveplayerid ), "players" );
        return 1;
    }
  • MySQL_SetString
    pawn Код:
    YCMD:setstring ( playerid, params[], help )
    {
        new
            giveplayerid,
            where [ 25 ],
            value [ 100 ];

        if ( sscanf ( params, "us[25]s[100]", giveplayerid, where, value ) ) return SendClientMessage ( playerid, 0xFFFFFFAA, "{C8C8C8}USE: {FFFFFF}/setint (PartOfName/playerid) (where) (value)");

        MySQL_SetInt ( where, value, "username", GetName ( giveplayerid ), "players" );
        return 1;
    }
  • MySQL_GetFloat
    pawn Код:
    YCMD:playerpos ( playerid, params[], help )
    {
        new
            name    [ 21 ],
            X,
            Y,
            Z;

        if ( sscanf ( params, "s[21]", name ) ) return SendClientMessage ( playerid, 0xFFFFFFAA, "{C8C8C8}USE: {FFFFFF}/playerpos (CompleteName)");

        X = MySQL_GetFloat( "cordX", name, "username", "players" );
        Y = MySQL_GetFloat( "cordY", name, "username", "players" );
        Z = MySQL_GetFloat( "cordZ", name, "username", "players" );
        printf ( "Name: %s, X: %f Y: %f Z:%f", name, x, y, z );
        return 1;
    }
  • MySQL_GetInt
    pawn Код:
    YCMD:adminlevel ( playerid, params[], help )
    {
        new
            name    [ 21 ],
            level;

        if ( sscanf ( params, "s[21]", name ) ) return SendClientMessage ( playerid, 0xFFFFFFAA, "{C8C8C8}USE: {FFFFFF}/playerpos (CompleteName)");

        level = MySQL_GetInt( "admin", name, "username", "players" );
        printf ( "Name: %s, Admin Level: %i, name, level );
        return 1;
    }
  • MySQL_GetString
    pawn Код:
    YCMD:playerpass ( playerid, params[], help )
    {
        new
            name    [ 21 ],
            password [ 50 ];

        if ( sscanf ( params, "s[21]", name ) ) return SendClientMessage ( playerid, 0xFFFFFFAA, "{C8C8C8}USE: {FFFFFF}/playerpos (CompleteName)");

        format ( password, 50, "%s", MySQL_GetString( "password", name, "username", "players" ) );
        printf ( "Name: %s, Password: %s, name, password );
        return 1;
    }
  • MySQL_Count
    pawn Код:
    public OnGameModeInit ( )
    {
        printf ( "There are %d accounts.", MySQL_Count ( "*", "players" ) );
        printf ( "There are %d bans.", MySQL_Count ( "*", "banlist" ) );
        return 1;
    }
  • MySQL_If
    pawn Код:
    public OnPlayerConnect ( playerid )
    {
        if ( MySQL_If ( "*", "username", GetName ( playerid ), "players" ) == 0 )
        {
            SendClientMessage ( playerid, 0xFFFFFFAA, "{C8C8C8}Welcome back.");
        } else return SendClientMessage ( playerid, 0xFFFFFFAA, "{C8C8C8}You don't have an account.");
        return 1;
    }
Bugs

We found no bug, if you find a bug, please contact us.

Author: PAWN++ Team
Credits: BlueG, Spookie
Download: Click
Password: pawnteam
Help: If you want to help us, send me a Private Message.

PAWN++
  • Armyw0w (Romania) - Founder
  • Alyn (Romania) - Founder
  • WaLLy (Romania) - Member
  • Spookie (Romania) - Member
* We are sorry for that we missed to place the File Password, thanks for understanding.
Thanks.
Reply


Messages In This Thread
Useful Functions v1.0 (MySQL) - by Spookie98 - 28.05.2012, 13:12
Re: Useful Functions v1.0 (MySQL) - by Hoss - 28.05.2012, 13:57
Re: Useful Functions v1.0 (MySQL) - by Shadow_ - 28.05.2012, 14:51
Re: Useful Functions v1.0 (MySQL) - by Calgon - 28.05.2012, 16:15
Re: Useful Functions v1.0 (MySQL) - by Spookie98 - 28.05.2012, 16:39
Re: Useful Functions v1.0 (MySQL) - by Calgon - 28.05.2012, 16:40
Re: Useful Functions v1.0 (MySQL) - by WaLLy.SAMP - 28.05.2012, 16:42
Re: Useful Functions v1.0 (MySQL) - by The__ - 28.05.2012, 16:45
Re: Useful Functions v1.0 (MySQL) - by Spookie98 - 28.05.2012, 16:47
Re: Useful Functions v1.0 (MySQL) - by Calgon - 29.05.2012, 08:13
Re: Useful Functions v1.0 (MySQL) - by Spookie98 - 29.05.2012, 10:06
Re: Useful Functions v1.0 (MySQL) - by Edvin - 29.05.2012, 11:04
Re: Useful Functions v1.0 (MySQL) - by Spookie98 - 29.05.2012, 11:53
Re: Useful Functions v1.0 (MySQL) - by Spookie98 - 04.06.2012, 09:50
Re: Useful Functions v1.0 (MySQL) - by Slice - 04.06.2012, 09:58
Re: Useful Functions v1.0 (MySQL) - by TheLazySloth - 04.06.2012, 11:35
Re: Useful Functions v1.0 (MySQL) - by Spookie98 - 04.06.2012, 11:40
Re: Useful Functions v1.0 (MySQL) - by Slice - 04.06.2012, 12:08
Re: Useful Functions v1.0 (MySQL) - by Spookie98 - 04.06.2012, 12:16
Re: Useful Functions v1.0 (MySQL) - by Slice - 04.06.2012, 12:20
Re: Useful Functions v1.0 (MySQL) - by Spookie98 - 04.06.2012, 12:30
Re: Useful Functions v1.0 (MySQL) - by Spookie98 - 04.06.2012, 12:35

Forum Jump:


Users browsing this thread: 2 Guest(s)