Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- //dini Include by DracoBlue (version 1.6)
- #include <dini>
- /*---------------------------
- 28/6/09
- Login / Register Menu Test
- - Copyright (C) 2009 Zezombia
- Permissions:
- Edit or/and Use
- NOT FOR REDISTRIBUTION
- ---------------------------*/
- //PRESSING Define by Alex "Y_Less" Cole
- #define PRESSING(%0,%1) \
- (((%0) & (%1)) == (%1))
- enum pInfo
- {
- menuing,
- option,
- logged,
- username[16],
- password[16]
- }
- enum sInfo
- {
- Text:box1,
- Text:box2,
- Text:box3,
- Text:box4,
- Text:box5
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new ServerInfo[sInfo];
- main()
- {
- print(" 28/6/09");
- print(" Login / Register Menu Test");
- print(" - Copyright (C) 2009 Zezombia");
- }
- public OnGameModeInit()
- {
- SetGameModeText("Login / Register");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- ServerInfo[box1] = TextDrawCreate(310, 200, "~r~>Login<~n~~w~Register");
- TextDrawUseBox(ServerInfo[box1], 1);
- TextDrawBoxColor(ServerInfo[box1], 0x00000099);
- TextDrawTextSize(ServerInfo[box1], 0.000000, 450.000000);
- TextDrawAlignment(ServerInfo[box1], 2);
- TextDrawFont(ServerInfo[box1], 2);
- TextDrawSetOutline(ServerInfo[box1], 1);
- TextDrawSetShadow(ServerInfo[box1], 0);
- TextDrawLetterSize(ServerInfo[box1], 0.5, 1.75);
- ServerInfo[box2] = TextDrawCreate(310, 236, "~g~Shift: Up - Space: Down - Ctrl: Accept");
- TextDrawUseBox(ServerInfo[box2], 1);
- TextDrawBoxColor(ServerInfo[box2], 0x00000099);
- TextDrawTextSize(ServerInfo[box2], 0.000000, 450.000000);
- TextDrawAlignment(ServerInfo[box2], 2);
- TextDrawFont(ServerInfo[box2], 2);
- TextDrawSetOutline(ServerInfo[box2], 1);
- TextDrawSetShadow(ServerInfo[box2], 0);
- ServerInfo[box3] = TextDrawCreate(310, 194, "~r~>Username:<~n~~w~Password:~n~~w~Login");
- TextDrawUseBox(ServerInfo[box3], 1);
- TextDrawBoxColor(ServerInfo[box3], 0x00000099);
- TextDrawTextSize(ServerInfo[box3], 0.000000, 450.000000);
- TextDrawAlignment(ServerInfo[box3], 2);
- TextDrawFont(ServerInfo[box3], 2);
- TextDrawSetOutline(ServerInfo[box3], 1);
- TextDrawSetShadow(ServerInfo[box3], 0);
- TextDrawLetterSize(ServerInfo[box3], 0.5, 1.75);
- ServerInfo[box4] = TextDrawCreate(310, 246, "~g~Shift: Up - Space: Down - Ctrl: Accept");
- TextDrawUseBox(ServerInfo[box4], 1);
- TextDrawBoxColor(ServerInfo[box4], 0x00000099);
- TextDrawTextSize(ServerInfo[box4], 0.000000, 450.000000);
- TextDrawAlignment(ServerInfo[box4], 2);
- TextDrawFont(ServerInfo[box4], 2);
- TextDrawSetOutline(ServerInfo[box4], 1);
- TextDrawSetShadow(ServerInfo[box4], 0);
- ServerInfo[box5] = TextDrawCreate(310, 194, "~r~>Username:<~n~~w~Password:~n~~w~Register");
- TextDrawUseBox(ServerInfo[box5], 1);
- TextDrawBoxColor(ServerInfo[box5], 0x00000099);
- TextDrawTextSize(ServerInfo[box5], 0.000000, 450.000000);
- TextDrawAlignment(ServerInfo[box5], 2);
- TextDrawFont(ServerInfo[box5], 2);
- TextDrawSetOutline(ServerInfo[box5], 1);
- TextDrawSetShadow(ServerInfo[box5], 0);
- TextDrawLetterSize(ServerInfo[box5], 0.5, 1.75);
- 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)
- {
- PlayerInfo[playerid][menuing] = 0;
- PlayerInfo[playerid][logged] = 0;
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- new string[128];
- if(PlayerInfo[playerid][menuing] > 1 && PlayerInfo[playerid][option] == 0)
- {
- if(strlen(text) > 12)
- {
- GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Username too long", 5000, 3);
- return 0;
- }
- if(strfind(text, "~", true) != -1)
- {
- GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Invalid charactors", 5000, 3);
- return 0;
- }
- format(PlayerInfo[playerid][username], sizeof(string), "%s", text);
- if(PlayerInfo[playerid][menuing] == 2)
- {
- format(string, sizeof(string), "~r~>Username: ~y~%s~r~<~n~~w~Password: ~g~%s~n~~w~Login", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box3]);
- TextDrawSetString(ServerInfo[box3], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box3]);
- }
- else if(PlayerInfo[playerid][menuing] == 3)
- {
- format(string, sizeof(string), "~r~>Username: ~y~%s~r~<~n~~w~Password: ~g~%s~n~~w~Register", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box5]);
- TextDrawSetString(ServerInfo[box5], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box5]);
- }
- return 0;
- }
- if(PlayerInfo[playerid][menuing] > 1 && PlayerInfo[playerid][option] == 1)
- {
- if(strlen(text) > 12)
- {
- GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Password too long", 5000, 3);
- return 0;
- }
- if(strfind(text, "~", true) != -1)
- {
- GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Invalid charactors", 5000, 3);
- return 0;
- }
- format(PlayerInfo[playerid][password], sizeof(string), "%s", text);
- if(PlayerInfo[playerid][menuing] == 2)
- {
- format(string, sizeof(string), "~w~Username: ~g~%s~n~~r~>Password: ~y~%s~r~<~n~~w~Login", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box3]);
- TextDrawSetString(ServerInfo[box3], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box3]);
- }
- else if(PlayerInfo[playerid][menuing] == 3)
- {
- format(string, sizeof(string), "~w~Username: ~g~%s~n~~r~>Password: ~y~%s~r~<~n~~w~Register", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box5]);
- TextDrawSetString(ServerInfo[box5], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box5]);
- }
- return 0;
- }
- if(PlayerInfo[playerid][menuing] > 0) return 0;
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(strcmp(cmdtext, "/menu", true) == 0)
- {
- if(PlayerInfo[playerid][menuing] == 1) return 1;
- if(PlayerInfo[playerid][logged] == 1) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~You are already logged in", 5000, 3);
- PlayerInfo[playerid][menuing] = 1;
- PlayerInfo[playerid][option] = 0;
- PlayerInfo[playerid][username] = EOS;
- PlayerInfo[playerid][password] = EOS;
- TogglePlayerControllable(playerid, 0);
- SetCameraBehindPlayer(playerid);
- TextDrawSetString(ServerInfo[box1], "~r~>Login<~n~~w~Register");
- TextDrawShowForPlayer(playerid, ServerInfo[box1]);
- TextDrawShowForPlayer(playerid, ServerInfo[box2]);
- return 1;
- }
- if(strcmp(cmdtext, "/gmx", true) == 0)
- {
- TextDrawHideForAll(ServerInfo[box1]);
- TextDrawHideForAll(ServerInfo[box2]);
- TextDrawHideForAll(ServerInfo[box3]);
- TextDrawHideForAll(ServerInfo[box4]);
- SendRconCommand("gmx");
- return 1;
- }
- if(strcmp(cmdtext, "/kill", true) == 0)
- {
- SetPlayerHealth(playerid, 0);
- return 1;
- }
- return 0;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new string[128];
- if(PlayerInfo[playerid][menuing] == 0) return 1;
- if(PlayerInfo[playerid][menuing] == 1)
- {
- if(PRESSING(newkeys, KEY_JUMP))
- {
- PlayerInfo[playerid][option] = 0;
- TextDrawHideForPlayer(playerid, ServerInfo[box1]);
- TextDrawSetString(ServerInfo[box1], "~r~>Login<~n~~w~Register");
- TextDrawShowForPlayer(playerid, ServerInfo[box1]);
- }
- if(PRESSING(newkeys, KEY_SPRINT))
- {
- PlayerInfo[playerid][option] = 1;
- TextDrawHideForPlayer(playerid, ServerInfo[box1]);
- TextDrawSetString(ServerInfo[box1], "~w~Login~n~~r~>Register<");
- TextDrawShowForPlayer(playerid, ServerInfo[box1]);
- }
- if(PRESSING(newkeys, KEY_FIRE))
- {
- TextDrawHideForPlayer(playerid, ServerInfo[box1]);
- TextDrawHideForPlayer(playerid, ServerInfo[box2]);
- if(PlayerInfo[playerid][option] == 0)
- {
- TextDrawSetString(ServerInfo[box3], "~r~>Username:<~n~~w~Password:~n~~w~Login");
- PlayerInfo[playerid][menuing] = 2;
- PlayerInfo[playerid][option] = 0;
- TextDrawShowForPlayer(playerid, ServerInfo[box3]);
- TextDrawShowForPlayer(playerid, ServerInfo[box4]);
- }
- if(PlayerInfo[playerid][option] == 1)
- {
- TextDrawSetString(ServerInfo[box5], "~r~>Username:<~n~~w~Password:~n~~w~Register");
- PlayerInfo[playerid][menuing] = 3;
- PlayerInfo[playerid][option] = 0;
- TextDrawShowForPlayer(playerid, ServerInfo[box5]);
- TextDrawShowForPlayer(playerid, ServerInfo[box4]);
- }
- }
- }
- else if(PlayerInfo[playerid][menuing] == 2)
- {
- if(PRESSING(newkeys, KEY_JUMP))
- {
- if(PlayerInfo[playerid][option] == 1 || PlayerInfo[playerid][option] == 0)
- {
- PlayerInfo[playerid][option] = 0;
- format(string, sizeof(string), "~r~>Username: ~y~%s~r~<~n~~w~Password: ~g~%s~n~~w~Login", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box3]);
- TextDrawSetString(ServerInfo[box3], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box3]);
- }
- else if(PlayerInfo[playerid][option] == 2)
- {
- PlayerInfo[playerid][option] = 1;
- format(string, sizeof(string), "~w~Username: ~g~%s~n~~r~>Password: ~y~%s~r~<~n~~w~Login", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box3]);
- TextDrawSetString(ServerInfo[box3], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box3]);
- }
- }
- if(PRESSING(newkeys, KEY_SPRINT))
- {
- if(PlayerInfo[playerid][option] == 0)
- {
- PlayerInfo[playerid][option] = 1;
- format(string, sizeof(string), "~w~Username: ~g~%s~n~~r~>Password: ~y~%s~r~<~n~~w~Login", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box3]);
- TextDrawSetString(ServerInfo[box3], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box3]);
- }
- else if(PlayerInfo[playerid][option] == 1 || PlayerInfo[playerid][option] == 2)
- {
- PlayerInfo[playerid][option] = 2;
- format(string, sizeof(string), "~w~Username: ~g~%s~n~~w~Password: ~g~%s~n~~r~>Login<", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box3]);
- TextDrawSetString(ServerInfo[box3], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box3]);
- }
- }
- if(PRESSING(newkeys, KEY_FIRE))
- {
- if(PlayerInfo[playerid][option] == 0) GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Press F6 and type in your username", 5000, 3);
- if(PlayerInfo[playerid][option] == 1) GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Press F6 and type in your password", 5000, 3);
- if(PlayerInfo[playerid][option] == 2)
- {
- PlayerInfo[playerid][menuing] = 0;
- TogglePlayerControllable(playerid, 1);
- TextDrawHideForPlayer(playerid, ServerInfo[box3]);
- TextDrawHideForPlayer(playerid, ServerInfo[box4]);
- if(strlen(PlayerInfo[playerid][username]) == 0 || strlen(PlayerInfo[playerid][password]) == 0) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Invalid Syntax", 5000, 3);
- if(dini_Exists(PlayerInfo[playerid][username]) == 0) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Account does not exist", 5000, 3);
- if(strcmp(PlayerInfo[playerid][password], dini_Get(PlayerInfo[playerid][username], "password"), true) != 0) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Invalid Password", 5000, 3);
- PlayerInfo[playerid][logged] = 1;
- GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~You are now logged in", 5000, 3);
- }
- }
- }
- else if(PlayerInfo[playerid][menuing] == 3)
- {
- if(PRESSING(newkeys, KEY_JUMP))
- {
- if(PlayerInfo[playerid][option] == 1 || PlayerInfo[playerid][option] == 0)
- {
- PlayerInfo[playerid][option] = 0;
- format(string, sizeof(string), "~r~>Username: ~y~%s~r~<~n~~w~Password: ~g~%s~n~~w~Register", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box5]);
- TextDrawSetString(ServerInfo[box5], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box5]);
- }
- else if(PlayerInfo[playerid][option] == 2)
- {
- PlayerInfo[playerid][option] = 1;
- format(string, sizeof(string), "~w~Username: ~g~%s~n~~r~>Password: ~y~%s~r~<~n~~w~Register", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box5]);
- TextDrawSetString(ServerInfo[box5], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box5]);
- }
- }
- if(PRESSING(newkeys, KEY_SPRINT))
- {
- if(PlayerInfo[playerid][option] == 0)
- {
- PlayerInfo[playerid][option] = 1;
- format(string, sizeof(string), "~w~Username: ~g~%s~n~~r~>Password: ~y~%s~r~<~n~~w~Register", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box5]);
- TextDrawSetString(ServerInfo[box5], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box5]);
- }
- else if(PlayerInfo[playerid][option] == 1 || PlayerInfo[playerid][option] == 2)
- {
- PlayerInfo[playerid][option] = 2;
- format(string, sizeof(string), "~w~Username: ~g~%s~n~~w~Password: ~g~%s~n~~r~>Register<", PlayerInfo[playerid][username], PlayerInfo[playerid][password]);
- TextDrawHideForPlayer(playerid, ServerInfo[box5]);
- TextDrawSetString(ServerInfo[box5], string);
- TextDrawShowForPlayer(playerid, ServerInfo[box5]);
- }
- }
- if(PRESSING(newkeys, KEY_FIRE))
- {
- if(PlayerInfo[playerid][option] == 0) GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Press F6 and type in your username", 5000, 3);
- if(PlayerInfo[playerid][option] == 1) GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Press F6 and type in your password", 5000, 3);
- if(PlayerInfo[playerid][option] == 2)
- {
- PlayerInfo[playerid][menuing] = 0;
- TogglePlayerControllable(playerid, 1);
- TextDrawHideForPlayer(playerid, ServerInfo[box5]);
- TextDrawHideForPlayer(playerid, ServerInfo[box4]);
- if(strlen(PlayerInfo[playerid][username]) == 0 || strlen(PlayerInfo[playerid][password]) == 0) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Invalid Syntax", 5000, 3);
- if(dini_Exists(PlayerInfo[playerid][username]) == 1) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Account already exists - Please choose a diffrent username", 5000, 3);
- dini_Create(PlayerInfo[playerid][username]);
- dini_Set(PlayerInfo[playerid][username], "Password", PlayerInfo[playerid][password]);
- GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~w~Account created - You may now login", 5000, 3);
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement