11.07.2011, 10:26
Alright so my register system wont work, when I try to /register it doesnt do anything
I made an folder called Accounts in scriptfiles, what could be the problem?
Код:
forward OnPlayerRegister(playerid,password[]);
pawn Код:
public OnPlayerRegister(playerid, password[])
{
if(IsPlayerConnected(playerid))
{
new name[MAX_PLAYER_NAME], str[128], ip[15];
GetPlayerName(playerid, name, sizeof name);
GetPlayerIp(playerid, ip, sizeof ip);
format(str, sizeof str, "/sAccounts/%s.ws", name);
new File:account = fopen(str, io_write);
if (account)
{
strmid(AccountInfo[playerid][Password], password, 0, strlen(password), 255);
AccountInfo[playerid][Cash] = GetPlayerMoney(playerid);
new Yearz, Monthz, Dayz;
new Hourz, Minutez, Secondz;
getdate(Yearz, Monthz, Dayz);
gettime(Hourz, Minutez, Secondz);
AccountInfo[playerid][RegYear] = Yearz;
AccountInfo[playerid][RegMonth] = Monthz;
AccountInfo[playerid][RegDay] = Dayz;
AccountInfo[playerid][RegHour] = Hourz+1;
AccountInfo[playerid][RegMinute] = Minutez;
new file[128];
{
format(file, sizeof file, "Password: %s\n\r", AccountInfo[playerid][Password]);
{ fwrite(account, file); }
format(file, sizeof file, "AdminLevel: %d\n\r",AccountInfo[playerid][AdminLevel]);
{ fwrite(account, file); }
format(file, sizeof file, "Cash: %d\n\r", AccountInfo[playerid][Cash]);
{ fwrite(account, file); }
format(file, sizeof file, "Bank: %d\n\r", AccountInfo[playerid][Bank]);
{ fwrite(account, file); }
format(file, sizeof file, "Brief: %d\n\r", AccountInfo[playerid][Brief]);
{ fwrite(account, file); }
format(file, sizeof file, "PosX: %f\n\r",AccountInfo[playerid][PosX]);
{ fwrite(account, file); }
format(file, sizeof file, "PosY: %f\n\r",AccountInfo[playerid][PosY]);
{ fwrite(account, file); }
format(file, sizeof file, "PosZ: %f\n\r",AccountInfo[playerid][PosZ]);
{ fwrite(account, file); }
format(file, sizeof file, "SkinQ: %d\n\r",AccountInfo[playerid][SkinQ]);
{ fwrite(account, file); }
format(file, sizeof file, "SkinJ: %d\n\r",AccountInfo[playerid][SkinJ]);
{ fwrite(account, file); }
format(file, sizeof file, "TeamJ: %d\n\r",AccountInfo[playerid][TeamJ]);
{ fwrite(account, file); }
format(file, sizeof file, "swat: %d\n\r",AccountInfo[playerid][swat]);
{ fwrite(account, file); }
format(file, sizeof file, "wspd: %d\n\r",AccountInfo[playerid][wspd]);
{ fwrite(account, file); }
format(file, sizeof file, "pJailed: %d\n\r",AccountInfo[playerid][pJailed]);
{ fwrite(account, file); }
format(file, sizeof file, "pJailT: %d\n\r",AccountInfo[playerid][pJailT]);
{ fwrite(account, file); }
format(file, sizeof file, "RegYear: %d\n\r",AccountInfo[playerid][RegYear]);
{ fwrite(account, file); }
format(file, sizeof file, "RegMonth: %d\n\r",AccountInfo[playerid][RegMonth]);
{ fwrite(account, file); }
format(file, sizeof file, "RegDay: %d\n\r",AccountInfo[playerid][RegDay]);
{ fwrite(account, file); }
format(file, sizeof file, "RegHour: %d\n\r",AccountInfo[playerid][RegHour]);
{ fwrite(account, file); }
format(file, sizeof file, "RegMinute: %d\n\r",AccountInfo[playerid][RegMinute]);
{ fwrite(account, file); }
format(file, sizeof file, "IP: %s\n\r",ip);
{ fwrite(account, file); }
}
fclose(account);
SendClientMessage(playerid,COLOR_GREEN, "- Account successfully registered. You can now login (/login [password])");
}
}
return 1;
}
pawn Код:
if (strcmp(cmd, "/register", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(AccountInfo[playerid][Logged] == 1)
{
SendClientMessage(playerid,COLOR_RED, "You are already logged in");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "/sAccounts/%s.ws", sendername);
new File: hFile = fopen(string, io_read);
if (hFile)
{
SendClientMessage(playerid,COLOR_RED, "That name is already taken. Please reconnect using a different username");
fclose(hFile);
return 1;
}
new tmppass[128];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /register [password]");
strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
OnPlayerRegister(playerid, MD5_Hash(tmppass));
}
return 1;
}
if (strcmp(cmd, "/login", true) == 0) // Logins
{
new tmppass[128];
if(AccountInfo[playerid][Logged] == 1) return SendClientMessage(playerid,COLOR_RED, "You are already logged in");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /login [password]");
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, sizeof(plname));
format(string, sizeof(string), "/sAccounts/%s.ws", plname);
if(!fexist(string)) return SendClientMessage(playerid,COLOR_RED, "That account isn't registered! Please register: /register [password]");
strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
OnPlayerLogin(playerid, MD5_Hash(tmppass));
return 1;
}