/register help!
#1

This is my /register /login commands

Quote:

// === [Register] ===
if(strcmp(cmd, "/register", true) == 0)
{
tmp = strtok(cmdtext, idx);
GetPlayerName(playerid, playername, sizeof(playername));
if(20 < strlen(tmp) || strlen(tmp) < 4)
{
SendClientMessage(playerid, COLOR_DBLUE, "Lozinka/Password mora imati vise od 4 slova, a manje od 20!!");
return 1;
}
if(!strlen(tmp))
SendClientMessage(playerid, COLOR_DBLUE, "Napisi: /register [password] ~ Da se registriras na server!");

else
{
if (!dini_Exists(udb_encode(playername)))
{
if(regplss[playerid] == 1 )
{
regplss[playerid] = 0;
TextDrawHideForPlayer(playerid, regpls);
}
dini_Create(udb_encode(playername));
dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
dini_Set(udb_encode(playername),"pass",tmp);
dini_IntSet(udb_encode(playername), "level", 0);
format(string, sizeof(string), "%s(%i) se registrirao sa lozinkom \"%s\"", playername, playerid, tmp);
printf(string);
format(string, sizeof(string), "Tvoj ACCOUNT je kreiran %s sa lozinkom \"%s\". OBAVEZNO ZAPAMTI LOZINKU!!!!", playername, tmp);
SendClientMessage(playerid, COLOR_PURPLE, string);
SendClientMessage(playerid, COLOR_PURPLE, "Logged in!");
logged[playerid] = 1;
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
new nstr[100];
format(nstr,100, "s%s", playername);
if( !FileExists(nstr) )
{
FileCreate(nstr);
logged[playerid] = 1;
new Float:X, Float:Y, Float:Z, money, Float:armour ,Float:hp, interior;
new IP[16];
new name[MAX_PLAYER_NAME];
new fnstr[MAX_PLAYERS];
if( logged[playerid] == 1 )
{
GetPlayerArmour(playerid, armour);
GetPlayerHealth(playerid, hp);
GetPlayerPos(playerid,X, Y, Z);
GetPlayerIp(playerid,IP, sizeof(IP));
GetPlayerName(playerid, name, sizeof(name));
interior = GetPlayerInterior(playerid);
money = GetPlayerMoney(playerid);
new score = GetPlayerScore(playerid);
format(fnstr, 256, "s%s", name);

if ( FileExists(fnstr) )
{
FileDelete(fnstr);
FileCreate(fnstr);
SaveFileString(fnstr, "Name: ", name);
SaveFileString(fnstr, "IP: ", IP);
SaveFileInteger(fnstr, "Moneys: ", money);
SaveFileFloat(fnstr , "X: ", X);
SaveFileFloat(fnstr , "Y: ", Y);
SaveFileFloat(fnstr , "Z: ", Z);
SaveFileFloat(fnstr , "HP: ", hp);
SaveFileFloat(fnstr , "Armour: ",armour);
SaveFileInteger(fnstr, "InteriorID: ", interior);
SaveFileInteger(fnstr, "Bank: ", bank[playerid]);
SaveFileInteger(fnstr, "Score: ",score);
print(fnstr);
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error je nastao kada si se pokusavao registrirati na server!!");
format(string, sizeof(string), "Nick %s Je vec registriran na serveru sada /login [password]!", playername,tmp);
SendClientMessage(playerid, COLOR_RED, string);
}
}

return 1;
}
// === [Login] ===
if(strcmp(cmd, "/login", true) == 0)
{
if(logged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "Vec si ulogiran!");
return 1;
}
tmp = strtok(cmdtext, idx);

GetPlayerName(playerid, playername, sizeof(playername));
if(!strlen(tmp))
SendClientMessage(playerid, COLOR_DBLUE, "Napisi: /login [password]");

else
{
if(dini_Exists(udb_encode(playername)))
{
tmp2 = dini_Get(udb_encode(playername), "password");
if(udb_hash(tmp) != strval(tmp2))
{
new PlayerName[24];
GetPlayerName(playerid, PlayerName, 30);
format(string, sizeof(string), "Napisao si pogresnu lozinku za %s", PlayerName);
SendClientMessage(playerid, COLOR_RED, string);
}
else
{
logged[playerid] = 1;
new nstr[100];
format(nstr,100, "s%s", playername);
if( FileExists(nstr) )
{
HasAntifall[playerid] = 0; SetTimerEx("EnableAntifall",5000,0,"i",playerid);
SetTimerEx("StatsLoadTimer", 2000, 0, "i",playerid);
GameTextForPlayer(playerid, "~b~Loading...", 2000, 3);
SendClientMessage(playerid, COLOR_YELLOW, "Sada si ulogiran ! Pricekaj 2 sekunde samo da ti se ucita tvoja statistika !");
}
dini_Set(udb_encode(playername),"pass",tmp);
PlayerInfo[playerid][pAdmin] = dini_Int(udb_encode(playername), "level");
GameTextForPlayer(playerid, "~b~Uspijesno ulogiran!",2000,1);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
if(PlayerInfo[playerid][pAdmin] == 0)
{
new PlayerName[24];
GivePlayerMoney(playerid, 4000);
GetPlayerName(playerid, PlayerName, 30);
format(string, sizeof(string), "Ulogiran kao: %s, Redoviti igrac", PlayerName);
SendClientMessage(playerid, COLOR_CYAN, string);
}
if(PlayerInfo[playerid][pAdmin] == 1)
{
new PlayerName[24];
GetPlayerName(playerid, PlayerName, 30);
SetPlayerArmour(playerid, 100);
format(string, sizeof(string), "Ulogiran kao: %s, Admin level 1 (moderator)", PlayerName);
SendClientMessage(playerid, COLOR_CYAN, string);
}
if(PlayerInfo[playerid][pAdmin] == 2)
{
new PlayerName[24];
SetPlayerArmour(playerid, 100);
GetPlayerName(playerid, PlayerName, 30);
format(string, sizeof(string), "Ulogiran kao: %s, Admin level 2 (administrator)", PlayerName);
SendClientMessage(playerid, COLOR_CYAN, string);
}
if(PlayerInfo[playerid][pAdmin] == 3)
{
new PlayerName[24];
SetPlayerArmour(playerid, 100);
GetPlayerName(playerid, PlayerName, 30);
format(string, sizeof(string), "Ulogiran kao: %s, Admin level 3 (administrator)", PlayerName);
SendClientMessage(playerid, COLOR_CYAN, string);
}
if(PlayerInfo[playerid][pAdmin] == 4)
{
new PlayerName[24];
SetPlayerArmour(playerid, 100);
GetPlayerName(playerid, PlayerName, 30);
format(string, sizeof(string), "Ulogiran kao: %s, Admin level 4 (GLAVNI ADMINISTRATOR)", PlayerName);
SendClientMessage(playerid, COLOR_CYAN, string);
}
return 1;
}
}
else
{
format(string, sizeof(string), "Ovaj account %s, ne postoji. Napisi /register [password] kako bi ga stvorio.", playername);
SendClientMessage(playerid, COLOR_RED, string);
}
}

return 1;
}

I wanna know if someone can post new code but you dont need to type /regiter ****** or /login ***** I wanna when you get into the server the will open BOX and you just need to type password and press login or register PLEASE HELP ME ! TnX
Reply


Messages In This Thread
/register help! - by nastoe - 22.01.2010, 15:10
Re: /register help! - by `FuTuRe- - 22.01.2010, 15:12
Re: /register help! - by Chivava - 22.01.2010, 15:33

Forum Jump:


Users browsing this thread: 1 Guest(s)