He really did crash, but I made some corrections and it is working perfectly now!
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT
#include <a_samp>
#include <dini>
#include <dudb>
#include <dutils>
#pragma unused ret_memcpy
new IsLogged[MAX_PLAYERS];
new LoginAttempts[MAX_PLAYERS];
enum pInfo
{
AdminLevel,
Cash,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnFilterScriptInit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
LoginAttempts[playerid] = 0;
SendClientMessage(playerid,0xCC0033AA,"Haven't signed up? /register [password]");
SendClientMessage(playerid,0x006633AA,"Have signed up? /login [password]");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
LoginAttempts[playerid]=0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256],idx,file[128],tmp[256];
cmd=strtok(cmdtext,idx);
if(strcmp(cmd, "/register", true) == 0)
{
new name[MAX_PLAYER_NAME];
tmp = strtok(cmdtext, idx);
GetPlayerName(playerid, name, sizeof(name));
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /register [password]");
format(file,sizeof(file),"%s.ini",name);
if(!fexist(file))
{
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(tmp));
dini_IntSet(file,"AdminLevel", 0);
dini_IntSet(file,"Cash", 0);
SendClientMessage(playerid, 0x006633AA, "[System]: Account Created!");
GetPlayerName(playerid, name, sizeof(name));
printf("%s has registered a account!", name);
}
else
{
SendClientMessage(playerid, 0xCC0033AA, " Account Already Found In Database");
}
return 1;
}
if(strcmp(cmd, "/login", true) == 0)
{
new PlayerName[24];
tmp = strtok(cmdtext, idx);
new tmp2[256];
new name[MAX_PLAYER_NAME];
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /login [password]");
if(IsLogged[playerid] == 1)
{
SendClientMessage(playerid, 0xCC0033AA, "You already are logged in!");
return 1;
}
else
{
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"%s.ini",name);
if(fexist(file))
{
tmp2 = dini_Get(file, "Password");
if(udb_hash(tmp) != strval(tmp2))
{
SendClientMessage(playerid, 0xCC0033AA, "Login Failed!");
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
printf("%s has failed to login", name);
}
else
{
IsLogged[playerid] = 1;
SetPlayerMoney(playerid, dini_Int(file, "Cash"));
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
SendClientMessage(playerid, 0xCC0033AA, "[System]: Account Logged into!");
}
}
}
return 1;
}
return 0;
}
public OnPlayerRequestSpawn(playerid)
{
if(IsLogged[playerid] == 0)
{
SendClientMessage(playerid, 0xCC0033AA, "SERVER: You have not logged in yet.");
if(LoginAttempts[playerid]<2)
{
Kick(playerid);
}
return 1;
}
return 1;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}