Hello all... in this day i give "alone" my register and login system...[pawn]#define REGISTERS "/Registers/%s.ini"[/pawn]
[pawn]new INFO[256];[/pawn]
[pawn]#define AMARILLO 0xFFFF00AA[/pawn]
[pawn]public OnPlayerConnect(playerid)
{
new string[128];
SetSpikes(playerid,1);
SetLogueo(playerid,0);
GetPlayerName(playerid,gPlayers[playerid],MAX_PLAYER_NAME);
format(MSN,256,"%s",gPlayers[playerid]);
format( string, 128, "** [%d] %s is entered in server.", playerid, gPlayers[ playerid ] );
print( string );
SetWaterLevel(6.0);
SetGamespeed(100);
SetGravity(100);
{
if (ObtenerLevel(playerid) == 0) {
SendClientMessage(playerid,AMARILLO,"Register or to stay frozen");
SendClientMessage(playerid,AMARILLO,"See the commands availables Whit !cmds");
}
SetLogueo(playerid,0);
if (ObtenerLevel(playerid) >= 1) {
SendClientMessage(playerid,AMARILLO,"Login or to stay frozen");
SendClientMessage(playerid,AMARILLO,"See the commands availables Whit !cmds");
}
}
return 1;
}[/pawn]
[pawn]public OnPlayerCommandText(playerid, cmdtext[ ] )
{
new cmd[256];
new tmp[256];
new szMsg[256];
new idx, newvar;
new Float:x, Float:y, Float:z;
new level[ 128 ], money[256];
new plr;
format(INFO,256, REGISTERS, gPlayers[playerid]);
cmd = strtok(cmdtext, idx);[/pawn]
[pawn]//======================================Register and login of players =====================================[/pawn]
[pawn] if (strcmp(cmd, "login", true) == 0) {
tmp = strtok(cmdtext, idx);
if (ObtenerLevel(playerid) == 0) SendClientMessage(playerid, AMARILLO,"[Error] - This nickname is not registered!");
else if (!strlen(tmp)) SendClientMessage(playerid, AMARILLO,"[Error] : /c login [Password].");
else if (GetLogueo(playerid) == 1) SendClientMessage(playerid, AMARILLO,"[Error] - Already logged!.");
else {
if (strcmp(hash(tmp), ObtenerClave(playerid), true) == 0) LogueoJugador(playerid,tmp);
else SendClientMessage(playerid, AMARILLO,"[Error] - Incorrect Password");
}
return 1;
}
else if (strcmp(cmd, "register", true) == 0) {
tmp = strtok(cmdtext, idx);
new str[256];
if (!strlen(tmp)) SendClientMessage(playerid, AMARILLO,"[Write] - /c register: [Password]");
else if (ObtenerLevel(playerid) >= 1) SendClientMessage(playerid, AMARILLO,"[Error] - This nickname is already registered!");
else if (GetLogueo(playerid) == 1) SendClientMessage(playerid, AMARILLO,"[Error] - Already logued.");
else if( AntiNick ( gPlayers[ playerid ] ) )
{
format( str, sizeof( str ), "Error: Nickname whit invalid characters, remove for register" );
SendClientMessage( playerid, AMARILLO, str );
}
else {
RegistroJugador(playerid,tmp,INFO);
}
return 1;
}[/pawn]
[pawn]//===============Register player================================================================
public RegistroJugador(playerid,clave[ ], xD[ ])
{
new szMsg[256];
dini_Create(xD);
dini_Set(xD,"Nombre", gPlayers[playerid]);
dini_Set(xD,"Clave", hash(clave));
dini_Set(xD,"Banco","1000");
dini_Set(xD,"Dinero","0");
dini_Set(xD,"Level","1");
dini_Set(xD,"Logueo","1");
format(szMsg,sizeof(szMsg),"Registered- Password --> [%s]",clave);
SendClientMessage(playerid,AMARILLO, szMsg);
TogglePlayerControllable(playerid,1);
return 1;
}
//==============================================================================
public LogueoJugador(playerid, clave[ ])
{
new szMsg[256];
format(szMsg,sizeof(szMsg),"Login Whit Password [%s]",clave);
SendClientMessage(playerid,AMARILLO, szMsg);
format(szMsg,sizeof(szMsg),"Name:[%s] Level:[%d][%s].",gPlayers[playerid],ObtenerLevel(playerid),LevelJugador(ObtenerLevel(playerid)));
SendClientMessage(playerid,AMARILLO, szMsg);
TogglePlayerControllable(playerid,1);
SetLogueo(playerid,1);
return 1;
}
//==============================================================================
public GetLogueo(playerid)
{
format(INFO,256, REGISTERS, gPlayers[playerid]);
new logueo; logueo = dini_Int(INFO,"Logueo");
return logueo;
}
//==============================================================================
public SetLogueo(playerid,logueo)
{
format(INFO,256, REGISTERS, gPlayers[playerid]);
dini_IntSet(INFO,"Logueo",logueo);
}
//==============================================================================
public ObtenerClave(playerid)
{
format(INFO,256, REGISTERS, gPlayers[playerid]);
new clave[256]; clave = dini_Get(INFO,"Clave");
return clave;
}
//==============================================================================
public ObtenerLevel(playerid)
{
format(INFO,256, REGISTERS, gPlayers[playerid]);
new level; level = dini_Int(INFO,"Level");
return level;
}
//==============================================================================
//==============================================================================
public LevelJugador(level)
{
new lvl[256];
if (level == 0) lvl = "Not registered";
if (level == 1) lvl = "Registered Player";
if (level == 2) lvl = "Bronze Account";
if (level == 3) lvl = "Silver Account";
if (level == 4) lvl = "Gold Account";
if (level == 5) lvl = "Premium Account";
if (level == 6) lvl = "Moderator Level 2";
if (level == 7) lvl = "Administrator Level 1";
if (level ==
lvl = "Administrator Level 2";
if (level == 9) lvl = "Scripter";
else if (level >= 10) lvl = "Scripter-Owner";
return lvl;
}
//=======================================================[/pawn]
[pawn]//==============================================================================
stock AntiNick(c [ ])
{
if (strfind(c, "*", true) != -1 || strfind(c, "?", true) != -1 ||
strfind(c, ">", true) != -1 || strfind(c, "<", true) != -1 ||
strfind(c, "¡", true) != -1 || strfind(c, "@", true) != -1 ||
strfind(c, "-", true) != -1 || strfind(c, "#", true) != -1 ||
strfind(c, "%", true) != -1 || strfind(c, "ñ", true) != -1 ||
strfind(c, "\\", true) != -1 || strfind(c, "\32", true) != -1 ||
strfind(c, "{", true) != -1 || strfind(c, "\162", true) != -1 ||
strfind(c, "}", true) != -1 || strfind(c, "\47", true) != -1 ||
strfind(c, "´", true) != -1 || strfind(c, "\658", true) != -1 ||
strfind(c, "`", true) != -1 || strfind(c, "\47", true) != -1 ||
strfind(c, "'", true) != -1 || strfind(c, "(", true) != -1 ||
strfind(c, "\33", true) != -1 || strfind(c, "\39", true) != -1 ||
strfind(c, "\34", true) != -1 || strfind(c, "\20", true) != -1 ||
strfind(c, "\21", true) != -1 || strfind(c, "\27", true) != -1 ||
strfind(c, "|", true) != -1) return 1;
if (isNumeric(c)) return 1;
else return 0;
return 1;
}
//==============================================================================
stock NombreJugador(playerid)
{
new nombre[24];
GetPlayerName(playerid,nombre,24);
return nombre;
}
//==============================================================================[/pawn]
[pawn]//====================Sistema de banco==========================================================
public MasDinero(playerid,amount)
{
new monto = ObtenerDinero(playerid)+amount;
format(INFO,256, REGISTERS, gPlayers[playerid]);
dini_IntSet(INFO, "Dinero", monto);
SetPlayerMoney(playerid,monto);
}
//==============================================================================
public MenosDinero(playerid,amount)
{
new monto = ObtenerDinero(playerid)-amount;
format(INFO,256, REGISTERS, gPlayers[playerid]);
dini_IntSet(INFO, "Dinero", monto);
SetPlayerMoney(playerid,monto);
}
//==============================================================================[/pawn]
2 Commands for admins[pawn] else if ( strcmp( cmd, "setmon", true ) == 0 )
{
tmp = strtok(cmdtext, idx), plr = FindPlayerIDFromString(tmp), money = strtok(cmdtext, idx);
if (GetLogueo(playerid) == 0) SendClientMessage(playerid, AMARILLO,"[Error] - Login first");
else if (!strlen(money)) SendClientMessage(playerid, AMARILLO,"[Syntax] - Write: /c setmon [Name] [Money]" );
else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, ROJO, "Error: Unknown Player" );
else if (ObtenerLevel(plr) == 0) SendClientMessage(playerid, AMARILLO,"[Error] - Not is registered");
else {
if (ObtenerLevel(playerid) == 10)
{
format( szMsg, sizeof( szMsg ), "Admin [%s] give money player: %s, amount: $ [%d]",gPlayers[playerid],gPlayers[plr],strval(money));
SendClientMessage( playerid, AMARILLO, szMsg );
MasDinero(plr,strval(money));
}
else SendClientMessage(playerid,AMARILLO,"You not are admin [10]");
}
return 1;
}[/pawn]
[pawn] else if ( strcmp( cmd, "setlevel", true ) == 0 )
{
tmp = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp ), level = strtok( cmdtext, idx );
if (GetLogueo(playerid) == 0) SendClientMessage(playerid, AMARILLO,"[Error] - First Login");
else if ( !strlen( level ) ) SendClientMessage( playerid, ROJO, "Write: /c setlevel [Nick/ID] [ Level ]" );
else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, ROJO, "Error: Unknown player" );
else if (ObtenerLevel(plr) == 0) SendClientMessage(playerid, AMARILLO,"[Error] - This nickname not is registered.");
else
{
if (ObtenerLevel(playerid) == 10) {
format( file, sizeof( file ), REGISTROS, gPlayers[ plr ] );
dini_Set( file, "Level", IntToStr( strval( level) ));
format( szMsg, sizeof( szMsg ), "[Admin] [%s] is changed the level of [%s] to [%s]", gPlayers[playerid],gPlayers[plr],level);
SendClientMessage( playerid, AMARILLO, szMsg );
}
else SendClientMessage(playerid,ROJO,"[ERROR] You Not Are Admin!!");
}
return 1;
}[/pawn]
Make a folder inside of scriptfiles named RegistersI think not forget anything xD