Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * GUI dini Login-Register
- * (c) Copyright 2010-2011 by FoxHound
- *
- * @author : FoxHound aka PSPgamer_10
- * @date : 27 October 2010
- * @version : v 1.0
- *
- * This file is provided as is (no warranties).
- *
- */
- #include <a_samp>
- #include <Dini>
- //#pragma unused ret_memcpy
- //Options
- #define USERFILE_DIRECTION "Accounts/%s.acc" //This will be saved in scriptfiles/Accounts/PLAYERNAME.acc. (If you want to save directly in Scriptfiles, just type only "%s.acc"
- #define MAX_LOG_TRIES 4 //Maximal tries to log-in
- //Dialogs
- #define RegisterDialog 946
- #define LoginDialog 945
- forward OnPlayerUpdateEx(playerid); //OnPlayerUpdate Alternative
- forward OnPlayerLogin(playerid, pass[]);
- forward OnPlayerRegister(playerid, pass[]);
- enum pVariableData
- {
- pSkin,
- pKills, pDeaths,
- gPlayerLogged, gLogTries
- }
- new pData[MAX_PLAYERS][pVariableData];
- public OnFilterScriptInit()
- {
- print("\n<-+-----------------------------------------------+->");
- print("\n<-| FoxHounds GUI-&-dini-supported Login-Register |->");
- print("\n<-| Login-Register by: FoxHound |->");
- print("\n<-| dini-System by: DracoBlue |->");
- print("\n<-+-----------------------------------------------+->");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new string[192],pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid,pName,sizeof(pName));
- /************************* RESETTING PLAYER-VARIABLES *************************/
- pData[playerid][pKills]=0; pData[playerid][pDeaths]=0;
- pData[playerid][pSkin]=0;
- pData[playerid][gPlayerLogged]=0; pData[playerid][gLogTries]=0;
- /******************************************************************************/
- RandomPlayerScreen(playerid); //Absolutely OPTIONAL
- format(string,sizeof(string),USERFILE_DIRECTION,pName);
- if(fexist(string))
- {
- format(string,sizeof(string),"Welcome back, %s !\nPlease log in with your Password:",pName);
- ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT, "Login", string, "Enter", "Cancel");
- }
- else
- {
- format(string,sizeof(string),"Hi, %s!\nOh, i see... You haven't got an account.\nYou must register and create one before you can play here.\nPlease enter your new Password in this case:",pName);
- ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_INPUT, "New Useraccount", string, "Enter", "Cancel");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- OnPlayerUpdateEx(playerid);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- pData[playerid][pDeaths]+=1;
- if(killerid != INVALID_PLAYER_ID) { pData[killerid][pKills]+=1; }
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- if(pData[playerid][gPlayerLogged]==1)
- {
- pData[playerid][pSkin]=GetPlayerSkin(playerid);
- return 1;
- }
- return 0;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- OnPlayerUpdateEx(playerid);
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- OnPlayerUpdateEx(playerid);
- return 1;
- }
- public OnPlayerRegister(playerid, pass[])
- {
- new string[64],pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid,pName,sizeof(pName));
- format(string,sizeof(string),USERFILE_DIRECTION,pName);
- if(!dini_Exists(string))
- {
- dini_Create(string);
- dini_Set(string,"Password",pass);
- dini_IntSet(string,"Kills",pData[playerid][pKills]);
- dini_IntSet(string,"Deaths",pData[playerid][pDeaths]);
- dini_IntSet(string,"Skin",pData[playerid][pSkin]);
- pData[playerid][gPlayerLogged]=1;
- CallRemoteFunction("OnPlayerSpawn","i",playerid);
- return 1;
- }
- return 1;
- }
- public OnPlayerLogin(playerid, pass[])
- {
- new string[128],pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid,pName,sizeof(pName));
- format(string,sizeof(string),USERFILE_DIRECTION,pName);
- if(!strcmp(pass,dini_Get(string,"Password"),false))
- {
- pData[playerid][pKills] = dini_Int(string,"Kills");
- pData[playerid][pDeaths] = dini_Int(string,"Deaths");
- pData[playerid][pSkin] = dini_Int(string,"Skin");
- CallRemoteFunction("OnPlayerSpawn","i",playerid);
- pData[playerid][gPlayerLogged] = 1;
- }
- else
- {
- pData[playerid][gLogTries]+=1;
- if(pData[playerid][gLogTries] >= MAX_LOG_TRIES)
- {
- format(string,sizeof(string),"You entered %d times a wrong password and you got banned.\nThe Ban is here, to avoid Password-Phishing.\nIf you forgot your Password, please contact an Admin.",MAX_LOG_TRIES);
- ShowPlayerDialog(playerid,947,DIALOG_STYLE_MSGBOX,"Login Failed",string,"~","~");
- Ban(playerid);
- }
- else
- {
- format(string,sizeof(string),"Wrong User-password !\nPlease try again.\nRemaining tries: '%d'",(MAX_LOG_TRIES-pData[playerid][gLogTries]));
- ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT, "Login Failed", string, "Enter", "Cancel");
- }
- }
- return 1;
- }
- public OnPlayerUpdateEx(playerid)
- {
- new string[64],pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid,pName,sizeof(pName));
- format(string,sizeof(string),USERFILE_DIRECTION,pName);
- if(dini_Exists(string) && pData[playerid][gPlayerLogged])
- {
- dini_IntSet(string,"Kills",pData[playerid][pKills]);
- dini_IntSet(string,"Deaths",pData[playerid][pDeaths]);
- dini_IntSet(string,"Skin",GetPlayerSkin(playerid));
- return 1;
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- #define RBUTTON 0 //Right Button
- #define LBUTTON 1 //Left Button
- new string[256],pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid,pName,sizeof(pName));
- switch(dialogid)
- {
- case RegisterDialog:
- {
- switch(response)
- {
- case RBUTTON: { return Kick(playerid); }
- case LBUTTON:
- {
- new tmp[256],tmppass[64],idx;
- tmp = strtok(inputtext, idx);
- if(!strlen(tmp)) {
- format(string,sizeof(string),"Hi, %s!\nOh, i see... You haven't got an account.\nYou must register and create one before you can play here.\nPlease enter your new Password in this case:",pName);
- return ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_INPUT, "New Useraccount", string, "Enter", "Cancel"); }
- strmid(tmppass,tmp,0,strlen(inputtext),255);
- OnPlayerRegister(playerid, tmppass);
- }
- }
- }
- case LoginDialog:
- {
- switch(response)
- {
- case RBUTTON: { return Kick(playerid); }
- case LBUTTON:
- {
- new tmp[256],tmppass[64],idx;
- tmp = strtok(inputtext, idx);
- if(!strlen(tmp)) {
- format(string,sizeof(string),"Welcome back, %s !\nPlease log in with your Password:",pName);
- return ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT, "Login", string, "Enter", "Cancel"); }
- strmid(tmppass,tmp,0,strlen(inputtext),255);
- OnPlayerLogin(playerid, tmppass);
- }
- }
- }
- }
- return 1;
- }
- forward RandomPlayerScreen(playerid); //Absolutely OPTIONAL to Use (Look at Line '58')
- public RandomPlayerScreen(playerid) {
- new screen = random(10);
- SetPlayerInterior(playerid, 0);
- switch(screen) {
- case 0: {
- SetPlayerPos(playerid,-346.083618,1599.942139,164.472366);
- SetPlayerCameraPos(playerid,-345.877228,1601.342896,164.518951);
- SetPlayerCameraLookAt(playerid,-340.641968,1938.658447,83.722984); }
- case 1: {
- SetPlayerPos(playerid,1485.0194,-892.1475,74.4098);
- SetPlayerCameraPos(playerid,1479.7717,-886.2401,73.9461);
- SetPlayerCameraLookAt(playerid,1415.3817,-807.9097,85.0613); }
- case 2: {
- SetPlayerPos(playerid,589.1550,373.1002,15.7948);
- SetPlayerCameraPos(playerid,543.9864,349.3647,14.9968);
- SetPlayerCameraLookAt(playerid,422.1727,599.0107,19.1812); }
- case 3: {
- SetPlayerPos(playerid,2155.0137,1129.7897,18.6397);
- SetPlayerCameraPos(playerid,2149.3992,1132.6051,24.3125);
- SetPlayerCameraLookAt(playerid,2105.0222,1156.5306,11.6470); }
- case 4: {
- SetPlayerPos(playerid,-2818.1499,1144.0898,19.2409);
- SetPlayerCameraPos(playerid,-2808.0366,1161.1864,20.3125);
- SetPlayerCameraLookAt(playerid,-2817.9348,1143.5291,19.3762); }
- case 5: {
- SetPlayerPos(playerid,2144.2822,1279.8054,7.9840);
- SetPlayerCameraPos(playerid,2154.24,1306.50,41.46);
- SetPlayerCameraLookAt(playerid,2273.45,1262.09,33.78); }
- case 6: {
- SetPlayerPos(playerid,-1771.7858,-565.5638,-0.5834);
- SetPlayerCameraPos(playerid,-1771.4641,-566.3715,16.4844);
- SetPlayerCameraLookAt(playerid,2105.0222,1156.5306,11.6470); }
- case 7: {
- SetPlayerPos(playerid,-1254.7159,953.9262,139.2734);
- SetPlayerCameraPos(playerid,-1256.6115,953.2058,139.2734);
- SetPlayerCameraLookAt(playerid,-1529.6639,689.2731,45.3311); }
- case 8: {
- SetPlayerPos(playerid,-2295.7979,712.2764,69.7422);
- SetPlayerCameraPos(playerid,-2265.6101,730.9575,49.2969);
- SetPlayerCameraLookAt(playerid,-2243.5103,731.5889,62.7217); }
- case 9: {
- SetPlayerPos(playerid,50.0000,50.0000,70.0000);
- SetPlayerCameraPos(playerid,50.0000,50.0000,70.2203);
- SetPlayerCameraLookAt(playerid,499.8851,504.5435,7.6593); } } }
Add Comment
Please, Sign In to add comment