Stats now working -
AroseKhanNiazi - 30.03.2014
Code:
enum PlayerInfo
{
Pass[129], //User's password
Adminlevel, //User's admin level
VIPlevel, //User's vip level
Money, //User's money
Scores, //User's scores
Kills, //User's kills
Deaths, //User's deaths
Banned, //User banned or not
Pills, //User Pills
Savedskin, //User Saved Skin
Last, //....
NoPM, //Nopm or not
Drugs, //user drugs
Jailed, //was user banned or not
JailTime, // Jail Timer
belt, //Belt
ad, //ad used
raped, //raped
gotraped, //times got raped
rape_kills, // rape kills
rape_deaths, // raped to death
flash, //flashed
flash_kills, // times did flash kills
flash_deaths, //got died by flash
foff_kills, // kills by doing foff
foff_deaths, // deaths by foff
Weapons_kit, //weapons kit
pBanexp,
pBanres[100],
pBanPerm,
pBanAdmin[20],
fighting,
MoneyBag_Founded
}
new pInfo[MAX_PLAYERS][PlayerInfo];
Code:
forward loadaccount_Players_Data(playerid, name[], value[]);
public loadaccount_Players_Data(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_Int("Money",pInfo[playerid][Money]); //As explained above
INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
INI_Int("Banned",pInfo[playerid][Banned]);
INI_Int("Pills",pInfo[playerid][Pills]);
INI_Int("Savedskin",pInfo[playerid][Savedskin]);
INI_Int("Last",pInfo[playerid][Last]);
INI_Int("NoPM",pInfo[playerid][NoPM]);
INI_Int("Drugs",pInfo[playerid][Drugs]);
INI_Int("belt",pInfo[playerid][belt]);
INI_Int("Jailed",pInfo[playerid][Jailed]);
INI_Int("JailTime",pInfo[playerid][JailTime]);
INI_Int("ad",pInfo[playerid][ad]);
INI_Int("raped",pInfo[playerid][raped]);
INI_Int("gotraped",pInfo[playerid][gotraped]);
INI_Int("rape_kills",pInfo[playerid][rape_kills]);
INI_Int("rape_deaths",pInfo[playerid][rape_deaths]);
INI_Int("flash",pInfo[playerid][flash]);
INI_Int("flash_kills",pInfo[playerid][flash_kills]);
INI_Int("flash_deaths",pInfo[playerid][flash_deaths]);
INI_Int("foff_kills",pInfo[playerid][foff_kills]);
INI_Int("foff_deaths",pInfo[playerid][foff_deaths]);
INI_Int("Weapons_kit",pInfo[playerid][Weapons_kit]);
INI_Int("fighting",pInfo[playerid][fighting]);
INI_Int("MoneyBag_Founded",pInfo[playerid][MoneyBag_Founded]);
return 1;
}
login
Code:
if(dialogid == dlogin) //If dialog id is a login dialog
{//then
if(!response)
{
KickWithMessage(playerid," {FF0000}* You have been kicked - Invalid password. (Change your nick)"); //If they clicked the second button "Quit", we will kick them.
}
if(response) //if they clicked the first button "Register"
{//then
new hashpass[129]; //Will create a new variable to hash his/her password
WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
if(!strcmp(hashpass,pInfo[playerid][Pass])) //If they have insert their correct password
{//then
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
if (pInfo[playerid][Banned] == 1)
{
pInfo[playerid][Banned] =1;
new str1[128];
ban1[playerid] = SetTimerEx("ban", 1000, false, "i", playerid);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,24);
SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
format(str1,sizeof(str1),"**KICK: %s (%d) (ACCOUNT BANNED) Account Banned", pname, playerid);
SendClientMessageToAll(COLOR_HOTPINK, str1);
KickWithMessage(playerid,"You Have Been Removed From The Server.");
if(fexist(UserBanPath(playerid)))
{
INI_ParseFile(UserBanPath(playerid), "LoadBanUser_%s", .bExtra = true, .extra = playerid);
if(pInfo[playerid][pBanPerm]==1)
{
new reso[300];
new targetname[MAX_PLAYER_NAME];
GetPlayerName(playerid,targetname,24);
format(reso,sizeof(reso),"**KICK: %s (%d) (ACCOUNT DISABLED) Account Disabled by Adminstration Reason:%s",targetname,playerid,pInfo[playerid][pBanres]);
SendClientMessageToAll(COLOR_HOTPINK,reso);
SetTimerEx("KickPlayer",100,false,"i",playerid);}
else
{
new d,m,y,h,mi,s;
TimestampToDate(pInfo[playerid][pBanexp],y,m,d,h,mi,s,0,0);//enter the gmt u want where the first 0 is i this statement
if(gettime()>pInfo[playerid][pBanexp])
{
fremove(UserBanPath(playerid));
SendClientMessage(playerid,COLOR_BROWN,"You have been unbanned!!!!");
}
else
{
new str[540];
new reso[300];
new targetname[MAX_PLAYER_NAME];
GetPlayerName(playerid,targetname,24);
format(reso,sizeof(reso),"**KICK: %s (%d) (ACCOUNT DISABLED) Account Disabled by Adminstrator",targetname,playerid);
format(str,sizeof(str),"This Account Has Been Disabled By An Admin. Reason: %s untill :%i-%i-%i :%i-%i",pInfo[playerid][pBanres],d,m,y,h,mi);
SendClientMessage(playerid,COLOR_HOTPINK,str);
SendClientMessageToAll(COLOR_HOTPINK,reso);
SetTimerEx("KickPlayer",100,false,"i",playerid);
}
}
}
}
else
{
SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
//SendClientMessage(playerid,COLOR_LIME,"You have successfully been logged in.");//Tell them that they've successfully logged in
SetTimerEx("AUTO_SAVE", AUTO_SAVE_MINUTES*60*1000, true, "i", playerid);
registered[playerid] =1;
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
if(pInfo[playerid][Adminlevel] >= 1)
{
SendClientMessage(playerid,0xFFFFFFFF, "Logged in as an {FF0000}Admin.");
}
else if(pInfo[playerid][VIPlevel] >= 1)
{
SendClientMessage(playerid,0xFFFFFFFF, "Logged in as an {FF0000}V.I.P.");
}
else
{
SendClientMessage(playerid,0xFFFFFFFF, "Logged in as an {00FFFF}Registered Player.");
}
}
}
onplayerconnect
Code:
pInfo[playerid][Adminlevel] =0;
pInfo[playerid][VIPlevel] =0;
pInfo[playerid][Money] =0;
pInfo[playerid][Scores] =0;
pInfo[playerid][Kills] =0;
pInfo[playerid][Deaths] =0;
pInfo[playerid][Last] = -1;
pInfo[playerid][NoPM] = 0;
pInfo[playerid][Pills] =1;
pInfo[playerid][Jailed] = 0;
on player disconnect
Code:
if(playerid == INVALID_PLAYER_ID || !IsPlayerConnected(playerid)) return SCM(playerid, -1,"");
print("INVALID_PLAYER_ID CALLED");
if(fexist(Path(playerid)))
{// then
new INI:file = INI_Open(Path(playerid)); //will open their file
INI_SetTag(file,"Players_Data");//We will set a tag inside of user's account called "Players_Data"
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
INI_WriteInt(file,"Banned",pInfo[playerid][Banned]);
INI_WriteInt(file,"Pills",pInfo[playerid][Pills]);
INI_WriteInt(file,"Savedskin",pInfo[playerid][Savedskin]);
INI_WriteInt(file,"Last",pInfo[playerid][Last]);
INI_WriteInt(file,"NoPM",pInfo[playerid][NoPM]);
INI_WriteInt(file,"Drugs",pInfo[playerid][Drugs]);
INI_WriteInt(file,"belt",pInfo[playerid][belt]);
INI_WriteInt(file,"Jailed",pInfo[playerid][Jailed]);
INI_WriteInt(file,"ad",pInfo[playerid][ad]);
INI_WriteInt(file,"raped",pInfo[playerid][raped]);
INI_WriteInt(file,"gotraped",pInfo[playerid][gotraped]);
INI_WriteInt(file,"rape_kills",pInfo[playerid][rape_kills]);
INI_WriteInt(file,"rape_deaths",pInfo[playerid][rape_deaths]);
INI_WriteInt(file,"flash",pInfo[playerid][flash]);
INI_WriteInt(file,"flash_kills",pInfo[playerid][flash_kills]);
INI_WriteInt(file,"flash_deaths",pInfo[playerid][flash_deaths]);
INI_WriteInt(file,"foff_kills",pInfo[playerid][foff_kills]);
INI_WriteInt(file,"foff_deaths",pInfo[playerid][foff_deaths]);
INI_WriteInt(file,"Weapons_kit",pInfo[playerid][Weapons_kit]);
INI_WriteInt(file,"fighting",pInfo[playerid][fighting]);
INI_WriteInt(file,"MoneyBag_Founded",pInfo[playerid][MoneyBag_Founded]);
INI_Close(file);//Now after we've done saving their data, we now need to close the file
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,24);
new str[120];
format(str,sizeof(str),"<SAVED> Stats for account: %s(%d) has been saved successfully.", playername, playerid);
print(str);
print("SAVING CALLED");
}
onplayerdisconnect after ^^
Code:
pInfo[playerid][Adminlevel] =0;
pInfo[playerid][VIPlevel] =0;
pInfo[playerid][Money] =0;
pInfo[playerid][Scores] =0;
pInfo[playerid][Kills] =0;
pInfo[playerid][Deaths] =0;
pInfo[playerid][Pills] =1;
pInfo[playerid][Savedskin] =-1;
warns[playerid] =0;
pInfo[playerid][Last] = -1;
pInfo[playerid][NoPM] = 0;
pInfo[playerid][Drugs] = -1;
pInfo[playerid][belt] = -1;
pInfo[playerid][Jailed] = -1;
pInfo[playerid][ad] = 1;
pInfo[playerid][raped] = -1;
pInfo[playerid][gotraped] = -1;
pInfo[playerid][rape_kills] = -1;
pInfo[playerid][rape_deaths] = -1;
pInfo[playerid][flash] = -1;
pInfo[playerid][flash_kills] = -1;
pInfo[playerid][flash_deaths] = -1;
pInfo[playerid][foff_kills] = -1;
pInfo[playerid][foff_deaths] = -1;
pInfo[playerid][Weapons_kit] = -1;
pInfo[playerid][fighting] = -1;
pInfo[playerid][MoneyBag_Founded] = -1;
Code:
public AUTO_SAVE(playerid)
{
if(playerid == INVALID_PLAYER_ID || !IsPlayerConnected(playerid)) return SCM(playerid, -1,"");
new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
GetPlayerName(playerid,name,sizeof(name)); //Get player's name
//new pname = strtolower(name);
new INI:file = INI_Open(Path(playerid)); //will open their file
INI_SetTag(file,"Players_Data");//We will set a tag inside of user's account called "Players_Data"
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
INI_WriteInt(file,"Banned",pInfo[playerid][Banned]);
INI_WriteInt(file,"Pills",pInfo[playerid][Pills]);
INI_WriteInt(file,"Savedskin",pInfo[playerid][Savedskin]);
INI_WriteInt(file,"Last",pInfo[playerid][Last]);
INI_WriteInt(file,"NoPM",pInfo[playerid][NoPM]);
INI_WriteInt(file,"Drugs",pInfo[playerid][Drugs]);
INI_WriteInt(file,"belt",pInfo[playerid][belt]);
INI_WriteInt(file,"Jailed",pInfo[playerid][Jailed]);
INI_WriteInt(file,"ad",pInfo[playerid][ad]);
INI_WriteInt(file,"raped",pInfo[playerid][raped]);
INI_WriteInt(file,"gotraped",pInfo[playerid][gotraped]);
INI_WriteInt(file,"rape_kills",pInfo[playerid][rape_kills]);
INI_WriteInt(file,"rape_deaths",pInfo[playerid][rape_deaths]);
INI_WriteInt(file,"flash",pInfo[playerid][flash]);
INI_WriteInt(file,"flash_kills",pInfo[playerid][flash_kills]);
INI_WriteInt(file,"flash_deaths",pInfo[playerid][flash_deaths]);
INI_WriteInt(file,"foff_kills",pInfo[playerid][foff_kills]);
INI_WriteInt(file,"foff_deaths",pInfo[playerid][foff_deaths]);
INI_WriteInt(file,"Weapons_kit",pInfo[playerid][Weapons_kit]);
INI_WriteInt(file,"fighting",pInfo[playerid][fighting]);
INI_WriteInt(file,"MoneyBag_Founded",pInfo[playerid][MoneyBag_Founded]);
INI_Close(file);//Now after we've done saving their data, we now need to close the file
SCM(playerid, COLOR_WHITE, "Your {00B9FF}Stats {FFFFFF}Have Been Automatically {FF0015}Saved.");
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,24);
new str[120];
format(str,sizeof(str),"<AUTO - SAVED> Stats for account: %s(%d) has been saved automatically.", playername, playerid);
print(str);
return 1;
}
idk why i somethime get -1 when i see stats
and mostly all stats got reset