28.05.2012, 13:12
(
Последний раз редактировалось Spookie98; 08.06.2012 в 18:07.
)
Useful Functions v1.0
Based on MySQL
IntroductionBased on MySQL
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.
- 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.
1. Place it to the top of the script:
pawn Код:
#include <useful_functions>
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
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;
}
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
Thanks.