Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #include <YSI\y_ini>
- #include <zcmd>
- #include <streamer>
- #include <sscanf>
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- new Text:login;
- new Text:kills;
- new Text:deaths;
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- // On top of script:
- // In OnGameModeInit
- login = TextDrawCreate(6 ,311 , "Logging to the server");
- TextDrawFont(login , 1);
- TextDrawLetterSize(login ,0.3, 1.5);
- TextDrawColor(login , 0x4400ffFF);
- TextDrawSetOutline(login , false);
- TextDrawSetProportional(login , true);
- TextDrawSetShadow(login , 1);
- kills = TextDrawCreate(6 ,290 , "Kills:");
- TextDrawFont(login , 1);
- TextDrawLetterSize(login ,0.3, 1.5);
- TextDrawColor(login , 0x4400ffFF);
- TextDrawSetOutline(login , false);
- TextDrawSetProportional(login , true);
- TextDrawSetShadow(login , 1);
- deaths = TextDrawCreate(6 ,269 , "Deaths:");
- TextDrawFont(login , 1);
- TextDrawLetterSize(login ,0.3, 1.5);
- TextDrawColor(login , 0x4400ffFF);
- TextDrawSetOutline(login , false);
- TextDrawSetProportional(login , true);
- TextDrawSetShadow(login , 1);
- 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;
- }
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- #define DIALOG_SUCCESS_1 3
- #define DIALOG_SUCCESS_2 4
- #define PATH "/Users/%s.ini"
- #define colorenter 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #define colorexit 0xFFFF00AA
- enum pInfos
- {
- pPass,
- pCash,
- pAdmin,
- pKills,
- pDeaths,
- pActivity,
- pRegister
- }
- new pInfo[MAX_PLAYERS][pInfos];
- new
- Float: PosX[ MAX_PLAYERS ],
- Float: PosY[ MAX_PLAYERS ],
- Float: PosZ[ MAX_PLAYERS ],
- Float: Angle[ MAX_PLAYERS ]
- ;
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("Password",pInfo[playerid][pPass]);
- INI_Int("Cash",pInfo[playerid][pCash]);
- INI_Int("Admin",pInfo[playerid][pAdmin]);
- INI_Int("Kills",pInfo[playerid][pKills]);
- INI_Int("Deaths",pInfo[playerid][pDeaths]);
- INI_Float( "PosX", PosX[ playerid ] );
- INI_Float( "PosY", PosY[ playerid ] );
- INI_Float( "PosZ", PosZ[ playerid ] );
- INI_Float( "PosAngle", Angle[ playerid ] );
- INI_Int("Activity",pInfo[playerid][pActivity]);
- return 1;
- }
- 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;
- }
- public OnPlayerConnect(playerid)
- {
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{A92ACC}Login","{09B086}Type your password below to login.","Login","Quit");
- TextDrawShowForPlayer(playerid,login);
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"{A92ACC}REGISTER","{09B086}Type your password below to register a new account to join Flement RPG.","Register","Quit");
- TextDrawSetString(login,"Registering to the server!");
- TextDrawShowForPlayer(playerid,login);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
- GetPlayerFacingAngle( playerid, Angle[ playerid ] );
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Cash",pInfo[playerid][pCash]);
- INI_WriteInt(File,"Admin",pInfo[playerid][pAdmin]);
- INI_WriteInt(File,"Kills",pInfo[playerid][pKills]);
- INI_WriteInt(File,"Deaths",pInfo[playerid][pDeaths]);
- INI_WriteFloat( File, "PosX", PosX[ playerid ] );
- INI_WriteFloat( File, "PosY", PosY[ playerid ] );
- INI_WriteFloat( File, "PosZ", PosZ[ playerid ] );
- INI_WriteFloat( File, "PosAngle", Angle[ playerid ] );
- INI_WriteInt(File,"Activity",pInfo[playerid][pActivity]);
- INI_Close(File);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
- SetPlayerFacingAngle( playerid, Angle[ playerid ] );
- SetTimer("activity",60000,true);
- TextDrawHideForPlayer(playerid,login);
- new str[128],str1[128],str2[128];
- format(str,sizeof(str),"Activity: %d",pInfo[playerid][pActivity]);
- TextDrawSetString(login,str);
- TextDrawShowForPlayer(playerid,login);
- format(str1,sizeof(str1),"Kills: %d",pInfo[playerid][pKills]);
- TextDrawSetString(kills,str1);
- TextDrawShowForPlayer(playerid,kills);
- format(str2,sizeof(str2),"Deaths: %d",pInfo[playerid][pDeaths]);
- TextDrawSetString(deaths,str2);
- TextDrawShowForPlayer(playerid,deaths);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- pInfo[killerid][pKills]++;
- pInfo[playerid][pDeaths]++;
- return 1;
- }
- CMD:activity(playerid,params[])
- {
- new str[128];
- format(str,sizeof(str),"[ ! ] Your total activity is %d",pInfo[playerid][pActivity]);
- SendClientMessage(playerid,colorenter,"------------------------------");
- SendClientMessage(playerid,-1,str);
- SendClientMessage(playerid,colorenter,"------------------------------");
- return 1;
- }
- CMD:kills(playerid,params[])
- {
- new str[128];
- format(str,sizeof(str),"[ ! ] Your total kills are %d",pInfo[playerid][pKills]);
- SendClientMessage(playerid,colorenter,"------------------------------");
- SendClientMessage(playerid,-1,str);
- SendClientMessage(playerid,colorenter,"------------------------------");
- return 1;
- }
- CMD:deaths(playerid,params[])
- {
- new str[128];
- format(str,sizeof(str),"[ ! ] Your total deaths are %d",pInfo[playerid][pDeaths]);
- SendClientMessage(playerid,colorenter,"------------------------------");
- SendClientMessage(playerid,-1,str);
- SendClientMessage(playerid,colorenter,"------------------------------");
- return 1;
- }
- CMD:savestats(playerid,params[])
- {
- GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
- GetPlayerFacingAngle( playerid, Angle[ playerid ] );
- //Login Register system
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Cash",pInfo[playerid][pCash]);
- INI_WriteInt(File,"Admin",pInfo[playerid][pAdmin]);
- INI_WriteInt(File,"Kills",pInfo[playerid][pKills]);
- INI_WriteInt(File,"Deaths",pInfo[playerid][pDeaths]);
- INI_WriteFloat( File, "PosX", PosX[ playerid ] );
- INI_WriteFloat( File, "PosY", PosY[ playerid ] );
- INI_WriteFloat( File, "PosZ", PosZ[ playerid ] );
- INI_WriteFloat( File, "PosAngle", Angle[ playerid ] );
- INI_WriteInt(File,"Activity",pInfo[playerid][pActivity]);
- INI_Close(File);
- SendClientMessage(playerid,colorenter,"[ ! ] Your stats have being saved!");
- //End
- return 1;
- }
- forward activity(playerid);
- public activity(playerid)
- {
- pInfo[playerid][pActivity] += 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch( dialogid )
- {
- case DIALOG_REGISTER:
- {
- if (!response) return Kick(playerid);
- if(response)
- {
- TextDrawSetString(login,"Registering to the server");
- TextDrawShowForPlayer(playerid,login);
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{A92ACC}Registering to the server","{09B086}Type 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,"FCash",0);
- INI_WriteInt(File,"Admin",0);
- INI_WriteInt(File,"Kills",0);
- INI_WriteInt(File,"Deaths",0);
- INI_WriteFloat(File,"PosX",0);
- INI_WriteFloat(File,"PosY",0);
- INI_WriteFloat(File,"PosZ",0);
- INI_WriteFloat(File,"PosAngle",0);
- INI_WriteInt(File,"Activity",0);
- INI_Close(File);
- SetTimer("RegPos",2000,false);
- pInfo[playerid][pActivity] = 0;
- }
- }
- case DIALOG_LOGIN:
- {
- TextDrawSetString(login,"Logging to the server");
- TextDrawShowForPlayer(playerid,login);
- if ( !response ) return Kick ( playerid );
- if( response )
- {
- if(udb_hash(inputtext) == pInfo[playerid][pPass])
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- GivePlayerMoney(playerid, pInfo[playerid][pCash]);
- TextDrawHideForPlayer(playerid,login);
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{A92ACC}Logging into the server","{09B086}You have entered an incorrect password.\nType your password below to login.","Login","Quit");
- }
- return 1;
- }
- }
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment