30.11.2010, 14:10
Is it possible to convert this to dialog?
pawn Код:
if(gPlayerAccount[playerid] == 1)
{
GameTextForPlayer(playerid, "~g~You Are Registered~n~~w~T/login [password] To log in", 5000, 1);
}
else
{
GameTextForPlayer(playerid, "~g~You are Not Registered~n~~w~/Register [password] To register", 5000, 1);
}
pawn Код:
if (strcmp(cmd, "/register", true)==0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /register [password]");
return 1;
}
if (gPlayerAccount[playerid] == 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "[SERVER]: That name is already registerd.");
return 1;
}
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "users/%s.ini", playername);
PlayerInfo[playerid][pCash] = GetPlayerPCash(playerid);
new File: file = fopen(string, io_read);
if (file)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "[SERVER]: That name is already registerd.");
gPlayerAccount[playerid] = 0;
fclose(file);
return 1;
}
OnPlayerRegister(playerid, tmp);
SendClientMessage(playerid, COLOR_WHITE, "[HINT]: Type (/login <password>) to log in.");
gPlayerAccount[playerid] = 1;
strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255);
PlayerInfo[playerid][pLevel] = 1;
OnPlayerDataSave(playerid);
return 1;
}
pawn Код:
if (strcmp(cmd, "/login", true) ==0 )
{
if (gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
return 1;
}
if (gPlayerAccount[playerid] == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "[SERVER]: You do not have an account, type /register <password>");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /login [password]");
return 1;
}
format(string, sizeof(string), "users/%s.ini", PlayerName(playerid));
new File: hFile = fopen(string, io_read);
if (hFile)
{
fclose(hFile);
OnPlayerLogin(playerid,tmp);
return 1;
}
return 1;
}