Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <YSI\y_ini>
- #include <sscanf2>
- #include <zcmd>
- #define FILTERSCRIPT
- #define DIALOG_REGISTER 9998
- #define DIALOG_LOGIN 9999
- #define UserPath "Users/%s.ini"
- #define COLOR_RED 0xFF0000FF
- #define COLOR_BLUE 0x0000FFFF
- #define COLOR_YELLOW 0xFFFF00FF
- #define COLOR_GREEN 0x00FF00FF
- #define COLOR_LIGHTBLUE 0x00FFFFFF
- #define COLOR_WHITE 0xFFFFFFFF
- #define COLOR_BLACK 0x000000FF
- #define COLOR_GRAY 0x808080FF
- native WP_Hash(buffer[],len,const str[]);
- forward loadaccount_user(playerid, name[], value[]);
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n---------------------------------------");
- print(" Blank admin filterscript by Stinged ");
- print("---------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- #endif
- enum PlayerStats
- {
- password[128],
- money,
- score,
- deaths,
- admin,
- }
- new pStats[MAX_PLAYERS][PlayerStats];
- public OnPlayerConnect(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- if(fexist(Path(playerid)))
- {
- INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{00FFFF}Login", "{00FFFF}Please enter your password to login.", "OK", "Cancel");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{00FFFF}Please enter your password to register.", "OK", "Cancel");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:file = INI_Open(Path(playerid));
- INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
- INI_WriteInt(file,"Score",GetPlayerScore(playerid));
- INI_WriteInt(file,"Deaths",pStats[playerid][deaths]);
- INI_WriteInt(file,"Admin",pStats[playerid][admin]);
- INI_Close(file);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid, pStats[playerid][money]);
- SetPlayerScore(playerid, pStats[playerid][score]);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- pStats[killerid][score]++;
- pStats[killerid][money]++;
- pStats[playerid][deaths]++;
- GivePlayerMoney(killerid, 1);
- SetPlayerScore(killerid, pStats[killerid][score]);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(response)
- {
- switch(dialogid)
- {
- case DIALOG_REGISTER:
- {
- if(!response) return Kick(playerid);
- if(response)
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00FFFF}Register", "{00FFFF}Please enter your password to register.\n{FF0000}You can't leave this empty.", "OK", "Cancel");
- return 1;
- }
- new hashpass[129];
- WP_Hash(hashpass,sizeof(hashpass),inputtext);
- new string[128];
- new INI:file = INI_Open(Path(playerid));
- INI_WriteString(file,"Password",hashpass);
- INI_WriteInt(file,"Money",0);
- INI_WriteInt(file,"Score",0);
- INI_WriteInt(file,"Deaths",0);
- INI_WriteInt(file,"Admin",0);
- INI_Close(file);
- format(string, sizeof(string), "You have successfully registered. Password: {00FF00)%s", inputtext);
- SendClientMessage(playerid, COLOR_WHITE, string);
- return 1;
- }
- }
- case DIALOG_LOGIN:
- {
- if(!response) return Kick(playerid);
- if(response)
- {
- new hashpass[129];
- WP_Hash(hashpass,sizeof(hashpass),inputtext);
- if(!strcmp(hashpass, pStats[playerid][password], false))
- {
- INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
- SendClientMessage(playerid,COLOR_WHITE,"You have successfully logged in.");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "{00FFFF}Please enter your password to login.\n{FF0000}Incorrect password.", "OK", "Cancel");
- return 1;
- }
- }
- }
- }
- }
- return 1;
- }
- CMD:setlevel(playerid,params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- new id,level,string[128],aName[MAX_PLAYER_NAME];
- if(sscanf(params,"ud",id,level)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /setlevel [id/name] [level]");
- else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "Invalid player id.");
- else if(level > 5) SendClientMessage(playerid, COLOR_RED, "Highest admin level is 5.");
- else
- {
- pStats[id][admin] = 5;
- new INI:file = INI_Open(Path(id));
- INI_WriteInt(file,"Admin",level);
- INI_Close(file);
- GetPlayerName(playerid, aName, sizeof(aName));
- format(string, sizeof(string), "Admin %s has set your admin level to %d.",aName,level);
- SendClientMessage(playerid, COLOR_WHITE, "You have changed the selected user's admin level.");
- SendClientMessage(id,COLOR_GREEN,string);
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "[!] You need to be a higher admin level to use this command.");
- }
- return 1;
- }
- public loadaccount_user(playerid, name[], value[])
- {
- INI_String("Password",pStats[playerid][password],128);
- INI_Int("Money",pStats[playerid][money]);
- INI_Int("Score",pStats[playerid][score]);
- INI_Int("Deaths",pStats[playerid][deaths]);
- INI_Int("Admin",pStats[playerid][admin]);
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment