13.04.2011, 17:49
I got this code:
So when the string Password is empty you'll get the register dialog, however when Password contains "somepass" or any other text it will still show the register dialog. I've tried to edit Password manually but nothing seems to work. The SendClientMessage will allways show the password in the playerlist.ini so I think the error lies int strcmp?
EDIT: I defined MAX_PASSWORD in <a_samp>
Код:
#include <a_samp> #include <YSI/y_ini> #include "../include/gl_common.inc" #include <string> #define FILTERSCRIPT #define COLOR_WHITE 0xFFFFFFFF new PlayerName[MAX_PLAYER_NAME], Password[MAX_PASSWORD]; INI:playerlist[](playerid, name[], value[]) { INI_String(PlayerName, Password, sizeof(Password)); return 1; } public OnPlayerCommandText(playerid, cmdtext[]){ new idx; new cmd[256]; cmd = strtok(cmdtext, idx); if(strcmp("/ls", cmd, true) == 0){ GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); INI_Load("playerlist.ini", true, playerid); // if set to true, playerid will be passed over to INI:playerlist[... SendClientMessage(playerid, COLOR_WHITE, Password); if(strcmp(Password, "") == 0){ ShowPlayerDialog(playerid, 30, 1, "Register", "To register you must first give in the first name of your character.", "OK", "Cancel"); return 1; } else{ ShowPlayerDialog(playerid, 33, 1, "Login", "Please give in your password.", "OK", "Cancel"); return 1; } } return 0; }
EDIT: I defined MAX_PASSWORD in <a_samp>