Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <YSI\y_ini>
- #define COLOR_GOLD 0xB8860BAA
- #define dregister 2011
- #define dlogin 2012
- #define UserPath "OPUsers/%s.ini"
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Simple Welcome + Register and Login Message by Oldphynix");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Simple Welcome + Register and Login Message by Oldphynix");
- print("----------------------------------\n");
- }
- //Enums
- enum PlayerInfo
- {
- Pass[129],
- Adminlevel,
- VIPlevel,
- Money,
- Scores,
- Kills,
- Deaths
- }
- //News
- new pInfo[MAX_PLAYERS][PlayerInfo];
- //Natives
- native WP_Hash(buffer[],len,const str[]);
- //Stocks
- stock Path(playerid)
- {
- new str[128],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- format(str,sizeof(str),UserPath,name);
- return str;
- }
- //Functions
- forward loadaccount_user(playerid, name[], value[]);
- #endif
- //Accounts Public
- public loadaccount_user(playerid, name[], value[])
- {
- INI_String("Password", pInfo[playerid][Pass],129);
- INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);
- INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);
- INI_Int("Money",pInfo[playerid][Money]);
- INI_Int("Scores",pInfo[playerid][Scores]);
- INI_Int("Kills",pInfo[playerid][Kills]);
- INI_Int("Deaths",pInfo[playerid][Deaths]);
- return 1;
- }
- //Others Public
- public OnGameModeInit()
- {
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new pname[MAX_PLAYER_NAME], string[23 + MAX_PLAYER_NAME+1];
- GetPlayerName(playerid, pname, sizeof(pname));
- format(string, sizeof(string), "Player %s Has Joined the Server!", pname);
- SendClientMessageToAll(COLOR_GOLD, string);
- if(fexist(Path(playerid)))
- {
- INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
- ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This Username is registered.\nPlease Enter Your Passwords to Login","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
- }
- else
- {
- ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome,This Username aren't Registered\nPlease Enter your passwords to register and keep it secret","Register","Quit");
- return 1;
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new
- szString[64],
- name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, MAX_PLAYER_NAME);
- switch(reason)
- {
- case 0: format(szString, sizeof szString, "Player %s Has Leaved The Server, Reason : Timed Out/Crashed", name);
- case 1: format(szString, sizeof szString, "Player %s Has Leaved The Server, Reason : Leaved", name);
- case 2: format(szString, sizeof szString, "Player %s Has Leaved The Server, Reason : Kicked/Banned", name);
- }
- SendClientMessageToAll(COLOR_GOLD, szString);
- new INI:file = INI_Open(Path(playerid));
- INI_SetTag(file,"Player's Data");
- INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]);
- INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);
- INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
- INI_WriteInt(file,"Scores",GetPlayerScore(playerid));
- INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);
- INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);
- INI_Close(file);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- pInfo[killerid][Kills]++;
- pInfo[playerid][Deaths]++;
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(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)
- {
- 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(!response) return Kick(playerid);
- if(response)
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome,This Username aren't Registered\nPlease Enter your passwords to register and keep it secret\nPlease enter the password!","Register","Quit");
- return 1;
- }
- new hashpass[129];
- WP_Hash(hashpass,sizeof(hashpass),inputtext);
- new INI:file = INI_Open(Path(playerid));
- INI_SetTag(file,"Player's Data");
- INI_WriteString(file,"Password",hashpass);
- INI_WriteInt(file,"AdminLevel",0);
- INI_WriteInt(file,"VIPLevel",0);
- INI_WriteInt(file,"Money",25000);
- INI_WriteInt(file,"Scores",2);
- INI_WriteInt(file,"Kills",0);
- INI_WriteInt(file,"Deaths",0);
- INI_Close(file);
- SendClientMessage(playerid,-1,"You Have been Registered , Welcome ! You get 2 Scores and 25000 Money from register");
- return 1;
- }
- }
- if(dialogid == dlogin)
- {
- if(!response) return Kick(playerid);
- if(response)
- {
- new hashpass[129];
- WP_Hash(hashpass,sizeof(hashpass),inputtext);
- if(!strcmp(hashpass, pInfo[playerid][Pass], false))
- {
- INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
- SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
- }
- else
- {
- ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This Username is registered.\nPlease Enter Your Passwords to Login\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
- return 1;
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement