Not saving dini -
GwarrSVK - 19.02.2020
Hey can someone help with this code ? I need to save money on disconnect and it doesnt work
here is code
https://drive.******.com/open?id=1U_...WtjUN3gTm1jIZC
Re: Not saving dini -
Davi52 - 19.02.2020
Can't reach the link!
Re: Not saving dini -
GwarrSVK - 19.02.2020
#include <dini> //UKLADANIE DБT
#include <dudb> //------//------
#include <strlib>//-------//------
new IsLogged[MAX_PLAYERS];
enum pInfo
{
AdminLevel,
Cash,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnPlayerDisconnect(playerid, reason)
{ //LOGIN/REGISTER
dini_IntSet("%s.ini", "Cash",GetPlayerMoney(playerid));
IsLogged[playerid] = 0;
return 1;
}
NOTHING ON PLAYER CONNECT
public OnPlayerCommandText(playerid, cmdtext[])
{ //UKLADANIE A ZISŤOVANIE ЪČTA
new cmd[256], idx, file[128], tmp[256], tmp2[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) == 0) 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, eadmin, "[System]: Ъčet bol vytvorenэ!");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
GetPlayerName(playerid, name, sizeof(name));
printf("%s has registered a account!", name);
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, " Ъčet bol nбjdenэ v databбze");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
}
return 1;
}
if(strcmp(cmd, "/login", true) == 0)
{
new PlayerName[24];
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /login [password]");
new name[MAX_PLAYER_NAME];
if(IsLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_YELLOW, "Ste prihlбsenэ!");
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, COLOR_YELLOW, "Prihlбsenie neъspeљnй!");
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
printf("%s has failed to login", name);
}
else
{
IsLogged[playerid] = 1;
SetPlayerMoney(playerid, dini_Int(file, "Money"));
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
SendClientMessage(playerid, COLOR_YELLOW, "[System]: Prihlбsenэ!");
}
}
}
return 1;
}
Re: Not saving dini -
GwarrSVK - 19.02.2020
Sorry see now you can download it in next reply i posted