format(string, sizeof(string), "Users/%s.ini", playername);//register if (dini_Exists(string)) { RegLogIn[playerid] = 1; SetPlayerCameraPos(playerid, 1363.3137,-1276.4448,21.6530); SetPlayerCameraLookAt(playerid, 1285.9583,-1219.0508,104.1589); ShowDialogID(playerid, 1); TextDrawHideForPlayer(playerid, MainTD[0]); TextDrawHideForPlayer(playerid, MainTD[1]); TogglePlayerControllable(playerid, false); SetPlayerPos(playerid, -1753.8430,885.1340,295.8750); } if (dini_Exists(string))//Login { ShowDialogID(playerid, 2); RegLogIn[playerid] = 1; TextDrawHideForPlayer(playerid, MainTD[0]); TextDrawHideForPlayer(playerid, MainTD[1]); }
check this out first ;
https://sampforum.blast.hk/showthread.php?tid=308390 https://sampforum.blast.hk/showthread.php?tid=101560 and back to this thread. . u get any Error ? warning ? |
format(string, sizeof(string), "Users/%s.ini", playername);//register if (!dini_Exists(string)) { RegLogIn[playerid] = 1; SetPlayerCameraPos(playerid, 1363.3137,-1276.4448,21.6530); SetPlayerCameraLookAt(playerid, 1285.9583,-1219.0508,104.1589); ShowDialogID(playerid, 1); TextDrawHideForPlayer(playerid, MainTD[0]); TextDrawHideForPlayer(playerid, MainTD[1]); TogglePlayerControllable(playerid, false); SetPlayerPos(playerid, -1753.8430,885.1340,295.8750); } if (dini_Exists(string))//Login { ShowDialogID(playerid, 2); RegLogIn[playerid] = 1; TextDrawHideForPlayer(playerid, MainTD[0]); TextDrawHideForPlayer(playerid, MainTD[1]); }
Well it's a silly mistake, you can use the conditional operator ! different means.
I will show how your code using the conditional operator ! Код:
format(string, sizeof(string), "Users/%s.ini", playername);//register if (!dini_Exists(string)) { RegLogIn[playerid] = 1; SetPlayerCameraPos(playerid, 1363.3137,-1276.4448,21.6530); SetPlayerCameraLookAt(playerid, 1285.9583,-1219.0508,104.1589); ShowDialogID(playerid, 1); TextDrawHideForPlayer(playerid, MainTD[0]); TextDrawHideForPlayer(playerid, MainTD[1]); TogglePlayerControllable(playerid, false); SetPlayerPos(playerid, -1753.8430,885.1340,295.8750); } if (dini_Exists(string))//Login { ShowDialogID(playerid, 2); RegLogIn[playerid] = 1; TextDrawHideForPlayer(playerid, MainTD[0]); TextDrawHideForPlayer(playerid, MainTD[1]); } I hope I have helped |
Is this correct what I said, ShowDialogID (playerid, 1) == register and ShowDialogID (playerid, 2) == login, but tests there and see if it worked.
: D :: D D... |
//Includes
#include <a_samp>
#include <dini>
#include <dudb>
//Pragma unused
#pragma unused strtok
#pragma unused ret_memcpy
#define DIALOG_REGISTER 227 // Define a Dialog for Register
#define DIALOG_LOGIN 225 // Define a Dialog for Login
#define SERVER_USER_FILE "PlayerAccount/%s.ini" // This will save the Player Account when he's Register
new PlayerLogged[MAX_PLAYERS];
enum pInfo // Setup your Variables
{
pAdmin, //Admin Variables
pMoney //Money Variables
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnPlayerRequestClass(playerid, classid)
{
// You can change this to OnplayerConnect / OnplayerSpawn / OnplayerRequestClass
new name[MAX_PLAYER_NAME], dfile[256];
GetPlayerName(playerid, name, sizeof(name));
format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
if (!dini_Exists(dfile))
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome {FF0000}Guest! {FFFFFF}- {FFFF00}Register", "{00FF00}Welcome! {FFFFFF}This account isn't {FF0000}registered!\n{FFFFFF}Please input your password to {FF0000}register!", "Register", "Refuse");
}
if(fexist(dfile))
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
//here when the player left the server , the Admin/Money will be save !
new pName[MAX_PLAYER_NAME], dfile[256];
GetPlayerName(playerid, pName, sizeof(pName));
format(dfile, sizeof(dfile), SERVER_USER_FILE, pName);
if(PlayerLogged[playerid] == 1)
{
dini_IntSet(dfile, "Admin", PlayerInfo[playerid][pAdmin]);
dini_IntSet(dfile, "Money", GetPlayerMoney(playerid));
}
PlayerLogged[playerid] = 0;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOG_REGISTER) // Dialog Register
{
new name[MAX_PLAYER_NAME], dfile[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome {FF0000}Guest! {FFFFFF}- {FFFF00}Register", "{00FF00}Welcome! {FFFFFF}This account isn't {FF0000}registered!\n{FFFFFF}Please input your password to {FF0000}register!", "Register", "Refuse");
dini_Create(dfile);
dini_IntSet(dfile, "Password", udb_hash(inputtext));
dini_IntSet(dfile, "Admin", PlayerInfo[playerid][pAdmin]);
dini_IntSet(dfile, "Money", GetPlayerMoney(playerid));
format(string, 128, "[SERVER]: You succesfully registered the nickname {00FF00}%s", name);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
}
if (dialogid == DIALOG_LOGIN) // Dialog Login
{
new name[MAX_PLAYER_NAME], dfile[256];
GetPlayerName(playerid, name, sizeof(name));
format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
new tmp;
tmp = dini_Int(dfile, "Password");
if(udb_hash(inputtext) != tmp) {
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
}
else
{
PlayerInfo[playerid][pAdmin] = dini_Int(dfile, "Admin");
GivePlayerMoney(playerid, dini_Int(dfile, "Cash")-GetPlayerMoney(playerid));
SpawnPlayer(playerid);
}
}
return 1;
}
ooh man, I just forget to add to the post this "!", I thought it was in, my bad, that's why I told you , you were wrong
|
try this
pawn Код:
this is more simple and easy EDIT:Let me try fix your script . . |