Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -------------------------------
- XDM - Xeiss Deathmatch
- This gamemode was created from scratch by Xeiss.
- -------------------------------
- ---------------------------
- DETAILS:
- Name: XDM
- Version: 1.0
- ---------------------------
- CHANGELOG:
- 1.1:
- Not yet.
- ---------------------------
- THANKS:
- ---------------------------
- -------------------------------
- */
- //--------------------------- INCLUDES ---------------------------
- #include <a_samp>
- #include <sscanf2>
- // YSI
- #define MAX_INI_ENTRY_TEXT 160
- #include <YSI\y_commands>
- #include <YSI\y_ini>
- //--------------------------- DEFINES ---------------------------
- #define GM_VERSION "1.0"
- // YSI
- #define USER_PATH "/XDM/Users/%s.ini"
- #define STARTING_MONEY 5000 // The amount of money a players gets when he creates a new account
- //--------------------------- DIALOGS ---------------------------
- #define DIALOG_MESSAGE 0
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- //--------------------------- COLORS ---------------------------
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x00FF00AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_BLUE 0x0000BBAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_LIME 0x10F441AA
- #define COLOR_MAGENTA 0xFF00FFFF
- #define COLOR_AQUA 0xF0F8FFAA
- #define COLOR_BROWN 0xA52A2AAA
- #define COLOR_GOLD 0xB8860BAA
- #define DIALOG_WHITE "{FFFFFF}"
- #define DIALOG_RED "{F81414}"
- #define DIALOG_GREEN "{00FF22}"
- #define DIALOG_LIGHTBLUE "{00CED1}"
- //--------------------------- NATIVES ---------------------------
- native WP_Hash(buffer[], len, const str[]);
- //--------------------------- ENUMS ---------------------------
- enum PlayerInfo
- {
- pPass[129],
- pCash,
- pBankCash,
- pKills,
- pAdmin,
- bool:pFirstReg
- }
- //--------------------------- VARS ---------------------------
- new fstr[129];
- new buf[129];
- new pInfo[MAX_PLAYERS][PlayerInfo];
- new GetName[MAX_PLAYERS][MAX_PLAYER_NAME];
- //--------------------------- STOCKS ---------------------------
- stock UserPath(playerid) {
- new nstr[128], pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(nstr, sizeof(nstr), USER_PATH, pName);
- return nstr;
- }
- //--------------------------- CUSTOM PUBLICS ---------------------------
- forward LoadUser_data(playerid, name[], value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_String("Password", pInfo[playerid][pPass], 129);
- INI_Int("Cash", pInfo[playerid][pCash]);
- INI_Int("BankCash", pInfo[playerid][pBankCash]);
- INI_Int("Kills", pInfo[playerid][pKills]);
- INI_Int("Admin", pInfo[playerid][pAdmin]);
- return 1;
- }
- forward LoginPlayer(playerid);
- public LoginPlayer(playerid)
- {
- GivePlayerMoney(playerid, pInfo[playerid][pCash]);
- return 1;
- }
- //--------------------------- PUBLICS ---------------------------
- main()
- {
- print("\n----------------------------------------------------");
- print(" [XDM] Xeiss Deathmatch V" GM_VERSION " Successfully loaded.");
- print("----------------------------------------------------\n");
- return 1;
- }
- public OnGameModeInit()
- {
- SetGameModeText("XDM V" GM_VERSION);
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- GetPlayerName(playerid, GetName[playerid], sizeof(GetName));
- pInfo[playerid][pFirstReg] = false;
- if (fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- format(fstr, sizeof(fstr), DIALOG_WHITE"Account "DIALOG_LIGHTBLUE"%s "DIALOG_WHITE"was found!\nPlease type in your password to login:", GetName[playerid]);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, DIALOG_WHITE"Login", fstr,"Login","Quit");
- }
- else
- {
- format(fstr, sizeof(fstr), DIALOG_WHITE"Accout "DIALOG_RED"%s "DIALOG_WHITE"was not found!\nPlease type in a password to create an account:", GetName[playerid]);
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, DIALOG_WHITE"Register", fstr, "Register", "Quit");
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch (dialogid)
- {
- case DIALOG_REGISTER:
- {
- if (!response) return Kick(playerid);
- if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, DIALOG_WHITE"Register", DIALOG_RED"Password can't be blank!\n"DIALOG_WHITE"Please type in a password to create an account:", "Register", "Quit");
- WP_Hash(buf, sizeof(buf), inputtext);
- format(pInfo[playerid][pPass], 129, "%s", buf);
- pInfo[playerid][pCash] = STARTING_MONEY;
- pInfo[playerid][pBankCash] = 0;
- pInfo[playerid][pKills] = 0;
- pInfo[playerid][pAdmin] = 0;
- pInfo[playerid][pFirstReg] = true;
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File, "data");
- INI_WriteString(File, "Password", pInfo[playerid][pPass]);
- INI_WriteInt(File, "Cash", pInfo[playerid][pCash]);
- INI_WriteInt(File, "BankCash", pInfo[playerid][pBankCash]);
- INI_WriteInt(File, "Kills", pInfo[playerid][pKills]);
- INI_WriteInt(File, "Admin", pInfo[playerid][pAdmin]);
- INI_Close(File);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, DIALOG_WHITE"Login", DIALOG_GREEN"You successfully registered!\n"DIALOG_WHITE"Please type in your password to login:", "Login", "Quit");
- }
- case DIALOG_LOGIN:
- {
- if (!response) return Kick(playerid);
- if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, DIALOG_WHITE"Login", DIALOG_RED"Password can't be blank!\n"DIALOG_WHITE"Please type in your password to login:", "Login", "Quit");
- if (strcmp(inputtext, pInfo[playerid][pPass])) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, DIALOG_WHITE"Login", DIALOG_RED"The password you entered is invalid!\n"DIALOG_WHITE"Please type in your password to login:", "Login", "Quit");
- if (pInfo[playerid][pFirstReg] == true)
- {
- LoginPlayer(playerid);
- }
- else
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- LoginPlayer(playerid);
- }
- format(fstr, sizeof(fstr), "Welcome, %s!", GetName[playerid]);
- SendClientMessage(playerid, COLOR_GREEN, fstr);
- return 1;
- }
- }
- return 1;
- }
- //--------------------------- COMMANDS ---------------------------
- YCMD:help(playerid, params[], help)
- {
- if (help) SendClientMessage(playerid, COLOR_GREY, "Displays the gamemode commands");
- if (isnull(params))
- {
- SendClientMessage(playerid, COLOR_LIME, "-------------------- [Help] --------------------");
- SendClientMessage(playerid, COLOR_BROWN, "");
- SendClientMessage(playerid, COLOR_GOLD, "This gamemode was created from scratch by Xeiss");
- SendClientMessage(playerid, COLOR_LIME, "-------------------- [Help] --------------------");
- }
- else
- {
- Command_ReProcess(playerid, params, true);
- }
- return 1;
- }
- // REMOVE LATER
- YCMD:v(playerid, params[], help) {
- if (help) SendClientMessage(playerid, COLOR_GREY, "Spawn a vechile. USAGE: /v [id]");
- new vid, Float:pos[4], vcar;
- if (sscanf(params, "%d", vid)) return 0;
- GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
- GetPlayerFacingAngle(playerid, pos[3]);
- vcar = CreateVehicle(vid, pos[0], pos[1], pos[2], pos[3], 0, 0, -1);
- PutPlayerInVehicle(playerid, vcar, 0);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement