Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined filterscript
- -=-=-=-=-=-=-=-=-=-=-=..::" [s74] Registration System"::..-=-==-=-=-=-=-=-=-=-=-
- /*
- CREATOR:
- • RastaOrecha ( JM_Millers)
- > Facebook: http://www.facebook.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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement