Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************************************************************
- * SERVER NAME: Los Santos Life Cops n Robbers
- * SERVER VERSION: v1.0
- * SERVER DEVELOPER: Goldkiller & JerryBean
- *
- * INFORMATION: Los Santos Life Cops n Robbers is a gamemode which was created
- * on the 19.1.2013. This script contains lots of functions, commands, and
- * admin commands.
- *
- * Copyright 2013. Do not steal this Gamemode, if your using it, leave the
- * credits on.
- *
- * To do list:
- *
- * *Add Admin + Register system
- *
- *******************************************************************************/
- //--[INCLUDES]--
- #include <a_samp>
- #include <YSI\y_ini>
- //-----[FORWARDS]-----
- forward loadaccount_user(playerid, name[], value[]);
- //-----[NATIVES]-----
- native WP_Hash(buffer[],len,const str[]);
- //-----[ADMIN DEFINES]-----
- #define dregister 2011
- #define dlogin 2012
- #define UserPath "Adm/Users/%s.ini"
- //-----[COLOR DEFINES FOR ADMIN/REG SYSTEM]-----
- #define COL_WHITE "{FFFFFF}"
- #define COL_RED "{F81414}"
- #define COL_GREEN "{00FF22}"
- #define COL_LIGHTBLUE "{00CED1}"
- //-----[ENUMS]-----
- enum PlayerInfo
- {
- Pass[129], //User's password
- Adminlevel, //User's admin level
- VIPlevel, //User's vip level
- Money, //User's money
- Scores, //User's scores
- Kills, //User's kills
- Deaths //User's deaths
- }
- new pInfo[MAX_PLAYERS][PlayerInfo];
- //-----[OTHER DEFINES]-----
- //-----[FORWARDS]-----
- forward RandomMessages();
- //--[TEXTDRAWS]--
- new Text:Startup0;
- new Text:Startup1;
- new Text:Startup2;
- new Text:Startup3;
- new Text:Startup4;
- new Text:Startup5;
- new randomMessages[][] = //Random server messages
- {
- "[INFO]Always remember to follow the servers rules otherwise it may result in a punishment", //First Random Message
- "[INFO]If you liked our server tell your friends about it", //Second Random Message
- "[INFO]Remember to add our server to your favourites. Our IP is ~Comming soon~", //Third Random Message
- "[INFO]Remember to visit our TeamSpeak 3 server. Our TS3 IP is ~Comming soon~", //Fourth Random Message
- "[INFO]Unsure of anything? Need help? Use /ask to ask a question to our online staff", //Fifth Random Message
- "[INFO]Spotted a hacker? /report in game them or report them on our forums", //Sixth Random Message
- "[INFO]Use /admins to see a list of our online staff", //Sevent Random Message
- "[INFO]Found a bug? Report it on our forums."
- };
- //------[TEAM DEFINES]------
- #define TEAM_COPS 0
- #define TEAM_COLOR_COPS COLOR_BLUE
- #define TEAM_C.I.A 1
- #define TEAM_COLOR_C.I.A COLOR_BLUE
- #define TEAM_SWAT 2
- #define TEAM_COLOR_SWAT COLOR_AQUA
- #define TEAM_ARMY 3
- #define TEAM_COLOR_ARMY COLOR_PURPLE
- #define TEAM_MEDICS 4
- #define TEAM_COLOR_MEDICS COLOR_PINK
- #define TEAM_TAXI 5
- #define TEAM_COLOR_TAXI COLOR_GREEN
- #define TEAM_MECH 6
- #define TEAM_COLOR_MECH COLOR_WHITE
- #define TEAM_ CIV 7
- #define TEAM_COLOR_CIV COLOR_WHITE
- //------[COLOR DEFINES]------
- /////////TEAM_COLORS/////////
- #define COLOR_BLUE 0x00FFFFFF ///Cops & C.I.A
- #define COLOR_AQUA 0x00FFFFFF ///SWAT
- #define COLOR_PURPLE 0xA200FFFF ///Army
- #define COLOR_PINK 0xECC8ECFF ///Medics
- #define COLOR_GREEN 0xECC8ECFF ///Taxi
- #define COLOR_WHITE 0xFFFFFFFF ///CIV & Mech
- //---------[COLORS]---------
- //////////OTHER_COLORS//////
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFFF
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_LIME 0x10F441AA
- #define COLOR_MAGENTA 0xFF00FFFF
- #define COLOR_NAVY 0x000080AA
- #define COLOR_CRIMSON 0xDC143CAA
- #define COLOR_FLBLUE 0x6495EDAA
- #define COLOR_BISQUE 0xFFE4C4AA
- #define COLOR_BLACK 0x000000AA
- #define COLOR_CHARTREUSE 0x7FFF00AA
- #define COLOR_BROWN 0XA52A2AAA
- #define COLOR_CORAL 0xFF7F50AA
- #define COLOR_GOLD 0xB8860BAA
- #define COLOR_GREENYELLOW 0xADFF2FAA
- #define COLOR_INDIGO 0x4B00B0AA
- #define COLOR_IVORY 0xFFFF82AA
- #define COLOR_LAWNGREEN 0x7CFC00AA
- #define COLOR_SEAGREEN 0x20B2AAAA
- #define COLOR_LIMEGREEN 0x32CD32AA
- #define COLOR_MIDNIGHTBLUE 0X191970AA
- #define COLOR_MAROON 0x800000AA
- #define COLOR_OLIVE 0x808000AA
- #define COLOR_ORANGERED 0xFF4500AA
- #define COLOR_SPRINGGREEN 0x00FF7FAA
- #define COLOR_TOMATO 0xFF6347AA
- #define COLOR_YELLOWGREEN 0x9ACD32AA
- #define COLOR_MEDIUMAQUA 0x83BFBFAA
- #define COLOR_MEDIUMMAGENTA 0x8B008BAA
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("-------------------------------------------");
- print("SERVER: Los Santos Life Cops n Robbers");
- print("VERSION: Mode v1.0");
- print("DEVELOPER: Goldkiller & JerryBean");
- print("BETA TESTERS: SilverKiller & JerryBean");
- print("-------------------------------------------");
- }
- #endif
- public OnGameModeInit()
- {
- Startup0 = TextDrawCreate(645.000000, 2.000000, "_");
- TextDrawBackgroundColor(Startup0, 255);
- TextDrawFont(Startup0, 1);
- TextDrawLetterSize(Startup0, 0.500000, 10.100002);
- TextDrawColor(Startup0, -1);
- TextDrawSetOutline(Startup0, 0);
- TextDrawSetProportional(Startup0, 1);
- TextDrawSetShadow(Startup0, 1);
- TextDrawUseBox(Startup0, 1);
- TextDrawBoxColor(Startup0, 255);
- TextDrawTextSize(Startup0, -5.000000, 0.000000);
- Startup1 = TextDrawCreate(645.000000, 354.000000, "_");
- TextDrawBackgroundColor(Startup1, 255);
- TextDrawFont(Startup1, 1);
- TextDrawLetterSize(Startup1, 0.500000, 10.100002);
- TextDrawColor(Startup1, -1);
- TextDrawSetOutline(Startup1, 0);
- TextDrawSetProportional(Startup1, 1);
- TextDrawSetShadow(Startup1, 1);
- TextDrawUseBox(Startup1, 1);
- TextDrawBoxColor(Startup1, 255);
- TextDrawTextSize(Startup1, -5.000000, 0.000000);
- Startup2 = TextDrawCreate(645.000000, 354.000000, "_");
- TextDrawBackgroundColor(Startup2, 255);
- TextDrawFont(Startup2, 1);
- TextDrawLetterSize(Startup2, 0.500000, 0.000000);
- TextDrawColor(Startup2, -1);
- TextDrawSetOutline(Startup2, 0);
- TextDrawSetProportional(Startup2, 1);
- TextDrawSetShadow(Startup2, 1);
- TextDrawUseBox(Startup2, 1);
- TextDrawBoxColor(Startup2, COLOR_LIGHTBLUE);
- TextDrawTextSize(Startup2, -5.000000, 0.000000);
- Startup3 = TextDrawCreate(645.000000, 93.000000, "_");
- TextDrawBackgroundColor(Startup3, 255);
- TextDrawFont(Startup3, 1);
- TextDrawLetterSize(Startup3, 0.500000, 0.000000);
- TextDrawColor(Startup3, -1);
- TextDrawSetOutline(Startup3, 0);
- TextDrawSetProportional(Startup3, 1);
- TextDrawSetShadow(Startup3, 1);
- TextDrawUseBox(Startup3, 1);
- TextDrawBoxColor(Startup3, COLOR_LIGHTBLUE);
- TextDrawTextSize(Startup3, -5.000000, 0.000000);
- Startup4 = TextDrawCreate(138.000000, 19.000000, "Los Santos Life");
- TextDrawBackgroundColor(Startup4, COLOR_LIGHTBLUE);
- TextDrawFont(Startup4, 2);
- TextDrawLetterSize(Startup4, 0.699999, 4.599997);
- TextDrawColor(Startup4, 255);
- TextDrawSetOutline(Startup4, 1);
- TextDrawSetProportional(Startup4, 1);
- Startup5 = TextDrawCreate(92.000000, 73.000000, "This server may contain explicit content and may be considered only for adults");
- TextDrawBackgroundColor(Startup5, COLOR_LIGHTBLUE);
- TextDrawFont(Startup5, 2);
- TextDrawLetterSize(Startup5, 0.240000, 0.900000);
- TextDrawColor(Startup5, 255);
- TextDrawSetOutline(Startup5, 1);
- TextDrawSetProportional(Startup5, 1);
- SetGameModeText("Cops and Robbers");
- //------------------------[PLAYER CLASS SELECTION]--------------------------
- /////////////////////////////////TEAM_COPS//////////////////////////////////
- AddPlayerClass(266, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(265, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(267, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(283, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(288, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(286, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(284, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
- //////////////////////////////////TEAM_C.I.A////////////////////////////////
- AddPlayerClass(165, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(166, 1576.9141,-1692.2262,6.2188,180.0963, 0, 0, 0, 0, 0, 0);
- //////////////////////////////////TEAM_SWAT///////////////////////////////////
- AddPlayerClass(285, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- /////////////////////////////////TEAM_ARMY///////////////////////////////////
- AddPlayerClass(287, 2778.7278,-2410.4207,13.6359,180.4225, 0, 0, 0, 0, 0, 0);
- ////////////////////////////////TEAM_MEDICS//////////////////////////////////
- AddPlayerClass(276, 2027.7826,-1404.2111,17.2339,179.8795, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(275, 2027.7826,-1404.2111,17.2339,179.8795, 0, 0, 0, 0, 0, 0);
- ///////////////////////////////TEAM_TAXI/////////////////////////////////////
- AddPlayerClass(261, 1770.8652,-1861.5470,13.5774,358.8449, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(7, 1770.8652,-1861.5470,13.5774,358.8449, 0, 0, 0, 0, 0, 0);
- //////////////////////////////TEAM_MECH//////////////////////////////////////
- AddPlayerClass(50, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- //////////////////////////////TEAM_CIV///////////////////////////////////////
- AddPlayerClass(2, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(3, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(21, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(22, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(23, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(29, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(47, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(48, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(12, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(24, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(25, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(26, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(28, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(86, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(100, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(103, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(104, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(106, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(107, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(108, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(147, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(149, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(180, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(188, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(217, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(223, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(247, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(248, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(250, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(254, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(264, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(46, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- AddPlayerClass(294, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- //Changing the way it runs
- UsePlayerPedAnims();
- ///Timer
- SetTimer("RandomMessages", 100000, true); //Time for Random Messages - Appears every 100 seceonds
- SetTimer("RandomMessage",10000,1); // 8000 is for 8 seconds, if you want 50 seconds use 50000
- return 1;
- }
- public OnGameModeExit()
- {
- 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)
- {
- TextDrawShowForPlayer(playerid,Startup0);
- TextDrawShowForPlayer(playerid,Startup1);
- TextDrawShowForPlayer(playerid,Startup2);
- TextDrawShowForPlayer(playerid,Startup3);
- TextDrawShowForPlayer(playerid,Startup4);
- TextDrawShowForPlayer(playerid,Startup5);
- PlayAudioStreamForPlayer(playerid, "http://mixconnect.com/disk2/mp3/1e1a51b28bdc93803dcbf.mp3");
- new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
- GetPlayerName(playerid,name,sizeof(name)); //Get player's name
- if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
- {// then
- INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
- ShowPlayerDialog(playerid,dlogin, DIALOG_STYLE_PASSWORD,""COL_GREEN"Login",""COL_WHITE"This account is {00FF22}already registered.\n{FFFFFF}Please login by entering your password in below","Login","Quit");
- }
- else //If the connected user is not registered,
- {//then we will 'force' him to register :)
- ShowPlayerDialog(playerid,dregister, DIALOG_STYLE_PASSWORD,""COL_RED"Register",""COL_WHITE"This account is{F81414} not yet registered \n{FFFFFF}Please create an account by writing a password below","Register","Quit");
- return 1;
- }
- return 1;
- }
- public RandomMessages()
- {
- new randomMsg = random(sizeof(randomMessages)); //create a variable "randomMsg" and give it the value of our array we've created ("randomMessages")
- SendClientMessageToAll(0xFF8400FF, randomMessages[randomMsg]); //Will send a Random Message to everybody on the server
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- //Same as OnDialogResponse, we will save their stats inside of their user's account
- if(fexist(Path(playerid)))//Will check if the file is exit or not inside of User's folder that we have created.
- {
- new INI:file = INI_Open(Path(playerid)); //will open their file
- INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
- INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
- INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
- INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
- INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
- INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
- INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
- INI_Close(file);//Now after we've done saving their data, we now need to close the file
- return 1;
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- TextDrawHideForPlayer(playerid, Startup0);
- TextDrawHideForPlayer(playerid, Startup1);
- TextDrawHideForPlayer(playerid, Startup2);
- TextDrawHideForPlayer(playerid, Startup3);
- TextDrawHideForPlayer(playerid, Startup4);
- TextDrawHideForPlayer(playerid, Startup5);
- StopAudioStreamForPlayer(playerid);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- pInfo[killerid][Kills]++;
- pInfo[killerid][Kills]++;
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/mycommand", cmdtext, true, 10) == 0)
- {
- // Do something here
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == dregister) //If dialog id is a register dialog
- {//then
- if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
- if(response) //if they clicked the first button "Register"
- {//then
- if(!strlen(inputtext)) //If they didn't enter any password
- {// then we will tell to them to enter the password to register
- ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
- return 1;
- }
- //If they have entered a correct password for his/her account...
- new hashpass[129]; //Now we will create a new variable to hash his/her password
- WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
- new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
- INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
- INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
- INI_WriteInt(file,"AdminLevel",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
- INI_WriteInt(file,"VIPLevel",0);//As explained above
- INI_WriteInt(file,"Money",0);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
- INI_WriteInt(file,"Scores",0);//Write an integer inside of user's account called "Scores". We will set their score to 0 after he registered
- INI_WriteInt(file,"Kills",0);//As explained above
- INI_WriteInt(file,"Deaths",0);//As explained above
- INI_Close(file);//Now after we've done saving their data, we now need to close the file
- SendClientMessage(playerid,-1,"You successfuly created an account!");//Tell to them that they have successfully registered a new account
- return 1;
- }
- }
- if(dialogid == dlogin) //If dialog id is a login dialog
- {//then
- if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
- if(response) //if they clicked the first button "Register"
- {//then
- new hashpass[129]; //Will create a new variable to hash his/her password
- WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
- if(!strcmp(hashpass,pInfo[playerid][Pass])) //If they have insert their correct password
- {//then
- INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
- SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
- GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
- SendClientMessage(playerid,-1,"You have successfully logged in");//Tell them that they've successfully logged in
- }
- else //If they've entered an incorrect password
- {//then
- ShowPlayerDialog(playerid,dlogin, DIALOG_STYLE_PASSWORD,""COL_GREEN"Login",""COL_RED"You have entered an{F81414} incorrect password.\n"COL_WHITE"Please try again","Login","Quit");
- return 1;
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- stock Path(playerid)
- {
- new str[128],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- format(str,sizeof(str),UserPath,name);
- return str;
- }
- public loadaccount_user(playerid, name[], value[])
- {
- INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
- ("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
- INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
- INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
- INI_Int("Money",pInfo[playerid][Money]); //As explained above
- INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
- INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
- INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment