Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TDM
- #include <a_samp>
- #include <Dini>
- #include <dudb>
- #include <Zcmd>
- #include <gvar>
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- /*______________________________________________________________________________ Color defines */
- #define color_white 0xFFFFFFAA
- #define color_green 0x00FF66AA
- #define color_admin 0x666699AA
- #define color_red 0xFF0000AA
- #define color_yellow 0xFFFF00AA
- #define color_blue 0x0066FFAA
- #define color_grey 0x999999AA
- #define color_orange 0xFF6600AA
- #define color_lightblue 0xB0C4DEAA
- #define color_purple 0x9370DBAA
- #define admin_duty 0x5F9EA0AA
- #define color_radio 0xFFFFCCAA
- #define color_pink 0x9900CCAA
- /*____________________________________________________________________________*/
- new logged[MAX_PLAYERS];
- enum pInfo
- {
- pAdmin, // Saves the players admin level
- pMoney, // Saves the player money
- pScore, // Saves the player score
- pSkin, // Saves the player skins
- pTeam // Saves the player team
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- public OnGameModeInit()
- {
- SetGameModeText("Akai's TDM");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- TogglePlayerSpectating(playerid, 1);
- new string[128];
- new name[MAX_PLAYER_NAME];
- new file[128];
- GetPlayerName(playerid, name, sizeof(name));
- format(file,sizeof(file),"/Users/%s.ini",name);
- if(!fexist(file))
- {
- format(string, 128, "You joined the server with name: ''%s''", name);
- SendClientMessage(playerid, color_white, string);
- SendClientMessage(playerid, color_white, "Hint: Account is not registered.");
- SendClientMessage(playerid, color_yellow,"Use /register 'password' to proceed.");
- logged[playerid] = 0;
- }
- if(fexist(file))
- {
- SendClientMessage(playerid, color_white, "Hint: Account already registered.");
- SendClientMessage(playerid, color_yellow, "Use /login 'password' to proceed.");
- }
- return 1;
- }
- COMMAND:register(playerid, params[])
- {
- new string[128];
- new file[128], pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(file, sizeof(file), "/Accounts/%s.ini", pname);
- //------------------------------------------------------------------------------
- if(!strlen(params)) return SendClientMessage(playerid, color_white, "[System]: /register 'password'");
- if(dini_Exists(file)) return SendClientMessage(playerid, color_white, "[System]: You are already registered!");
- dini_Create(file);
- dini_IntSet(file, "hashPW", udb_hash(params));
- dini_Set(file, "password", params);
- dini_IntSet(file, "pAdmin", 0);
- dini_IntSet(file, "pMoney", 0);
- dini_IntSet(file, "pScore", 0);
- dini_IntSet(file, "pSkin", 127);
- dini_IntSet(file, "pTeam", 0);
- format(string, 128, "[SYSTEM]: You succesfully registered the account %s with password %s. You can now use /login 'password'", pname, params);
- SendClientMessage(playerid, color_white, string);
- printf("[User Registered] Username: %s || Password: %s", pname, params); // For debugging purposes
- return 1;
- }
- COMMAND:login(playerid, params[])
- {
- new file[128];
- new joinmsg[128];
- new string[MAX_STRING], pname[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(file, sizeof(file), "/Accounts/%s.ini", pname);
- //------------------------------------------------------------------------------
- if(!strlen(params)) return SendClientMessage(playerid, color_white, "[SYSTEM]: /login [password]");
- if(!dini_Exists(file)) return SendClientMessage(playerid, color_white, "[SYSTEM]: You are not registered!");
- if(logged[playerid]) return SendClientMessage(playerid, color_white, "[SYSTEM]: You are already logged in!");
- new tmp;
- tmp = dini_Int(file, "hashPW");
- //------------------------------------------------------------------------------
- if(udb_hash(params) != tmp)
- {
- format(string, 256, "[System]: You typed the wrong password for account: %s.", pname);
- SendClientMessage(playerid, color_white, string);
- }
- else
- {
- TogglePlayerSpectating(playerid, 0);
- PlayerInfo[playerid][pAdmin] = dini_Int(file, "pAdmin");
- SetPlayerScore(playerid, dini_Int(file, "pScore"));
- SetPlayerMoney(playerid, dini_Int(file, "pMoney"));
- SetPlayerSkin(playerid, dini_Int(file, "pSkin"));
- SetGVarInt("TEAM", dini_Int(file, "pTeam"), playerid);
- format(string, sizeof(string), "Welcome back %s!", pname);
- SendClientMessage(playerid, color_green, string);
- SendClientMessage(playerid, color_yellow, "Feel free to use /report or /helpme if you got questions. (Hint: read /help)");
- format(string, sizeof(string), "~y~Welcome back ~g~%s", pname);
- GameTextForPlayer(playerid, string, 5000, 5);
- printf("[User Logged in] Username: %s || Given Playerid: %i || Password: %s", pname, playerid, params); // For debugging purposes
- PlayerPlaySound(playerid,1058,0.0,0.0,0.0);
- PlayerPlaySound(playerid, 1186, 0.0, 0.0, 0.0);
- format(joinmsg, sizeof(joinmsg), "[Connected]: %s connected and logged in.", pname);
- SendAdminMessage(color_green, joinmsg);
- }
- return 1;
- }
- //==============================================================================
- //==============================================================================
- //==============================================================================
- stock SendAdminMessage(color, msg[])
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(PlayerInfo[i][pAdmin] > 1)
- {
- SendClientMessage(i, color, msg);
- }
- }
- return 1;
- }
- //==============================================================================
- //==============================================================================
- //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement