Is it Possible to do this? -
traxrex - 30.11.2010
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;
}
Re: Is it Possible to do this? -
Nero_3D - 30.11.2010
Is it Possible to do this? Yes, it is
Any other questions ?
Re: Is it Possible to do this? -
traxrex - 30.11.2010
How do i do this :P?
off topic: Nice sig :]
Re: Is it Possible to do this? - Guest3598475934857938411 - 30.11.2010
Heres a normal register dialog thing:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 201)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,201,DIALOG_STYLE_INPUT,"Registration","ERROR: You did not enter a password.\nPlease enter a password to register this account!","Register","Cancel");
new playerfile[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(playerfile, sizeof(playerfile), "EAdmin/Users/%s.ini",pname);
if(dini_Exists(playerfile)) return SendClientMessage(playerid, red, "You are already registered!");
new playerip[20];
GetPlayerIp(playerid, playerip, sizeof(playerip));
dini_Create(playerfile);
dini_IntSet(playerfile, "Password", udb_hash(inputtext));
dini_Set(playerfile, "Ip", playerip);
dini_IntSet(playerfile, "Level", 0);
dini_IntSet(playerfile, "Cash", 0);
dini_IntSet(playerfile, "Score", 0);
logged[playerid] = 1;
SendClientMessage(playerid, yellow, "You have registered your account! You have also been logged in.");
}
if(dialogid == 200)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"Login","ERROR: You did not enter a password.\nPlease enter a password to login to this account!","Login","Cancel");
new playerfile[100], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(playerfile, sizeof(playerfile), "EAdmin/Users/%s.ini",pname);
if(!dini_Exists(playerfile)) return SendClientMessage(playerid, red, "This account is not yet registered, please type /register.");
new tmp[256];
tmp = dini_Get(playerfile, "Password");
if(udb_hash(inputtext) == strval(tmp))
{
new playerip[20];
GetPlayerIp(playerid, playerip, sizeof(playerip));
level[playerid] = dini_Int(playerfile, "Level");
logged[playerid] = 1;
dini_Set(playerfile, "Ip", playerip);
GivePlayerMoney(playerid, dini_Int(playerfile, "Cash"));
SetPlayerScore(playerid, dini_Int(playerfile, "Score"));
logged[playerid] = 1;
SendClientMessage(playerid, yellow, "You have logged in!");
} else return ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"Login","ERROR: Invalid Password.\nPlease enter a password to login to this account!","Login","Cancel");
}
return 1;
}
Re: Is it Possible to do this? - Guest3598475934857938411 - 30.11.2010
Oh also:
Код:
COMMAND:login(playerid, params[])
{
if(logged[playerid] == 1) return SendClientMessage(playerid, red, "You are already logged in.");
ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"Login","Please enter a password to login to this account!","Login","Cancel");
return 1;
}
COMMAND:register(playerid, params[])
{
ShowPlayerDialog(playerid,201,DIALOG_STYLE_INPUT,"Registration","Please enter a password to register this account!","Register","Cancel");
return 1;
}
Re: Is it Possible to do this? -
Nero_3D - 30.11.2010
@expertprogrammer I dont think that its useful to put some code here which uses variables / system which traxrex isnt using
Quote:
Originally Posted by traxrex
How do i do this :P?
|
First of all we need
the function
pawn Код:
ShowPlayerDialog(playerid, dialogid, style, caption[], info[], button1[], button2[]);
We want an input dialog so we take the style: DIALOG_STYLE_INPUT
At first we define our unique dialogids
pawn Код:
#define DIALOG_LOGIN (1)
#define DIALOG_REGISTER (2)
pawn Код:
if(gPlayerAccount[playerid] == 1)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login",
"You Are Registered~n~~w~Type your password too log in", "Ok", "Cancel");
} else {
//Your try :P
}
And than the OnDialogResponse code
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid) {
case DIALOG_LOGIN: {
if(response) {
new string[32]; //You can change this code since it only links to your OnPlayerCommandText code
format(string, sizeof string, "/login %s", inputtext);
OnPlayerCommandText(playerid, string);
return 1;
}
}
case DIALOG_REGISTER: {
//Your try
}
}
return 0;
}
Re: Is it Possible to do this? -
traxrex - 01.12.2010
Help D:
pawn Код:
E:\Tp-rp The Revenge of the fallen\INT-RP\INT-RP\gamemodes\INT-RP.pwn(40112) : error 002: only a single statement (or expression) can follow each "case"
E:\Tp-rp The Revenge of the fallen\INT-RP\INT-RP\gamemodes\INT-RP.pwn(40112 -- 40113) : error 029: invalid expression, assumed zero
Код:
40112 = if(dialogid == 1)
40113= {
Re: Is it Possible to do this? -
traxrex - 01.12.2010
Sorry for duble Post But i fixed that But When i press Leave It doest Kick them :[
And I cant make the Register Work :[
Re: Is it Possible to do this? -
Nero_3D - 01.12.2010
What you have so far ?
And the register dialog you already created ?
Basically if you want to kick someone if they press leave and if leave is the second button
pawn Код:
if(response) {
} else {
Kick(playerid);
}