Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- #include <sscanf2>
- #include <streamer>
- #define name_modifications "« Role Play 0.3.7 »"
- #define name_servers "f0Re3t Role Play"
- #define maximum_flood_kick 5
- #define publics:%0(%1) forward %0(%1); public %0(%1)
- #define mysql_hostname "localhost"
- #define mysql_username "root"
- #define mysql_database "f0Re3t"
- #define mysql_password ""
- #define table_users "users"
- #include "../library/color.library"
- #include "../library/variables.library"
- enum
- {
- dialogue_registration,
- dialogue_authorization,
- dialogue_email,
- dialogue_gender
- }
- main() { }
- public OnGameModeInit()
- {
- connection = mysql_connect(mysql_hostname, mysql_username, mysql_database, mysql_password);
- SetGameModeText(""name_modifications"");
- AddPlayerClass(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- DisableInteriorEnterExits();
- EnableStuntBonusForAll(false);
- LimitPlayerMarkerRadius(30.0);
- ManualVehicleEngineAndLights();
- SetTimer("SAPI", 1000, true);
- return true;
- }
- public OnGameModeExit()
- {
- mysql_close(connection);
- return true;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- if(temporary[playerid][authorization] == true) return SpawnPlayer(playerid);
- new ORM:key = player[playerid][user_data] = orm_create(table_users);
- orm_addvar_int(key, player[playerid][user_number], "user_number");
- orm_addvar_string(key, player[playerid][user_name], MAX_PLAYER_NAME, "user_name");
- orm_addvar_string(key, player[playerid][user_password], 65, "user_password");
- orm_addvar_string(key, player[playerid][user_email], 130, "user_email");
- orm_addvar_string(key, player[playerid][user_address], 16, "user_address");
- orm_addvar_string(key, player[playerid][user_last_address], 16, "user_last_address");
- orm_addvar_int(key, player[playerid][user_gender], "user_gender");
- orm_addvar_int(key, player[playerid][user_clothing], "user_clothing");
- orm_addvar_int(key, player[playerid][user_money], "user_money");
- orm_addvar_int(key, player[playerid][user_level], "user_level");
- orm_setkey(key, "user_name");
- orm_select(key, "registration", "d", playerid);
- return true;
- }
- public OnPlayerConnect(playerid)
- {
- GetPlayerName(playerid, player[playerid][user_name], MAX_PLAYER_NAME);
- reset_variables(playerid);
- return true;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(temporary[playerid][authorization] == true) orm_update(player[playerid][user_data]), orm_destroy(player[playerid][user_data]);
- return true;
- }
- public OnPlayerSpawn(playerid)
- {
- if(temporary[playerid][authorization] == false) return Kick(playerid);
- spawn_player_function(playerid);
- return true;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return true;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return true;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return true;
- }
- public OnPlayerText(playerid, text[])
- {
- if(temporary[playerid][authorization] == false || temporary[playerid][flood] > gettime())
- {
- temporary[playerid][flood_kick] ++;
- return false;
- }
- if(temporary[playerid][flood_kick] >= maximum_flood_kick) return Kick(playerid);
- temporary[playerid][flood] = gettime() + 1;
- format(strings, sizeof(strings), "- %s (%s) [%d]", text, player[playerid][user_name], playerid);
- send_radius_message(playerid, strings, 10.0, 0xD3D3D3FF);
- return false;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return true;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return true;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return true;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return true;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return true;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return true;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return true;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return true;
- }
- public OnRconCommand(cmd[])
- {
- return true;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- if(temporary[playerid][authorization] == false) return Kick(playerid);
- return true;
- }
- public OnObjectMoved(objectid)
- {
- return true;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return true;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return true;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return true;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return true;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return true;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return true;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return true;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return true;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return true;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return true;
- }
- public OnPlayerUpdate(playerid)
- {
- return true;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return true;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return true;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return true;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return true;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case dialogue_authorization:
- {
- if(!response) return Kick(playerid);
- if(!strlen(inputtext))
- {
- format(strings, sizeof(strings), "Добро пожаловать на сервер "name_servers"\nВаш персонаж найден в базе данных\n\nИмя персонажа: %s\nВведите ваш игровой пароль:", player[playerid][user_name]);
- ShowPlayerDialog(playerid, dialogue_authorization, DIALOG_STYLE_PASSWORD, "Авторизация", strings, "Войти", "Отмена");
- return true;
- }
- new password_hash[65];
- SHA256_PassHash(inputtext, "3b?jKqe>9qr1WqUCd.B?]N!>!joa>at8", password_hash, 65);
- if(!strcmp(password_hash, player[playerid][user_password], false, 65)) user_authorization(playerid);
- else
- {
- if(temporary[playerid][wrong_password] == 2) return Kick(playerid);
- temporary[playerid][wrong_password] ++;
- format(strings, sizeof(strings), "Добро пожаловать на сервер "name_servers"\nВаш персонаж найден в базе данных\n\nИмя персонажа: %s\nВведите ваш игровой пароль:", player[playerid][user_name]);
- ShowPlayerDialog(playerid, dialogue_authorization, DIALOG_STYLE_PASSWORD, "Авторизация", strings, "Войти", "Отмена");
- }
- }
- case dialogue_registration:
- {
- if(!response) return Kick(playerid);
- if(!strlen(inputtext) || strlen(inputtext) < 6 || strlen(inputtext) > 16)
- {
- format(strings, sizeof(strings), "Добро пожаловать на сервер "name_servers"\nВаш персонаж не найден в базе данных\n\nИмя персонажа: %s\nВведите ваш будущий пароль:", player[playerid][user_name]);
- ShowPlayerDialog(playerid, dialogue_registration, DIALOG_STYLE_INPUT, "Регистрация", strings, "Дальше", "Отмена");
- return true;
- }
- SHA256_PassHash(inputtext, "3b?jKqe>9qr1WqUCd.B?]N!>!joa>at8", player[playerid][user_password], 65);
- ShowPlayerDialog(playerid, dialogue_email, DIALOG_STYLE_INPUT, "Регистрация", "Введите действующий адрес электронной почты", "Дальше", "Отмена");
- }
- case dialogue_email:
- {
- if(!response) return Kick(playerid);
- if(!strlen(inputtext) || strlen(inputtext) > 129) return ShowPlayerDialog(playerid, dialogue_email, DIALOG_STYLE_INPUT, "Регистрация", "Введите действующий адрес электронной почты", "Дальше", "Отмена");
- strins(player[playerid][user_email], inputtext, 0);
- ShowPlayerDialog(playerid, dialogue_gender, DIALOG_STYLE_MSGBOX, "Регистрация", "Выберите пол своего персонажа", "Мужчина", "Женщина");
- }
- case dialogue_gender:
- {
- switch(response)
- {
- case 0: player[playerid][user_gender] = 2;
- case 1: player[playerid][user_gender] = 1;
- }
- user_registration(playerid);
- }
- }
- return true;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return true;
- }
- publics: registration(playerid)
- {
- switch(orm_errno(player[playerid][user_data]))
- {
- case ERROR_OK:
- {
- format(strings, sizeof(strings), "Добро пожаловать на сервер "name_servers"\nВаш персонаж найден в базе данных\n\nИмя персонажа: %s\nВведите ваш игровой пароль:", player[playerid][user_name]);
- ShowPlayerDialog(playerid, dialogue_authorization, DIALOG_STYLE_PASSWORD, "Авторизация", strings, "Войти", "Отмена");
- temporary[playerid][timer] = SetTimerEx("time_authorization", 30000, false, "d", playerid);
- }
- case ERROR_NO_DATA:
- {
- format(strings, sizeof(strings), "Добро пожаловать на сервер "name_servers"\nВаш персонаж не найден в базе данных\n\nИмя персонажа: %s\nВведите ваш будущий пароль:", player[playerid][user_name]);
- ShowPlayerDialog(playerid, dialogue_registration, DIALOG_STYLE_INPUT, "Регистрация", strings, "Дальше", "Отмена");
- }
- }
- orm_setkey(player[playerid][user_data], "user_number");
- return true;
- }
- publics: time_authorization(playerid)
- {
- switch(temporary[playerid][authorization])
- {
- case true: KillTimer(temporary[playerid][timer]);
- case false: Kick(playerid);
- }
- return true;
- }
- publics: SAPI()
- {
- for(new cycle = 0; cycle <= GetPlayerPoolSize(); cycle ++)
- {
- SAPI_money(cycle);
- if(temporary[cycle][flood_kick] > 0) temporary[cycle][flood_kick] --;
- }
- return true;
- }
- stock SAPI_money(playerid)
- {
- if(GetPlayerMoney(playerid) != player[playerid][user_money]) ResetPlayerMoney(playerid), GivePlayerMoney(playerid, player[playerid][user_money]);
- return true;
- }
- stock reset_variables(playerid)
- {
- player[playerid][user_number] = 0;
- player[playerid][user_gender] = 0;
- player[playerid][user_clothing] = 0;
- player[playerid][user_money] = 0;
- player[playerid][user_level] = 0;
- temporary[playerid][authorization] = false;
- temporary[playerid][flood] = 0;
- temporary[playerid][flood_kick] = 0;
- temporary[playerid][wrong_password] = 0;
- return true;
- }
- stock user_authorization(playerid)
- {
- temporary[playerid][authorization] = true;
- SpawnPlayer(playerid);
- return true;
- }
- stock user_registration(playerid)
- {
- new address[16];
- GetPlayerIp(playerid, address, sizeof(address));
- strins(player[playerid][user_address], address, 0);
- strins(player[playerid][user_last_address], address, 0);
- temporary[playerid][authorization] = true;
- switch(player[playerid][user_gender])
- {
- case 1: player[playerid][user_clothing] = clothing_man[random(sizeof(clothing_man))];
- case 2: player[playerid][user_clothing] = clothing_woman[random(sizeof(clothing_woman))];
- }
- player[playerid][user_level] = 1;
- player[playerid][user_money] = 1000;
- SpawnPlayer(playerid);
- orm_insert(player[playerid][user_data], "", "");
- return true;
- }
- stock spawn_player_function(playerid)
- {
- SetPlayerSkin(playerid, player[playerid][user_clothing]);
- SetPlayerScore(playerid, player[playerid][user_level]);
- SetPlayerColor(playerid, 0xFFFFFF30);
- SetPlayerPos(playerid, 1154.3717, -1769.2594, 16.5938);
- SetPlayerFacingAngle(playerid, 0.6853);
- SetCameraBehindPlayer(playerid);
- SetPlayerVirtualWorld(playerid, 0);
- SetPlayerInterior(playerid, 0);
- return true;
- }
- stock send_radius_message(playerid, string[], Float: radius, color)
- {
- new Float: position[3];
- GetPlayerPos(playerid, position[0], position[1], position[2]);
- for(new cycle = 0; cycle <= GetPlayerPoolSize(); cycle ++)
- {
- if(!IsPlayerConnected(cycle) || temporary[cycle][authorization] == false || GetPlayerVirtualWorld(playerid) != GetPlayerVirtualWorld(cycle) || GetPlayerInterior(playerid) != GetPlayerInterior(cycle) || GetPlayerDistanceFromPoint(cycle, position[0], position[1], position[2]) > radius) continue;
- SendClientMessage(cycle, color, string);
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement