01.08.2010, 18:34
(
Последний раз редактировалось Carlton; 08.08.2010 в 10:22.
)
Information
Hi, i've been thinking about scripting this for the last few weeks, and finally had time to do so. This is pretty much, dini in MySQL. This is easy to use as long as you understand the parameters and have basic knowledge of creating and setting up a MySQL database.
Compatibility
This can be use with G-StyleZzZ's (C-MySQL.inc) and StrickenKid's (C-MySQL-S.inc) MySQL plugin.
These two plugins can be found at the plugin board. Direct links are below:
https://sampforum.blast.hk/showthread.php?tid=122983
https://sampforum.blast.hk/showthread.php?tid=56564
Example Script - Account System
http://forum.sa-mp.com/showthread.ph...127#post783127
Example Script (StrickenKid's plugin)
The example script comes with the download, but you can view it below:
Why use this?
- Speed.
I'm pretty sure scripters would rather use made functions instead of writing a whole query, and doing all the necessary work.
- Easy
The script is very easy to use, so it shouldn't be a huge problem.
- Password
The passwords, are encrypted, so, don't worry about that security.
Functions (List)
Functions (Explanation)
CMySQL_Create(Username[], Table[], Field[]);
Username - The account username.
Table - The table that stores the account.
Field - The field name you'd like to store the username inside. (Ex:
).
MySQL_Delete(Username[], Table[], Field[]);
Username - The account username.
Table - The table that stores the account.
Field - The field name you'd like to get the username from, so it doesn't delete a invalid field.
CMySQL_SetInt(Username[], Table[], Field[], FieldValue[], Value);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to change.
Value - The value of the field (integer).
( Check the example for information how to use this, and other similar functions! ).
CMySQL_Set(Username[], Table[], Field[], FieldValue[], Value[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to change.
Value - The value of the field (string).
CMySQL_Int(Username[], Table[], Field[], FieldValue[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to get the value from (integer).
- Returns the value of the field (integer).
CMySQL_Get(Username[], Table[], Field[], FieldValue[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to get the value from (string).
- Returns the value of the field (string).
CMySQL_SetFloat(Username[], Table[], Field[], FieldValue[], Float:Value);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to set the value to (Float).
Value - The value of the field you'd like to set.
CMySQL_Float(Username[], Table[], Field[], FieldValue[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to get the value from (float).
- Returns the value of the field (float).
CMySQL_Password(Username[], Table[], Field[], Value[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
Value- The value you'd like to set the field to.
- Stores in MD5
CMySQL_GetPassword(Username[], Table[], Field[], Value[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
Value- The value you'd like to get the password from.
- Receives from MD5
CMySQL_SetUserName(name[], AccountTable[], UserFieldName[], Value[]));
name- The account username (the current one, without changed).
AccountTable- The table that stores the account.
UserFieldName- The name storing field name, so it doesn't confuse for a invalid field.
Value- The new name you'd like to set.
CMySQL_SetBool(Username[], Table[], Field[], FieldValue[], bool:Value);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to change.
Value - The value of the field (bool).
CMySQL_LoadAccount(Username[], Table[], Field[], ThreadID, extraid);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
ThreadID- The thread ID.
extraid - The extraid parameter for the thread callback.
Bugs
None found yet.
Thanks to
BlueG - Plugin.
Strickenkid - Plugin.
Download
C-MySQL 0.0
C-MySQL 0.1
C-MySQL 0.2
Hi, i've been thinking about scripting this for the last few weeks, and finally had time to do so. This is pretty much, dini in MySQL. This is easy to use as long as you understand the parameters and have basic knowledge of creating and setting up a MySQL database.
Compatibility
This can be use with G-StyleZzZ's (C-MySQL.inc) and StrickenKid's (C-MySQL-S.inc) MySQL plugin.
These two plugins can be found at the plugin board. Direct links are below:
https://sampforum.blast.hk/showthread.php?tid=122983
https://sampforum.blast.hk/showthread.php?tid=56564
Example Script - Account System
http://forum.sa-mp.com/showthread.ph...127#post783127
Example Script (StrickenKid's plugin)
The example script comes with the download, but you can view it below:
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <C-MySQL-S>
#define MySQL_HOST ""
#define MySQL_USER ""
#define MySQL_DB ""
#define MySQL_PASSWORD ""
#define ACCOUNT_TABLE ""
public OnGameModeInit() {
mysql_connect(MySQL_HOST, MySQL_USER, MySQL_PASSWORD, MySQL_DB, 1);
}
CMD:Register(playerid, params[]) {
new
Password[55],
string[138];
if(sscanf(params, "z[55]", Password)) return SendClientMessage(playerid, 0xFFFFFFF, "<> /register <password>");
GetPlayerName(playerid, string, 24);
format(string, 138, "SELECT * FROM %s WHERE Username = '%s'", ACCOUNT_TABLE, string);
mysql_query(string);
mysql_store_result();
if(mysql_num_rows() >= 1) {
SendClientMessage(playerid, 0xFFFFFFF, "<> You already have a account!");
mysql_free_result();
return 1;
}
mysql_free_result();
GetPlayerName(playerid, string, 24);
CMySQL_Create(string, ACCOUNT_TABLE, "Username");
CMySQL_Password(string, ACCOUNT_TABLE, "Password", Password);
CMySQL_SetInt(string, ACCOUNT_TABLE, "Username", "Money", 5000);
return 1;
}
CMD:Login(playerid, params[]) {
new
Password[55],
string[138];
if(sscanf(params, "z[55]", Password)) return SendClientMessage(playerid, 0xFFFFFFF, "<> /login <password>");
if(GetPVarInt(playerid, "Logged") == 1) return SendClientMessage(playerid, 0xFFFFFFF, "<> You're logged already");
GetPlayerName(playerid, string, 24);
if(!CMySQL_GetPassword(string, ACCOUNT_TABLE, "Password", Password)) return SendClientMessage(playerid, 0xFFFFFFF, "<> Invalid Password.");
GivePlayerMoney(playerid, CMySQL_Int(string, ACCOUNT_TABLE, "Username", "Money"));
SetPVarInt(playerid, "Logged", 1);
return 1;
}
- Speed.
I'm pretty sure scripters would rather use made functions instead of writing a whole query, and doing all the necessary work.
- Easy
The script is very easy to use, so it shouldn't be a huge problem.
- Password
The passwords, are encrypted, so, don't worry about that security.
Functions (List)
pawn Код:
native CMySQL_Create(Username[], Table[], Field[]);
native CMySQL_Delete(Username[], Table[], Field[]);
native CMySQL_SetInt(Username[], Table[], Field[], FieldValue[], Value);
native CMySQL_Set(Username[], Table[], Field[], FieldValue[], Value[]);
native CMySQL_Int(Username[], Table[], Field[], FieldValue[]);
native CMySQL_Get(Username[], Table[], Field[], FieldValue[]);
native CMySQL_SetFloat(Username[], Table[], Field[], FieldValue[], Float:Value);
native CMySQL_Float(Username[], Table[], Field[], FieldValue[]);
native CMySQL_Password(Username[], Table[], Field[], Value[]);
native CMySQL_GetPassword(Username[], Table[], Field[], Value[]);
native CMySQL_SetUserName(name[], AccountTable[], UserFieldName[], Value[]);
native CMySQL_SetBool(Username[], Table[], Field[], FieldValue[], bool:Value);
native CMySQL_LoadAccount(Username[], Table[], Field[], ThreadID, extraid);
CMySQL_Create(Username[], Table[], Field[]);
Username - The account username.
Table - The table that stores the account.
Field - The field name you'd like to store the username inside. (Ex:
PHP код:
CMySQL_Create(GetPlayerNameEx(playerid), "Accounts", "PUserName");
MySQL_Delete(Username[], Table[], Field[]);
Username - The account username.
Table - The table that stores the account.
Field - The field name you'd like to get the username from, so it doesn't delete a invalid field.
CMySQL_SetInt(Username[], Table[], Field[], FieldValue[], Value);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to change.
Value - The value of the field (integer).
( Check the example for information how to use this, and other similar functions! ).
CMySQL_Set(Username[], Table[], Field[], FieldValue[], Value[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to change.
Value - The value of the field (string).
CMySQL_Int(Username[], Table[], Field[], FieldValue[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to get the value from (integer).
- Returns the value of the field (integer).
CMySQL_Get(Username[], Table[], Field[], FieldValue[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to get the value from (string).
- Returns the value of the field (string).
CMySQL_SetFloat(Username[], Table[], Field[], FieldValue[], Float:Value);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to set the value to (Float).
Value - The value of the field you'd like to set.
CMySQL_Float(Username[], Table[], Field[], FieldValue[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to get the value from (float).
- Returns the value of the field (float).
CMySQL_Password(Username[], Table[], Field[], Value[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
Value- The value you'd like to set the field to.
- Stores in MD5
CMySQL_GetPassword(Username[], Table[], Field[], Value[]);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
Value- The value you'd like to get the password from.
- Receives from MD5
CMySQL_SetUserName(name[], AccountTable[], UserFieldName[], Value[]));
name- The account username (the current one, without changed).
AccountTable- The table that stores the account.
UserFieldName- The name storing field name, so it doesn't confuse for a invalid field.
Value- The new name you'd like to set.
CMySQL_SetBool(Username[], Table[], Field[], FieldValue[], bool:Value);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
FieldValue - The field you'd like to change.
Value - The value of the field (bool).
CMySQL_LoadAccount(Username[], Table[], Field[], ThreadID, extraid);
Username - The account username.
Table - The table that stores the account.
Field - The name storing field name, so it doesn't confuse for a invalid field.
ThreadID- The thread ID.
extraid - The extraid parameter for the thread callback.
Bugs
None found yet.
Thanks to
BlueG - Plugin.
Strickenkid - Plugin.
Download
C-MySQL 0.0
C-MySQL 0.1
C-MySQL 0.2