Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <Dini>
- #include <dutils>
- #pragma unused ret_memcpy
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 32
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_YELLOW 0xFFFFF00AA
- #define COLOR_RED 0x660000AA
- #define COLOR_PINK 0xFF66FFAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_DARKRED 0x660000AA
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_ERROR 0xD2691EAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_PINK1 0xEC13COFF
- #define COLOR_GREEN 0x7CFC00AA
- #define DIALOG_REGISTER 100
- #define DIALOG_LOGIN 101
- enum PlayerInfo
- {
- Username[MAX_PLAYER_NAME],
- Password[32],
- RegisterIP[17],
- LastIP[17],
- Cash,
- Bank,
- Level,
- EXP,
- Admin,
- AdminLevel,
- Job,
- JobRank,
- Faction,
- FactionRank
- }
- new pData[MAX_PLAYERS][PlayerInfo];
- new Logged[MAX_PLAYERS];
- forward ScoreUpdate();
- public ScoreUpdate()
- {
- new Score;
- new name[MAX_PLAYER_NAME];
- //new string[256];
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- GetPlayerName(i, name, sizeof(name));
- Score = pData[i][Level];
- SetPlayerScore(i, Score);
- }
- }
- }
- main()
- {
- printf("Mod Loaded.");
- }
- public OnGameModeInit()
- {
- SetTimer("ScoreUpdate", 1000, 1);
- SetGameModeText("BETA");
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new string[158], string1[50];
- if(!dini_Exists(GetPlayerFile(playerid)))
- {
- format(string, sizeof(string), "Welcome to {0000FF}BETA %s{a9c4e4}, Your username didn't found in our database.\nType your {FF0000}password{a9c4e4}, for login in the next times.", GetName(playerid));
- format(string1, sizeof(string1), "Register - {0000FF}%s", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, string1, string, "Register", "Cancel");
- }
- else
- {
- format(string, sizeof(string), "Welcome back {0000FF}%s{a9c4e4}, to {0000FF}BETA.\n{a9c4e4}Enter your {FF0000}password {a9c4e4}below to login.", GetName(playerid));
- format(string1, sizeof(string1), "Login - {0000FF}%s", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Cancel");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(Logged[playerid] == 1)
- {
- dini_Set(GetPlayerFile(playerid), "LastIP", GetIP(playerid));
- dini_IntSet(GetPlayerFile(playerid), "Cash", pData[playerid][Cash]);
- dini_IntSet(GetPlayerFile(playerid), "Bank", pData[playerid][Bank]);
- dini_IntSet(GetPlayerFile(playerid), "Level", pData[playerid][Level]);
- dini_IntSet(GetPlayerFile(playerid), "EXP", pData[playerid][EXP]);
- dini_IntSet(GetPlayerFile(playerid), "Admin", pData[playerid][Admin]);
- dini_IntSet(GetPlayerFile(playerid), "AdminLevel", pData[playerid][AdminLevel]);
- dini_IntSet(GetPlayerFile(playerid), "Job", pData[playerid][Job]);
- dini_IntSet(GetPlayerFile(playerid), "JobRank", pData[playerid][JobRank]);
- dini_IntSet(GetPlayerFile(playerid), "Faction", pData[playerid][Faction]);
- dini_IntSet(GetPlayerFile(playerid), "FactionRank", pData[playerid][FactionRank]);
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(Logged[playerid] == 1)
- {
- new string[256];
- format(string, sizeof(string), "%s says: %s", UnderlineRemove(playerid), text);
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return 1;
- }
- 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)
- {
- for(new i; i > MAX_PLAYERS; i++)
- {
- SetPlayerMarkerForPlayer(i,playerid,0xFFFFFF00);
- }
- 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[])
- {
- new string[180], string1[50];
- if(dialogid == DIALOG_REGISTER)
- {
- if(response)
- {
- if(strlen(inputtext) < 4 || strlen(inputtext) > 32)
- {
- format(string, sizeof(string), "Welcome to {0000FF}BETA %s{a9c4e4}, Your username didn't found in our database.\nType your {FF0000}password{a9c4e4}, for login in the next times.\n{FF0000}ERROR: Invaild Password", GetName(playerid));
- format(string1, sizeof(string1), "Register - {0000FF}%s", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, string1, string, "Register", "Cancel");
- return 0;
- }
- format(string, sizeof(string), "Users/%s.ini", GetName(playerid));
- dini_Create(string);
- dini_Set(GetPlayerFile(playerid), "Username", GetName(playerid));
- dini_Set(GetPlayerFile(playerid), "Password", hash(inputtext));
- dini_Set(GetPlayerFile(playerid), "RegisterIP", GetIP(playerid));
- dini_Set(GetPlayerFile(playerid), "LastIP", GetIP(playerid));
- dini_IntSet(GetPlayerFile(playerid), "Level", 1);
- dini_IntSet(GetPlayerFile(playerid), "EXP", 0);
- dini_IntSet(GetPlayerFile(playerid), "Admin", 0);
- dini_IntSet(GetPlayerFile(playerid), "AdminLevel", 0);
- dini_Set(GetPlayerFile(playerid), "Job", "0");
- dini_Set(GetPlayerFile(playerid), "JobRank", "0");
- dini_Set(GetPlayerFile(playerid), "Faction", "0");
- dini_Set(GetPlayerFile(playerid), "FactionRank", "0");
- format(string, sizeof(string), "Congratulations {0000FF}%s{a9c4e4}, You have been registered successfully.\ntype your {FF0000}password {a9c4e4}again to login.");
- format(string1, sizeof(string1), "Login - {0000FF}%s", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, string1, string, "Login", "Cancel");
- return 1;
- }
- }
- else if(dialogid == DIALOG_LOGIN)
- {
- if(!response) return Kick(playerid);
- if(strlen(inputtext) < 4 || strlen(inputtext) > 32)
- {
- format(string, sizeof(string), "Welcome back {0000FF}%s{a9c4e4}, to {0000FF}BETA.\n{a9c4e4}Enter your {FF0000}password {a9c4e4}below to login.\n{FF0000}ERROR: Type password between 4-32 characters", GetName(playerid));
- format(string1, sizeof(string1), "Login - {0000FF}%s", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, string1, string, "Login", "Cancel");
- format(string, sizeof(string), "%s[Server:]{FF0000}Type Password between 4-32 characters!", COLOR_WHITE);
- SendClientMessage(playerid, COLOR_RED, string);
- return 0;
- }
- else if(strcmp(hash(inputtext), dini_Get(GetPlayerFile(playerid), "Password"), true))
- {
- format(string, sizeof(string), "Welcome back {0000FF}%s{a9c4e4}, to {0000FF}BETA.\n{a9c4e4}Enter your {FF0000}password {a9c4e4}below to login.\n{FF0000}ERROR: Invalid Password!", GetName(playerid));
- format(string1, sizeof(string1), "Login - {0000FF}%s", GetName(playerid));
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, string1, string, "Login", "Cancel");
- format(string, sizeof(string), "%s[Server:]{FF0000}Invalid Password!", COLOR_WHITE);
- SendClientMessage(playerid, COLOR_RED, string);
- return 0;
- } else {
- pData[playerid][Cash] = dini_Int(GetPlayerFile(playerid), "Money");
- pData[playerid][Bank] = dini_Int(GetPlayerFile(playerid), "Bank");
- pData[playerid][Level] = dini_Int(GetPlayerFile(playerid), "Level");
- pData[playerid][EXP] = dini_Int(GetPlayerFile(playerid), "EXP");
- pData[playerid][Admin] = dini_Int(GetPlayerFile(playerid), "Admin");
- pData[playerid][AdminLevel] = dini_Int(GetPlayerFile(playerid), "AdminLevel");
- pData[playerid][Job] = dini_Int(GetPlayerFile(playerid), "Job");
- pData[playerid][JobRank] = dini_Int(GetPlayerFile(playerid), "JobRank");
- pData[playerid][Faction] = dini_Int(GetPlayerFile(playerid), "Faction");
- pData[playerid][FactionRank] = dini_Int(GetPlayerFile(playerid), "FactionRank");
- Logged[playerid] = 1;
- SpawnPlayer(playerid);
- SetPlayerScore(playerid, pData[playerid][Level]);
- return 1;
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- stock GetName(playerid)
- {
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- return pName;
- }
- stock GetIP(playerid)
- {
- new ip[30];
- GetPlayerIp(playerid, ip, 30);
- return ip;
- }
- stock GetPlayerFile(playerid)
- {
- new file[128];
- format(file, sizeof(file), "Users/%s.ini", GetName(playerid));
- return file;
- }
- stock UnderlineRemove(playerid)
- {
- new Name[24];
- GetPlayerName(playerid,Name,24);
- new N[24];
- strmid(N,Name,0,strlen(Name),24);
- for(new i = 0; i < MAX_PLAYER_NAME; i++)
- {
- if (N [i] == '_') N[i] = ' ';
- }
- return N;
- }
Advertisement
Add Comment
Please, Sign In to add comment