27.01.2011, 18:45
(
Последний раз редактировалось KappaG3; 27.01.2011 в 20:49.
)
Hi. I'm new to this forum.
I'm from Italy, so the original version of this script was in Italian. If some words are wrong, please tell me it.
This is a script for registration and login, it saves password, money and score.
In next versions i'll insert some settings in the config file wich allows you to set what do you want to save and what no.
Currently in the config file you can set:
The minimun lenght of the password.
The maximum lenght of the password.
But soon you'll being able to decide if you want to save only moneys, or moneys and weapons ... etc.
For this FS i've created a little include wich contains the functions (so you can modify that by the inc) and the strtok under include, so you can use it without paste the code every times.
Download includes:
Dini 1.6 by DracoBlue
Strtok by KevinGenoves3 (is just the strtok)
RM 1.0 by KevinGenoves3 (contains the functions for the FS)
How to install:
Put the includes in pawno/includes
Add "registerme" to your server.cfg
Enjoy![Smiley](images/smilies/smile.png)
How to use:
Make sure that the message of successfully config load appears in console.
Connect to your server and try to register.
Now, check in scripfiles that there are RM_config.cfg and RM_YourNickname.ini
By RM_YourNickname.ini you can set your password, your moneys and your score.
Score and moneys will update by OnPlayerUpdate every 40ms.
I hope you like this
I'm from Italy, so the original version of this script was in Italian. If some words are wrong, please tell me it.
This is a script for registration and login, it saves password, money and score.
In next versions i'll insert some settings in the config file wich allows you to set what do you want to save and what no.
Currently in the config file you can set:
The minimun lenght of the password.
The maximum lenght of the password.
But soon you'll being able to decide if you want to save only moneys, or moneys and weapons ... etc.
For this FS i've created a little include wich contains the functions (so you can modify that by the inc) and the strtok under include, so you can use it without paste the code every times.
Код:
#include <a_samp> #include <Dini> #include <rm> #include <strtok> new config[24] = "RM_config.cfg"; new PSW_mL, PSW_ML; // In order: PSW_MinLenght, PSW_MaxLenght. new LoggedIn[MAX_PLAYERS]; new file[36]; public OnFilterScriptInit() { //------------------------------------------------------------------------------ if(!dini_Exists(config)) { dini_Create(config); PSW_mL = dini_IntSet(config, "PSW_MinLenght", 8); PSW_ML = dini_IntSet(config, "PSW_MaxLenght", 16); print("-------------------------------------------------------"); print(" RegisterMe - Config created and loaded"); print("-------------------------------------------------------"); } else { PSW_mL = dini_Int(config, "PSW_MinLenght"); PSW_ML = dini_Int(config, "PSW_MaxLenght"); print("---------------------------------------------"); print(" RegisterMe - Config loaded"); print("---------------------------------------------"); } //------------------------------------------------------------------------------ if(dini_Int(config, "PSW_MinLenght") == 0 || dini_Int(config, "PSW_MinLenght") > 12) { dini_IntSet(config, "PSW_MinLenght", 8); printf("Password's min. Lenght: Value to high or low, automatically set to %d", dini_Int(config, "PSW_MinLenght")); } else { printf("Password's min. Lenght: %d characters.", dini_Int(config, "PSW_MinLenght")); } //------------------------------------------------------------------------------ if(dini_Int(config, "PSW_MaxLenght") < dini_Int(config, "PSW_MinLenght")) { dini_IntSet(config, "PSW_MaxLenght", dini_Int(config, "PSW_MinLenght") * 2); printf("Password's max. Lenght: Value to high or low, automatically set to %d", dini_Int(config, "PSW_MaxLenght")); } else { printf("Password's max. Lenght: %d characters.", dini_Int(config, "PSW_MaxLenght")); } print("---------------------------------------------"); //------------------------------------------------------------------------------ return 1; } public OnFilterScriptExit() { //------------------------------------------------------------------------------ print("---------------------------------------------"); print(" RegisterMe - Filterscript unloaded."); print("---------------------------------------------"); //------------------------------------------------------------------------------ return 1; } public OnPlayerConnect(playerid) { new name[24]; GetPlayerName(playerid, name, 24); format(file, sizeof(file), "RM_%s.ini", name); //------------------------------------------------------------------------------ if(!dini_Exists(file)) { SendClientMessage(playerid, 0xFFFFFFFF, "{00dd00} RegisterMe: {c8c8c8} Type /register [psw] for register."); } else { SendClientMessage(playerid, 0xFFFFFFFF, "{00dd00} RegisterMe: {c8c8c8} Type /login [psw] for log-in."); } //------------------------------------------------------------------------------ LoggedIn[playerid] = 0; return 1; } public OnPlayerDisconnect(playerid, reason) { LoggedIn[playerid] = 0; return 1; } public OnPlayerSpawn(playerid) { if(LoggedIn[playerid] == 0) return 0; return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[128], idx; cmd = strtok(cmdtext, idx); //------------------------------------------------------------------------------ if (strcmp("/register", cmd, true, 10) == 0) { new name[24]; GetPlayerName(playerid, name, 24); format(file, sizeof(file), "/RM_%s.ini", name); new tmp[128]; tmp = strtok(cmdtext, idx); if(!dini_Exists(file)) { if(strlen(tmp) < PSW_mL || strlen(tmp) > PSW_ML) return SendClientMessage(playerid, 0xFFFFFFFF, "{00dd00} RegisterMe: {c8c8c8} Errore: Password troppo corta / lunga."); dini_Create(file); dini_Set(file, "Password", tmp); printf("%s have registered with password: %s", name, tmp); } else { SendClientMessage(playerid, 0xFFFFFFFF, "{00dd00} RegisterMe: {c8c8c8} You're already registered. Type /login [psw] for log-in."); } return 1; } //------------------------------------------------------------------------------ if (strcmp("/login", cmd, true, 10) == 0) { new name[24]; GetPlayerName(playerid, name, 24); format(file, sizeof(file), "/RM_%s.ini", name); new tmp[128]; tmp = strtok(cmdtext, idx); if(LoggedIn[playerid] == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "{00dd00} RegisterMe: {c8c8c8} You are already logged in!"); if(dini_Exists(file)) { if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFFF, "{00dd00} RegisterMe: {c8c8c8} Error: Bad password."); if(!strcmp(dini_Get(file, "Password"), tmp, false)) { LoggedIn[playerid] = 1; SendClientMessage(playerid, 0xFFFFFFFF, "{00dd00} RegisterMe: {c8c8c8} You have successfully Logged-in."); printf("%s si и loggato, con password: %s", name, tmp); RMPlayerMoney(playerid); RMPlayerScore(playerid); } else { SendClientMessage(playerid, 0xFFFFFFFF, "{00dd00} RegisterMe: {c8c8c8} Bad password."); } } else { SendClientMessage(playerid, 0xFFFFFFFF, "{00dd00} RegisterMe: {c8c8c8} This account doesn't exists. Type /register [psw] for register."); } return 1; } //------------------------------------------------------------------------------ return 0; } public OnPlayerUpdate(playerid) { UpdatePlayerMoney(playerid); UpdatePlayerScore(playerid); return 1; }
Dini 1.6 by DracoBlue
Strtok by KevinGenoves3 (is just the strtok)
RM 1.0 by KevinGenoves3 (contains the functions for the FS)
How to install:
Put the includes in pawno/includes
Add "registerme" to your server.cfg
Enjoy
![Smiley](images/smilies/smile.png)
How to use:
Make sure that the message of successfully config load appears in console.
Connect to your server and try to register.
Now, check in scripfiles that there are RM_config.cfg and RM_YourNickname.ini
By RM_YourNickname.ini you can set your password, your moneys and your score.
Score and moneys will update by OnPlayerUpdate every 40ms.
I hope you like this
![Cheesy](images/smilies/biggrin.png)