Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Includes & Plugins:
- I-ZCMD 0.2.3.0: http://forum.sa-mp.com/showthread.php?t=576114
- MySQL R39-6: http://forum.sa-mp.com/showthread.php?t=56564 | https://github.com/pBlueG/SA-MP-MySQL/releases/tag/R39-6
- Streamer 2.9.0: http://forum.sa-mp.com/showthread.php?t=102865
- Foreach: http://forum.sa-mp.com/showthread.php?t=570868
- sscanf 2.8.2: http://forum.sa-mp.com/showthread.php?t=570927
- All work completed in this script was with the help of iGetty:
- http://forum.sa-mp.com/member.php?u=105293
- https://www.youtube.com/channel/UCBWCX6AxNL7-O3xuvSKaG-A
- This is the work of XXXXXXXXX, for the roleplay script.
- */
- #include <a_samp>
- #include <izcmd>
- #include <a_mysql>
- #include <streamer>
- #include <foreach>
- #include <sscanf2>
- #include "../gamemodes/modules/defines.pwn"
- #include "../gamemodes/modules/vars.pwn"
- #include "../gamemodes/modules/publics.pwn"
- #include "../gamemodes/modules/commands/generalcommands.pwn"
- main(){}
- public OnGameModeInit()
- {
- mysql_log(LOG_ERROR | LOG_WARNING, LOG_TYPE_HTML);
- sqlConnection = mysql_connect(SQL_HOST, SQL_USER, SQL_DATABASE, SQL_PASSWORD);
- OneSecondTimer = SetTimer("TIMER_OneSecondTimer", 999, true);
- return true;
- }
- public OnGameModeExit()
- {
- KillTimer(OneSecondTimer);
- mysql_close(sqlConnection);
- return true;
- }
- public OnPlayerConnect(playerid)
- {
- DoesPlayerExist(playerid);
- return true;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerPos(playerid, pInfo[playerid][pLastPos][0], pInfo[playerid][pLastPos][1], pInfo[playerid][pLastPos][2]);
- SetPlayerFacingAngle(playerid, pInfo[playerid][pLastPos][3]);
- return true;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- LoadDefaultValues(playerid);
- return true;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return true;
- }
- public OnPlayerUpdate(playerid)
- {
- if(GetPlayerMoney(playerid) != pInfo[playerid][pMoney]){
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
- }
- return true;
- }
- public OnPlayerText(playerid, text[])
- {
- if(!LoggedIn[playerid])return true;
- new string[128];
- format(string, sizeof(string), "%s: %s", RPName(playerid), text);
- SendLocalMessage(playerid, COLOR_WHITE, string);
- return false;
- }
- // Stocks and other functions
- /*GetIP(playerid) {
- new ip[20];
- GetPlayerIp(playerid, ip, sizeof(ip));
- return ip;
- }*/
- GetName(playerid) {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- stock strmatch(const String1[], const String2[])
- {
- if((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- // ------------------------------------
- /*---------------- Dialogs ---------------------*/
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid) {
- case DIALOG_REGISTER:
- {
- if(!response)return Kick(playerid); // kick the player if they do not respond
- // Check if entered password is less than 3 and more than 30.
- if(strlen(inputtext) < 3 || strlen(inputtext) > 30) {
- ShowRegisterDialog(playerid, "Please ensure your password is more than 2 characters and below 30 characters.");
- return true;
- }
- // Add the player to the database.
- new query[128];
- mysql_format(sqlConnection, query, sizeof(query), "INSERT INTO users (Name, Password) VALUES ('%e', sha1('%e'))", GetName(playerid), inputtext);
- mysql_pquery(sqlConnection, query, "SQL_AccountRegistered", "i", playerid);
- }
- case DIALOG_LOGIN:
- {
- if(!response)return Kick(playerid);// kick the player if they do not respond
- // Check if entered password is less than 3 and more than 30.
- if(strlen(inputtext) < 3 || strlen(inputtext) > 30) {
- ShowLoginDialog(playerid, "Please ensure your password is more than 2 characters and below 30 characters.");
- return true;
- }
- // Login the player.
- new query[128];
- mysql_format(sqlConnection, query, sizeof(query), "SELECT id FROM users WHERE Name = '%e' AND Password = sha1('%e') LIMIT 1", GetName(playerid), inputtext);
- mysql_pquery(sqlConnection, query, "SQL_AccountLogin", "i", playerid);
- }
- }
- return false;
- }
- // ----------------------------- functions -------------------------------------
- RPName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- for(new i = 0; i < strlen(name); i++) {
- if(name[i] == '_'){
- name[i] = ' ';
- }
- }
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement