Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Include--
- #include <a_samp>
- #include <YSI\y_ini>
- #include <zcmd>
- //Forward--
- forward LoadUser_data(playerid,name[],value[]);
- //Enum--
- enum pInfo
- {
- pPassword,
- pCash,
- pAdmin,
- pBanned,
- pBanName,
- pBanBy,
- pBanReason,
- Skin,
- Float:Xpos,
- Float:Ypos,
- Float:Zpos,
- Float:Anglelog
- }
- //New--
- new pAntiHackSawnOff[MAX_PLAYERS]; // 1=Accepted, 0=Hacked
- new PlayerInfo[MAX_PLAYERS][pInfo];
- //Define--
- #define Dialog_Register_Password 1
- #define Dialog_Login_Password 2
- #define Dialog_AntiHackSawnOffMessage 3
- #define Dialog_AntiHackSawnOffAppeal 4
- #define PATH "/Users/%s.ini"
- #define Dialog_Color_Red "{F81414}"
- //Main--
- main()
- {
- print("Roleplay GameMode Loaded.");
- }
- //Public--
- public OnGameModeInit()
- {
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- pAntiHackSawnOff[playerid] = 0;
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- if(PlayerInfo[playerid][pBanned] == 1)
- {
- new stringban[2000];
- format(stringban, sizeof(stringban), "{FFFFFF}You {FC4949}%s{FFFFFF} have been banned by %s for: %s\nPlease write your appael below to let admins judge it.", PlayerInfo[playerid][pBanName], PlayerInfo[playerid][pBanBy], PlayerInfo[playerid][pBanReason]);
- ShowPlayerDialog(playerid, Dialog_AntiHackSawnOffAppeal, DIALOG_STYLE_MSGBOX, "{FC4949}Banned!", stringban, "Send", "Quit");
- }
- else
- {
- ShowPlayerDialog(playerid, Dialog_Login_Password, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
- }
- }
- else
- {
- ShowPlayerDialog(playerid, Dialog_Register_Password, DIALOG_STYLE_INPUT,"Registering...","Type your password below to register a new account.","Register","Quit");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new Float:Xlog, Float:Ylog, Float:Zlog, Float:Angle;
- GetPlayerFacingAngle(playerid, Angle);
- GetPlayerPos(playerid, Xlog, Ylog, Zlog);
- PlayerInfo[playerid][Xpos] = Xlog;
- PlayerInfo[playerid][Ypos] = Ylog;
- PlayerInfo[playerid][Zpos] = Zlog;
- PlayerInfo[playerid][Anglelog] = Angle;
- new playerskin = GetPlayerSkin(playerid);
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
- INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
- INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
- INI_WriteInt(File,"BanName",PlayerInfo[playerid][pBanName]);
- INI_WriteInt(File,"BanBy",PlayerInfo[playerid][pBanBy]);
- INI_WriteInt(File,"BanReason",PlayerInfo[playerid][pBanReason]);
- INI_WriteInt(File,"Skin",playerskin);
- INI_WriteFloat(File,"Xpos",PlayerInfo[playerid][Xpos]);
- INI_WriteFloat(File,"Ypos",PlayerInfo[playerid][Ypos]);
- INI_WriteFloat(File,"Zpos",PlayerInfo[playerid][Zpos]);
- INI_WriteFloat(File,"Anglelog",PlayerInfo[playerid][Anglelog]);
- INI_Close(File);
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(GetPlayerWeapon(playerid) == 26)
- {
- if(pAntiHackSawnOff[playerid] == 0)
- {
- new name[MAX_PLAYER_NAME], BanReasonString[17], BanByString[10];
- GetPlayerName(playerid, name, sizeof(name));
- format(BanReasonString, sizeof(BanReasonString), "Sawn Off Hacking");
- format(BanByString, sizeof(BanByString), "Anti Hack");
- PlayerInfo[playerid][pBanned] = 1;
- PlayerInfo[playerid][pBanName] = name[playerid];
- PlayerInfo[playerid][pBanBy] = BanByString;
- PlayerInfo[playerid][pBanReason] = BanReasonString;
- ResetPlayerWeapons(playerid);
- ShowPlayerDialog(playerid, Dialog_AntiHackSawnOffMessage, DIALOG_STYLE_MSGBOX, ""Dialog_Color_Red"Banned!", "[Anti-Hack] You have been banned by the Anti-Hack system for: Sawn Off Hack.", "Appael", "Quit");
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case Dialog_AntiHackSawnOffMessage:
- {
- if(!response)
- {
- Kick(playerid);
- }
- if(response)
- {
- ShowPlayerDialog(playerid, Dialog_AntiHackSawnOffAppeal, DIALOG_STYLE_INPUT, ""Dialog_Color_Red"Banned!","[Anti-Hack] You have been banned by the Anti-Hack system for: Sawn Off Hack.\nPlease write your appael below to let admins judge it.","Appael","Quit");
- }
- }
- case Dialog_AntiHackSawnOffAppeal:
- {
- if(!response)
- {
- Kick(playerid);
- }
- if(response)
- {
- ShowPlayerDialog(playerid, Dialog_AntiHackSawnOffAppeal, DIALOG_STYLE_INPUT, ""Dialog_Color_Red"Banned!","[Anti-Hack] You have been banned by the Anti-Hack system for: Sawn Off Hack.\nPlease write your appael below to let admins judge it.","Appael","Quit");
- }
- }
- case Dialog_Register_Password:
- {
- if (!response) return Kick(playerid);
- if(response)
- {
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, Dialog_Register_Password, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Password",udb_hash(inputtext));
- INI_WriteInt(File,"Cash",0);
- INI_WriteInt(File,"Admin",0);
- INI_WriteInt(File,"Banned",0);
- INI_WriteInt(File,"BanName",0);
- INI_WriteInt(File,"BanBy",0);
- INI_WriteInt(File,"BanReason",0);
- INI_WriteInt(File,"Skin",0);
- INI_WriteInt(File,"Xpos",0);
- INI_WriteInt(File,"Ypos",0);
- INI_WriteInt(File,"Zpos",0);
- INI_WriteInt(File,"Anglelog",0);
- INI_Close(File);
- SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
- SpawnPlayer(playerid);
- }
- }
- case Dialog_Login_Password:
- {
- if ( !response ) return Kick ( playerid );
- if( response )
- {
- if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
- SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
- SetPlayerFacingAngle(playerid, PlayerInfo[playerid][Anglelog]);
- SetPlayerPos(playerid, PlayerInfo[playerid][Xpos], PlayerInfo[playerid][Ypos], PlayerInfo[playerid][Zpos]+0.3);
- SetSpawnInfo(playerid, PlayerInfo[playerid][Skin], PlayerInfo[playerid][Skin], PlayerInfo[playerid][Xpos], PlayerInfo[playerid][Ypos], PlayerInfo[playerid][Zpos]+0.3, PlayerInfo[playerid][Anglelog], 0, 0, 0, 0, 0, 0);
- SpawnPlayer(playerid);
- }
- else
- {
- ShowPlayerDialog(playerid, Dialog_Login_Password, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
- }
- return 1;
- }
- }
- }
- return 1;
- }
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("Password",PlayerInfo[playerid][pPassword]);
- INI_Int("Cash",PlayerInfo[playerid][pCash]);
- INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
- INI_Int("Banned",PlayerInfo[playerid][pBanned]);
- INI_Int("BanName",PlayerInfo[playerid][pBanName]);
- INI_Int("BanBy",PlayerInfo[playerid][pBanBy]);
- INI_Int("BanReason",PlayerInfo[playerid][pBanReason]);
- INI_Int("Skin",PlayerInfo[playerid][Skin]);
- INI_Float("Xpos",PlayerInfo[playerid][Xpos]);
- INI_Float("Ypos",PlayerInfo[playerid][Ypos]);
- INI_Float("ZXpos",PlayerInfo[playerid][Zpos]);
- INI_Float("Anglelog",PlayerInfo[playerid][Anglelog]);
- return 1;
- }
- //CMD--
- CMD:gunsawnofftrue(playerid, params[])
- {
- pAntiHackSawnOff[playerid] = 1;
- GivePlayerWeapon(playerid, 26, 64);
- return 1;
- }
- CMD:gunsawnoff(playerid, params[]) // Hack Test
- {
- GivePlayerWeapon(playerid, 26, 64);
- return 1;
- }
- //Stock--
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),PATH,playername);
- return string;
- }
- stock udb_hash(buf[]) {
- new length=strlen(buf);
- new s1 = 1;
- new s2 = 0;
- new n;
- for (n=0; n<length; n++)
- {
- s1 = (s1 + buf[n]) % 65521;
- s2 = (s2 + s1) % 65521;
- }
- return (s2 << 16) + s1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement