Well im having problems with my registry but the fix to your problem would be like this
if (strcmp(cmd, "/register", true)==0)
{
new string[265];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, grey, "USAGE: /register [password]");
return 1;
}
if (gPlayerAccount[playerid] == 1)
{
SendClientMessage(playerid, grey, " That nickname is already registered");
return 1;
}
strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255);
String(PlayerInfo[playerid][pPassword]);
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "%s.cer", playername);
new File: file = fopen(string, io_read);
if (file)
{
SendClientMessage(playerid, grey, " That name is already registered");
fclose(file);
return 1;
}
//new File:hFile; its now global
hFile = fopen(string, io_append);
new var[32];//
format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
format(var, 32, "Level:%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
format(var, 32, "Exp:%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var);
format(var, 32, "Kills:%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
format(var, 32, "Deaths:%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
format(var, 32, "Cash:%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
fclose(hFile);
SendClientMessage(playerid, white, "Succesfully Registered!");
gPlayerAccount[playerid] = 1;
SendClientMessage(playerid, white, "Next time when you come , use /login [ password ].");
GivePlayerMoney(playerid, 40000);// They get 40k as they register but only for this moment
OnPlayerLogin(playerid,PlayerInfo[playerid][pPassword]);
return 1;
}
return 0;