28.11.2015, 14:57
Hello!
So, I have added money feature for the server, so that players could buy weapons for money, not for EXP points, for EXP points they buy classes.
There is such thing, when you made it to evacuation point, you don't recieve 100$, but it does not show in /stats, it is still "Cash: 0" and I opened the user account file, but there is added 100$ and when I connected and spawned, my money instantly increases up to 100,000 and some other weird stuff is happening..
I will provide you the code and please tell if something is wrong:
So, I have added money feature for the server, so that players could buy weapons for money, not for EXP points, for EXP points they buy classes.
There is such thing, when you made it to evacuation point, you don't recieve 100$, but it does not show in /stats, it is still "Cash: 0" and I opened the user account file, but there is added 100$ and when I connected and spawned, my money instantly increases up to 100,000 and some other weird stuff is happening..
I will provide you the code and please tell if something is wrong:
PHP код:
enum playerinfo
{
pSpawned,
pPassword[129],
pCash,
pXP,
pKills,
pHeads,
pDeaths,
pRank,
pEvac,
pAdminLevel,
pAdminDuty,
pBanned,
BannedIP[22],
pVipLevel,
pHour,
pMin,
pSec,
pMapsPlayed,
pCoins,
pLogged,
pWarnings,
pPM,
IsPlayerMuted,
Killstreak,
pHumanClass,
pZombieClass,
IsPlayerInfected,
IsPlayerInfectedTimer,
Boxes,
BoxesAdvanced,
C4,
bombs,
pVipKickBack,
pVipFlash,
pVipBoxes,
pLadders,
pKickBackCoin,
pDamageShotgunCoin,
pDamageDeagleCoin,
pDamageMP5Coin,
pDoctorShield,
// pTerroristBomb,
Frozen,
Minigun
};
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"pCash",GetPlayerMoney(playerid));
INI_WriteInt(File,"pXP",pInfo[playerid][pXP]);
INI_WriteInt(File,"pKills",pInfo[playerid][pKills]);
INI_WriteInt(File,"pDeaths",pInfo[playerid][pDeaths]);
INI_WriteInt(File,"pHeads",pInfo[playerid][pHeads]);
INI_WriteInt(File,"pRank",pInfo[playerid][pRank]);
INI_WriteInt(File,"pEvac",pInfo[playerid][pEvac]);
INI_WriteInt(File,"pAdminLevel",pInfo[playerid][pAdminLevel]);
INI_WriteInt(File,"pAdminDuty",pInfo[playerid][pAdminDuty]);
INI_WriteInt(File,"pVipLevel",pInfo[playerid][pVipLevel]);
INI_WriteInt(File,"pHour",pInfo[playerid][pHour]);
INI_WriteInt(File,"pMin",pInfo[playerid][pMin]);
INI_WriteInt(File,"pSec",pInfo[playerid][pSec]);
INI_WriteInt(File,"pMapsPlayed",pInfo[playerid][pMapsPlayed]);
INI_WriteInt(File,"pCoins",pInfo[playerid][pCoins]);
INI_WriteInt(File,"pBanned",pInfo[playerid][pBanned]);
INI_Close(File);
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new INI:File = INI_Open(UserPath(playerid));
WP_Hash(buf, sizeof(buf), inputtext);
INI_SetTag(File,"data");
INI_WriteString(File,"pPassword", buf);
INI_WriteInt(File,"pCash",0);
INI_WriteInt(File,"pXP",0);
INI_WriteInt(File,"pKills",0);
INI_WriteInt(File,"pHeads",0);
INI_WriteInt(File,"pDeaths",0);
INI_WriteInt(File,"pRank",0);
INI_WriteInt(File,"pEvac",0);
INI_WriteInt(File,"pAdminLevel",0);
INI_WriteInt(File,"pAdminDuty",0);
INI_WriteInt(File,"pVipLevel",0);
INI_WriteInt(File,"pHour",0);
INI_WriteInt(File,"pMin",0);
INI_WriteInt(File,"pSec",0);
INI_WriteInt(File,"pMapsPlayed",0);
INI_WriteInt(File,"pCoins",0);
INI_WriteString(File,"pIP",IP);
INI_WriteInt(File,"pBanned",0);
INI_Close(File);
stock ResetVars(playerid)
{
//pInfo[playerid][pPassword] = 0;
pInfo[playerid][pCash] = 0;
pInfo[playerid][pXP] = 0;
pInfo[playerid][pKills] = 0;
pInfo[playerid][pDeaths] = 0;
pInfo[playerid][pHeads] = 0;
pInfo[playerid][pRank] = 0;
pInfo[playerid][pEvac] = 0;
pInfo[playerid][pAdminLevel] = 0;
pInfo[playerid][pAdminDuty] = 0;
pInfo[playerid][pBanned] = 0;
pInfo[playerid][pVipLevel] = 0;
pInfo[playerid][pHour] = 0;
pInfo[playerid][pMin] = 0;
pInfo[playerid][pSec] = 0;
pInfo[playerid][pMapsPlayed] = 0;
pInfo[playerid][pCoins] = 0;
pInfo[playerid][pLogged] = 0;
pInfo[playerid][pWarnings] = 0;
pInfo[playerid][pPM] = 0;
pInfo[playerid][IsPlayerMuted] = 0;
pInfo[playerid][Killstreak] = 0;
pInfo[playerid][pHumanClass] = 0;
pInfo[playerid][pZombieClass] = 0;
pInfo[playerid][IsPlayerInfected] = 0;
pInfo[playerid][Boxes] = 0;
pInfo[playerid][BoxesAdvanced] = 0;
pInfo[playerid][pVipKickBack] = 0;
pInfo[playerid][pVipFlash] = 0;
pInfo[playerid][pVipBoxes] = 0;
pInfo[playerid][pLadders] = 0;
pInfo[playerid][pKickBackCoin] = 0;
pInfo[playerid][pDamageShotgunCoin] = 0;
pInfo[playerid][pDamageDeagleCoin] = 0;
pInfo[playerid][pDamageMP5Coin] = 0;
pInfo[playerid][pDoctorShield] = 0;
Abilitys[playerid][HighJumpScout] = 0;
Abilitys[playerid][HighJumpZombie] = 0;
Abilitys[playerid][StomperPushing] = 0;
Abilitys[playerid][WitchAttack] = 0;
Abilitys[playerid][ScreamerZombieAb] = 0;
Abilitys[playerid][InfectionNormal] = 0;
Abilitys[playerid][InfectionMutated] = 0;
Abilitys[playerid][ShoutCooldown] = 0;
Abilitys[playerid][HealCoolDown] = 0;
Abilitys[playerid][ScreamerZombieAb2] = 0;
Abilitys[playerid][WitchAttack2] = 0;
Abilitys[playerid][InfectionFleshEater] = 0;
KillTimer(playedtimer[playerid]);
CurePlayer(playerid);
KillTimer(pInfo[playerid][IsPlayerInfectedTimer]);
SetPVarInt(playerid, "SPS Messages Sent", 0);
SetPVarInt(playerid, "SPS Muted", 0);
SetPVarInt(playerid, "SPS Spam Warnings", 0);
//SPS_Reset_PVars();
return 1;
stock SaveStats(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"pCash",GetPlayerMoney(playerid));
INI_WriteInt(File,"pXP",pInfo[playerid][pXP]);
INI_WriteInt(File,"pKills",pInfo[playerid][pKills]);
INI_WriteInt(File,"pDeaths",pInfo[playerid][pDeaths]);
INI_WriteInt(File,"pHeads",pInfo[playerid][pHeads]);
INI_WriteInt(File,"pRank",pInfo[playerid][pRank]);
INI_WriteInt(File,"pEvac",pInfo[playerid][pEvac]);
INI_WriteInt(File,"pAdminLevel",pInfo[playerid][pAdminLevel]);
INI_WriteInt(File,"pAdminDuty",pInfo[playerid][pAdminDuty]);
INI_WriteInt(File,"pVipLevel",pInfo[playerid][pVipLevel]);
INI_WriteInt(File,"pHour",pInfo[playerid][pHour]);
INI_WriteInt(File,"pMin",pInfo[playerid][pMin]);
INI_WriteInt(File,"pSec",pInfo[playerid][pSec]);
INI_WriteInt(File,"pMapsPlayed",pInfo[playerid][pMapsPlayed]);
INI_WriteInt(File,"pCoins",pInfo[playerid][pCoins]);
INI_WriteInt(File,"pBanned",pInfo[playerid][pBanned]);
INI_Close(File);
return 1;
}
SetPlayerMoney(playerid, cash)
{
pInfo[playerid][pCash] += cash;
GivePlayerMoney(playerid, pInfo[playerid][pCash]);
return 1;
}
CMD:stats(playerid)
{
new string[2000];
new Float:kd = floatdiv(pInfo[playerid][pKills], pInfo[playerid][pDeaths]);
new Float:wins = floatdiv(pInfo[playerid][pMapsPlayed], pInfo[playerid][pEvac]);
format(string,sizeof(string)," Viewing player stats: Yourself \n\nCash: %i\n{DC143C}Tokens{FFFFFF}: %i\n{DC143C}XP{FFFFFF}: %i\n{DC143C}Kills{FFFFFF}: %i\n{DC143C}Deaths{FFFFFF}: %i\n{DC143C}Headshots{FFFFFF}: %i\n{DC143C}Maps Played{FFFFFF}: %i\n\
{DC143C}Rank{FFFFFF}: %i\n{DC143C}Evac Points{FFFFFF}: %i\n{DC143C}Admin{FFFFFF}: %s\n{DC143C}Vip Level{FFFFFF}: %i\n\
{DC143C}Played{FFFFFF}: %d Hours || %d Minutes || %d Seconds\n{DC143C}K:D RATIO{FFFFFF}: %0.2f\n{DC143C}Win RATIO{FFFFFF}: %0.2f",
pInfo[playerid][pCash],pInfo[playerid][pCoins],pInfo[playerid][pXP],pInfo[playerid][pKills],pInfo[playerid][pDeaths],pInfo[playerid][pHeads],pInfo[playerid][pMapsPlayed],
pInfo[playerid][pRank],pInfo[playerid][pEvac],GetAdminName(playerid),pInfo[playerid][pVipLevel],pInfo[playerid][pHour],pInfo[playerid][pMin],pInfo[playerid][pSec],kd,wins);
ShowPlayerDialog(playerid,1888,DIALOG_STYLE_MSGBOX,"Viewing Stats!",string,"Close","");
return 1;
}