#if defined filterscript
-=-=-=-=-=-=-=-=-=-=-=..::" [s74] Registration System"::..-=-==-=-=-=-=-=-=-=-=-
/*
CREATOR:
• RastaOrecha ( JM_Millers)
> Facebook: http://w...content-available-to-author-only...k.com/sweed74
&&
• FanHamMer
> Skype: fanhammer
RUSSIAN MADAFAKA SCRIPTER COMMUNITI EBAT LOPATOI ANAL SEX VODKA DUDKA BALALAIKA
______________________________
*/
" _¶____________________._ "
" /________\\___/___________|] "
" /__==O__________________/ "
" ), ---.(_\\(_) /; "
" //_¤_)/ "
" //_¤_// "
" //_¤_// "
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#endif
/*CREATE TABLE `SREG`.`users` (
`Name` VARCHAR( 24 ) NOT NULL ,
`Key` VARCHAR( 16 ) NOT NULL ,
`Money` INT( 10 ) NOT NULL ,
`Admin` INT( 3 ) NOT NULL ,
`Skin` INT( 3 ) NOT NULL
) ENGINE = MYISAM ;*/
// s74`Registration System by RastaOrecha
#tryinclude a_samp
#tryinclude a_mysql
#file "s74`Registration"
#undef MAX_PLAYERS
#define MAX_PLAYERS (50) // !!! MAX_PLAYERS
#assert MAX_PLAYERS >(0)
////////////////////////////////////////////////////////////////////////////////
#define VECTOR (0) // Change to 1 to use loop optimization players
#if VECTOR == 1
#tryinclude Vectoral
static players;
#define foreach(%0) for(new %0, d, x = cvector_g_size(players); d != x; %0 &= 0, %0 += cvector_g_get(players, d++))
#endif
////////////////////////////////////////////////////////////////////////////////
#define SPAWN_X (0.0)
#define SPAWN_Y (0.0)
#define SPAWN_Z (7.0)
#define SPAWN_A (90.0)
#define SQL_HOST "localhost"
#define SQL_USER "root"
#define SQL_DB "SREG" //DataBase
#define SQL_PASS ""
#define SQL_TABLE "users" //
#define SQL_DEBUG (0)
#define @ERR "[ERROR]"
#define @OK "[OK]"
#define col:: col_
#define VERSION (1)
#define d_none (0)
#define d_reg (1)
#define d_log (2)
#define col_lbl "{7DAEFF}"
#define col_gld "{FFD700}"
//MACRO
#define GN(%0) pInfo[%0][Name]
enum InfoPlayers{Name[24]};
static
handle,
pInfo[MAX_PLAYERS][InfoPlayers]
;
public OnFilterScriptInit()
{
print("\n--------------------------------------"), \
printf("s74`Register_System" # ...v1... "started"), \
print("--------------------------------------\n");
handle = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
if mysql_ping()== 1 *then
printf("MySQL " #@OK);
else
printf("MySQL " #@ERR);
#if VECTOR == 1
players = cvector_g();
#endif
return true;
}
public OnFilterScriptExit()
{
#if VECTOR == 1
foreach(i)
{
SaveAccount(i);
}
cvector_g_clear(players);
#else
for(new i = GetMaxPlayers()-1; i != -1; --i)
{
SaveAccount(i);
}
#endif
mysql_close(handle), \
printf("MySQL" ", close");
return true;
}
public OnPlayerConnect(playerid)
{
#if VECTOR == 1
cvector_g_push_back(players, playerid);
#endif
static query[70];
GetPlayerName(playerid, pInfo[playerid][Name], MAX_PLAYER_NAME), \
format(query,70, "select * from "#SQL_TABLE" where `Name`='%s'", GN(playerid)), \
mysql_function_query(handle, query, true, "RegisterCheck", "d", playerid);
return true;
}
forward RegisterCheck(playerid);
public RegisterCheck(playerid)
{
static rows, fields, str[93];
cache_get_data(rows, fields);
if rows *then
format(str, 91,"Hello %s\n\
Please, enter a password in the fields below to "#col::gld"login", GN(playerid)), \
ShowPlayerDialog(playerid, d_log, DIALOG_STYLE_INPUT, ""#col::gld"Login", str, "Ok", "Cancel");
else
format(str, 93,"Hello %s\n\
Please, enter a password in the fields below to "#col::gld"register", GN(playerid)), \
ShowPlayerDialog(playerid, d_reg, DIALOG_STYLE_INPUT, ""#col::lbl"Registration", str, "Next", "Cancel");
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
#if VECTOR == 1
cvector_g_remove(players, cvector_g_find(players, playerid));
#endif
SaveAccount(playerid);
return true;
}
public OnPlayerSpawn(playerid)
{
return true;
}
public OnPlayerText(playerid, text[])
{
if(GetPVarInt(playerid, "Logged") == 0) return false;
return true;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
static lstr[93];
static query[100];
switch(dialogid)
{
case d_log:
{
if !response *then return Kick(playerid);
if !strlen(inputtext) *then
return format(lstr, 91,"Hello %s\nPlease, enter a password in the fields below to "#col::gld"login", GN(playerid)), \
ShowPlayerDialog(playerid, d_log, DIALOG_STYLE_INPUT, ""#col::gld"Login", lstr, "Ok", "Cancel");
format(query,100,"select * from "SQL_TABLE" where `Name`='%s' and `Key`='%s'", GN(playerid), inputtext), \
mysql_function_query(handle, query, true, "Login", "d", playerid);
}
case d_reg:
{
if !response *then return Kick(playerid);
if strlen(inputtext) < 3 || strlen(inputtext) > 16 *then
return SendClientMessage(playerid, -1, "The password must be at least 3 and no more than 16 characters"), \
format(lstr, 93,"Hello %s\nPlease, enter a password in the fields below to "#col::gld"register", GN(playerid)), \
ShowPlayerDialog(playerid, d_reg, DIALOG_STYLE_INPUT, ""#col::lbl"Registration", lstr, "Next", "Cancel");
format(query, 90, "INSERT INTO "SQL_TABLE" (`Name`,`Key`) VALUES ('%s','%s')", GN(playerid), inputtext), \
mysql_function_query(handle, query, false, "Register", "d", playerid);
}
}
return true;
}
forward Login(playerid);
public Login(playerid)
{
static rows, fields;
cache_get_data(rows, fields);
if rows *then
{
GivePlayerMoney(playerid, cache_get_field_int(0, "Money", handle)), \
SetPVarInt(playerid, "Admin", cache_get_field_int(0, "Admin", handle)), \
SetPVarInt(playerid, "Logged", 1), \
SetSpawnInfo(playerid,-1,cache_get_field_int(0, "Skin", handle), SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A, 0,0, 0,0, 0,0), \
SpawnPlayer(playerid), \
SendClientMessage(playerid, -1, "[»] You have successfully logged in"), \
PlayerPlaySound(playerid, 41603, 0.0, 0.0, 0.0);
}
else
{
if GetPVarInt(playerid, "WrongPassword") > 2 *then return Kick(playerid);
SetPVarInt(playerid, "WrongPassword", GetPVarInt(playerid, "WrongPassword") + 1);
new lstr[78];
format(lstr, 78,"Wrong password (%i/3)\nPlease, enter a password in the fields below to "#col::gld"login", GetPVarInt(playerid, "WrongPassword")), \
ShowPlayerDialog(playerid, d_log, DIALOG_STYLE_INPUT, ""#col::gld"Login", lstr, "Ok", "Cancel"), \
PlayerPlaySound(playerid, 4203, 0.0, 0.0, 0.0);
return true;
}
return true;
}
forward Register(playerid);
public Register(playerid)
{
static rand;
rand = 1 + random(299);
SendClientMessage(playerid, -1, "Welcome to the server, you have successfully registered"), \
SetPlayerSkin(playerid, rand), \
SetPVarInt(playerid, "Logged", 1), \
SetSpawnInfo(playerid,-1,rand, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A, 0,0, 0,0, 0,0), \
SpawnPlayer(playerid), \
PlayerPlaySound(playerid, 21001, 0.0, 0.0, 0.0);
return true;
}
SaveAccount(playerid)
{
if(GetPVarInt(playerid, "Logged") == 1)
{
static query[130];
format(query, 130, "UPDATE "SQL_TABLE" SET `Money`='%d',`Admin`='%d',`Skin`='%d' WHERE `Name`='%s'",
GetPlayerMoney(playerid), GetPVarInt(playerid, "Admin"), GetPlayerSkin(playerid), GN(playerid)), \
mysql_query(query, -1, -1, handle);
}
return true;
}
I2lmIGRlZmluZWQgZmlsdGVyc2NyaXB0Ci09LT0tPS09LT0tPS09LT0tPS09LT0uLjo6IiBbczc0XSBSZWdpc3RyYXRpb24gU3lzdGVtIjo6Li4tPS09PS09LT0tPS09LT0tPS09LT0tCi8qCkNSRUFUT1I6CuKAoiBSYXN0YU9yZWNoYSAoIEpNX01pbGxlcnMpCj4gRmFjZWJvb2s6IGh0dHA6Ly93Li4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5rLmNvbS9zd2VlZDc0CiAgICAJJiYK4oCiIEZhbkhhbU1lcgo+IFNreXBlOiBmYW5oYW1tZXIKClJVU1NJQU4gTUFEQUZBS0EgU0NSSVBURVIgQ09NTVVOSVRJIEVCQVQgTE9QQVRPSSBBTkFMIFNFWCBWT0RLQSBEVURLQSBCQUxBTEFJS0EKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCiovCgoiCQkJIF/Ctl9fX19fX19fX19fX19fX19fX19fLl8gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiCiIJCSAgIC9fX19fX19fX1xcX19fL19fX19fX19fX19ffF0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIgoiCQkgIC9fXz09T19fX19fX19fX19fX19fX19fXy8gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIKIgkgICAgICApLCAtLS0uKF9cXChfKSAvOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiCiIgICAgICAgICAvL1/CpF8pLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIgoiICAgICAgICAvL1/CpF8vLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIKIiAgICAgICAvL1/CpF8vLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiCi09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09CiNlbmRpZgoKLypDUkVBVEUgVEFCTEUgIGBTUkVHYC5gdXNlcnNgICgKYE5hbWVgIFZBUkNIQVIoIDI0ICkgTk9UIE5VTEwgLApgS2V5YCBWQVJDSEFSKCAxNiApIE5PVCBOVUxMICwKYE1vbmV5YCBJTlQoIDEwICkgTk9UIE5VTEwgLApgQWRtaW5gIElOVCggMyApIE5PVCBOVUxMICwKYFNraW5gIElOVCggMyApIE5PVCBOVUxMCikgRU5HSU5FID0gTVlJU0FNIDsqLwoKLy8gczc0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gICAgICAgICAgICAgICg3LjApCiNkZWZpbmUgU1BBV05fQSAgICAgICAgICAgICAgICAgICAgICg5MC4wKQoKI2RlZmluZSBTUUxfSE9TVCAgICAgCQkJCSJsb2NhbGhvc3QiCiNkZWZpbmUgU1FMX1VTRVIgICAgIAkJCQkicm9vdCIKI2RlZmluZSBTUUxfREIgICAgICAgCQkJCSJTUkVHIiAvL0RhdGFCYXNlCiNkZWZpbmUgU1FMX1BBU1MgICAgICAgICAJCQkiIgojZGVmaW5lIFNRTF9UQUJMRSAgICAgICAgICAgICAgICAgICAidXNlcnMiIC8vCiNkZWZpbmUgU1FMX0RFQlVHICAgICAgICAgIAkJCSgwKQoKI2RlZmluZSBARVJSICAgICAgICAgICAgICAgICAgICAgICAgIltFUlJPUl0iCiNkZWZpbmUgQE9LICAgICAgICAgICAgICAgICAgICAgICAgICJbT0tdIgojZGVmaW5lIGNvbDo6ICAgICAgICAgICAgICAJCQljb2xfCgojZGVmaW5lIFZFUlNJT04gICAgICAgICAgICAgICAgICAgICAoMSkKCiNkZWZpbmUgZF9ub25lICAgICAgICAgICAgICAgICAgICAgICgwKQojZGVmaW5lIGRfcmVnICAgICAgICAgICAgICAgICAgICAgICAoMSkKI2RlZmluZSBkX2xvZyAgICAgICAgICAgICAgICAgICAgICAgKDIpCgojZGVmaW5lIGNvbF9sYmwgICAgICAgICAgICAgICAgICAgIAkiezdEQUVGRn0iCiNkZWZpbmUgY29sX2dsZCAgICAgICAgICAgICAgICAgICAgCSJ7RkZENzAwfSIKCi8vTUFDUk8KI2RlZmluZSBHTiglMCkgICAgICAgICAgICAgICAgICAgICAgcEluZm9bJTBdW05hbWVdCgplbnVtIEluZm9QbGF5ZXJze05hbWVbMjRdfTsKCnN0YXRpYwoJICBoYW5kbGUsCgkgIHBJbmZvW01BWF9QTEFZRVJTXVtJbmZvUGxheWVyc10KOwpwdWJsaWMgT25GaWx0ZXJTY3JpcHRJbml0KCkKewoJcHJpbnQoIlxuLS0tLS0tLS0tLS0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