Register / Login command doesn't work?
#1

Код:
if (strcmp(cmdtext, "/register", true)==0)
{
new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /register [password]");
return 1;
}
if (gPlayerAccount[playerid] == 1)
{
SendClientMessage(playerid, COLOR_ERROR, "That name is already registered");
return 1;
}


strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255);
Encrypt(PlayerInfo[playerid][pPassword]);
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "users/%s.ini", pname);
new File: file = fopen(string, io_read);
if (file)
{
SendClientMessage(playerid, COLOR_ERROR, "That name is already registered");
fclose(file);
return 1;
}
new File:hFile;
hFile = fopen(string, io_append);
new var[32];//
format(var, 32, "pPassword=%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
format(var, 32, "pCash=%s\n", PlayerInfo[playerid][pCash]);fwrite(hFile, var);
format(var, 32, "pKills=%s\n", PlayerInfo[playerid][pKills]);fwrite(hFile, var);
format(var, 32, "pAdmin=%s\n", PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
format(var, 32, "pJailed=%s\n", PlayerInfo[playerid][pJailed]);fwrite(hFile, var);
format(var, 32, "pJailTime=%s\n", PlayerInfo[playerid][pJailTime]);fwrite(hFile, var);
fclose(hFile);
justreg[playerid] = 1;
gPlayerAccount[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "Succesfully Registered!");
SendClientMessage(playerid, COLOR_YELLOW, "Next time you connect, type /login <password> to login.");
OnPlayerLogin(playerid,PlayerInfo[playerid][pPassword]);
return 1;
}
// login
if (strcmp(cmdtext, "/login", true) ==0 )
{
if(IsPlayerConnected(playerid))
{
new tmppass[64];
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_ERROR, "You are already logged in.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_YELLOW, "     USAGE: /login [password]");
return 1;
}
strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass);
}
return 1;
}
When you type register, it says Unknown Command. When you type /login, says wrong password, ideas?

EDIT: Also after i type them commands, the server shuts off.
Reply
#2

Got bumped.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)