Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////
- // Unknown Roleplay //
- // Type: Roleplay //
- // Author: Jake Johnson & David W. //
- // Licensing: CCC //
- // Completion time: Unknown //
- // Bugs: None at this time. //
- //////////////////////////////////////////////
- //////////////////////////
- /* Includes */
- //////////////////////////
- #include <a_samp>
- #include <CMD>
- #include <foreach>
- #include <dini>
- #include <dutils>
- //////////////////////////////
- /* Color defines */
- //////////////////////////////
- #define white 0xFFFFFFFAA
- //////////////////////////////////////
- /* Other defines[Random] */
- //////////////////////////////////////
- #define gmdev "Jake Johnson"
- #define gmver "Version 1.0.0"
- #define gmstability "STABLE"
- #define gmgravity "0.008"
- #define SCM SendClientMessage
- #define SPP SetPlayerPos
- #define mapname "San Andreas"
- #define chatcmds 1
- #define chatcmds1 10
- #define chatcmds2 2
- #define chatcmds3 3
- #define chatcmds4 4
- #define chatcmds5 5
- #define chatcmds6 6
- #define chatcmds7 7
- #define chatcmds8 8
- #define chatcmds9 9
- #define RequestClass 10
- #define Login 11
- #define Register 12
- #define RegistrationSuccess 13
- forward waitdisplay();
- forward OnPlayerLogin(playerid, password[]);
- forward OnPlayerRegister(playerid, password[]);
- forward OnPlayerUpdate(playerid);
- //////////////////////////////////////
- /* Main Defines [Random] */
- //////////////////////////////////////
- new LoggedIn[MAX_PLAYERS];
- new LoginTries[MAX_PLAYERS];
- new PlayerAccount[MAX_PLAYERS];
- new Typed[MAX_PLAYERS][64];
- enum PlayerEnumeration
- {
- Level,
- Password,
- Money,
- }
- new PI[MAX_PLAYERS][PlayerEnumeration];
- public OnGameModeInit()
- {
- return 1;
- }
- stock playerfirstname(playerid)
- {
- new
- namestring[2][MAX_PLAYER_NAME],
- name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,MAX_PLAYER_NAME);
- split(name, namestring, '_');
- return namestring[0];
- }
- stock split(const strsrc[], strdest[][], delimiter)
- {
- new i, li;
- new aNum;
- new len;
- while(i <= strlen(strsrc)){
- if(strsrc[i]==delimiter || i==strlen(strsrc)){
- len = strmid(strdest[aNum], strsrc, li, i, 128);
- strdest[aNum][len] = 0;
- li = i+1;
- aNum++;
- }
- i++;
- }
- return 1;
- }
- Log(sz_fileName[], sz_input[]) {
- new
- sz_logEntry[156],
- i_dateTime[2][3],
- File: fileHandle = fopen(sz_fileName, io_append);
- gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
- getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
- format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
- fwrite(fileHandle, sz_logEntry);
- return fclose(fileHandle);
- }
- public waitdisplay()
- {
- foreach(Player, i)
- {
- ShowPlayerDialog(i, chatcmds, DIALOG_STYLE_LIST, "Server Commands", "General Commands\nNulled\nNulled\nNulled\nNulled\nNulled\nNulled\nNulled", "Select", "Cancel");
- }
- }
- public OnPlayerCommandPerformed(playerid, cmdtext[], success)
- {
- if(!success)
- {
- new string[500];
- format(string, sizeof(string), "{F81414}[Info]:{FFFFFF} That command is invalid - (%s).", cmdtext);
- SCM(playerid, white, string);
- }
- return 1;
- }
- public OnPlayerCommandReceived(playerid, cmdtext[])
- {
- new pname[MAX_PLAYER_NAME];
- new string[500];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(string, sizeof(string), "[Logging]: %s has typed a command - (%s).", pname, cmdtext);
- print(string);
- Log("logging/cmd.log", string);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new connectstring[128];
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- PI[playerid][Level] = 0;
- PI[playerid][Money] = 0;
- format(connectstring, sizeof(connectstring), "%s.ini", name);
- if(dini_Exists(connectstring))
- {
- PlayerAccount[playerid] = 1;
- }
- else
- {
- PlayerAccount[playerid] = 0;
- }
- return 1;
- }
- public OnPlayerRegister(playerid, password[])
- {
- if(IsPlayerConnected(playerid))
- {
- new file[64];
- new playername3[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername3, sizeof(playername3));
- format(file, sizeof(file), "%s.ini", playername3);
- if(dini_Exists(file))
- {
- return SCM(playerid, white,"Error: This account is already registered.");
- }
- else
- {
- dini_Create(file);
- new password2 = num_hash(password);
- PI[playerid][Password] = password2;
- dini_IntSet(file, "Password",password2);
- dini_IntSet(file, "Level",PI[playerid][Level]);
- dini_IntSet(file, "Money",PI[playerid][Money]);
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,"Registration","You've sucessfully registered!\nPlease type your password below to login","Login","Quit");
- }
- }
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(IsPlayerConnected(playerid))
- {
- if(LoggedIn[playerid] == 1)
- {
- new string3[64];
- new playername3[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername3, sizeof(playername3));
- format(string3, sizeof(string3), "%s.ini", playername3);
- dini_IntSet(string3, "Password",PI[playerid][Password]);
- dini_IntSet(string3, "Level",PI[playerid][Level]);
- dini_IntSet(string3, "Money",PI[playerid][Money]);
- }
- }
- return 1;
- }
- public OnPlayerLogin(playerid,password[])
- {
- new string2[64];
- new playername3[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername3, sizeof(playername3));
- format(string2, sizeof(string2), "%s.ini", playername3);
- if (dini_Exists(string2))
- {
- new password2 = num_hash(password);
- if(dini_Int(string2,"Password") == password2)
- {
- PI[playerid][Password] = dini_Int(string2,"Password");
- PI[playerid][Level] = dini_Int(string2,"Level");
- PI[playerid][Money] = dini_Int(string2,"Money");
- }
- else
- {
- LoginTries[playerid] += 1;
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,"Invalid password","That password is invalid.\nPlease enter your password below:","Login","Quit");
- if(LoginTries[playerid] == 3)
- {
- SCM(playerid, white, "You've been kicked for too many invalid password attempts.");
- Kick(playerid);
- }
- return 1;
- }
- }
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- ShowPlayerDialog(playerid, RequestClass, DIALOG_STYLE_MSGBOX,"Test1","Test2","Accept","Refuse");
- SetPlayerCameraPos(playerid, 1890.1014,-1194.7969,25.8091);
- SetPlayerCameraLookAt(playerid, 1933.4393,-1196.2479,18.8163);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == chatcmds)
- {
- if(response)
- {
- if(listitem == 0)
- {
- ShowPlayerDialog(playerid, chatcmds1, DIALOG_STYLE_MSGBOX, "General Commands", " ", "Thanks", "Cancel");
- }
- if(listitem == 1)
- {
- ShowPlayerDialog(playerid, chatcmds2, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
- }
- if(listitem == 2)
- {
- ShowPlayerDialog(playerid, chatcmds3, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
- }
- if(listitem == 3)
- {
- ShowPlayerDialog(playerid, chatcmds4, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
- }
- if(listitem == 4)
- {
- ShowPlayerDialog(playerid, chatcmds5, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
- }
- if(listitem == 5)
- {
- ShowPlayerDialog(playerid, chatcmds6, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
- }
- if(listitem == 6)
- {
- ShowPlayerDialog(playerid, chatcmds7, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
- }
- if(listitem == 7)
- {
- ShowPlayerDialog(playerid, chatcmds8, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
- }
- if(listitem == 8)
- {
- ShowPlayerDialog(playerid, chatcmds9, DIALOG_STYLE_MSGBOX, "Nulled Commands", " ", "Thanks", "Cancel");
- }
- }
- }
- if(dialogid == RequestClass)
- {
- if(response)
- {
- new playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- new string[64];
- format(string, sizeof(string), "%s.ini", playername);
- if (dini_Exists(string))
- {
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,"Server Login","Welcome back!\nPlease enter your password below to login:","Login","Quit");
- }
- else
- {
- ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT,"Registration", "Welcome to our server!\nPlease type a password below to register here:","Register","Quit");
- }
- }
- else
- {
- SCM(playerid, white, "You've been kicked due to hitting 'Quit'.");
- Kick(playerid);
- }
- }
- if(dialogid == Login)
- {
- if(response)
- {
- strmid(Typed[playerid], inputtext, 0, strlen(inputtext), 255);
- if(!strcmp(Typed[playerid], "None", true))
- {
- ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,"Server Login","Welcome back!\nPlease enter your password below to login:","Login","Quit");
- }
- else
- {
- OnPlayerLogin(playerid, inputtext);
- }
- }
- else
- {
- Kick(playerid);
- }
- }
- if(dialogid == Register)
- {
- if(response == 1)
- {
- new sendername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, sendername, sizeof(sendername));
- new string[512];
- format(string, sizeof(string),"Thanks for registering, %s\nYou've been given 500 dollars and level 1 to start you off.",sendername);
- ShowPlayerDialog(playerid, RegistrationSuccess, DIALOG_STYLE_MSGBOX, "Sucessfull Registration",string,"Ok","");
- GivePlayerMoney(playerid, 500);
- SetPlayerScore(playerid, 1);
- OnPlayerRegister(playerid, inputtext);
- }
- else
- {
- Kick(playerid);
- }
- }
- return 0;
- }
- //////////////////////////////////////
- /* Commands[ZCMD + sscanf] */
- //////////////////////////////////////
- // format format(string, sizeof(string)
- CMD:cmds(playerid, params[])
- {
- return cmd_commands(playerid, params);
- }
- CMD:commands(playerid, params[])
- {
- new string[32];
- format(string, sizeof(string), "Our commands are as followed, %s.", playerfirstname(playerid));
- SCM(playerid, white, string);
- SetTimer("waitdisplay", 5000, false);
- return 1;
- }
Add Comment
Please, Sign In to add comment