if (strcmp(cmd, "/login", true) ==0 )
{
if(IsPlayerConnected(playerid))
{
new tmppass[64];
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /login [password]");
return 1;
}
strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
Encrypt(tmppass);
SetPlayerHealth(playerid, 0); <---- DO I ONLY REMOVE THIS? Or what Else? :\
OnPlayerLogin(playerid,tmppass);
}
return 1;
}
if (strcmp(cmd, "/register", true) ==0 )
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
new namestring = strfind(sendername, "_", true);
if(namestring == -1)
{
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "Immigration: Your name is not acceptable.");
SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "Hint: Your name must be in the format Firstname_Lastname.");
Kick(playerid);
return 1;
}
else
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s.ini", sendername);
new File: hFile = fopen(string, io_read);
if (hFile)
{
SendClientMessage(playerid, COLOR_YELLOW, "That Name is already taken, please choose a different one.");
fclose(hFile);
return 1;
}
new tmppass[64];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /register [password]");
return 1;
}
strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
Encrypt(tmppass);
OnPlayerRegister(playerid,tmppass);
}
}
return 1;
}
if (strcmp(cmd, "/changepass", true) ==0 )
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s.ini", sendername);
new tmppass[64];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /changepass [newpassword]");
return 1;
}
strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
Encrypt(tmppass);
OnPlayerRegister(playerid,tmppass);
}
return 1;
}
if (strcmp(cmd, "/changename", true)==0)
{
tmp = strtok(cmdtext, idx);
new string2[256];
if (gPlayerLogged[playerid] != 1)
{
SendClientMessage(playerid, COLOR_GRAD1, " You Are Not Logged In");
return 1;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /changename [newname]");
return 1;
}
format(string, sizeof(string), "%s.ini", tmp);
if(fexist(string))
{
SendClientMessage(playerid, COLOR_GRAD1, " That nick is registered");
return 1;
}
OnPlayerRename(tmp,string,playerid);
format(string, sizeof(string), "You may now reconnect with the name %s", tmp);
SendClientMessage(playerid, COLOR_YELLOW, string);
GetPlayerName(playerid, playername, sizeof(playername));
format(string2, sizeof(string2), "%s.ini", playername);
printf("%s has changed there name to %s.", playername,tmp);
gPlayerLogged[playerid] = 0;
fremove(string2);
return 1;
}
|