Very strange bug with money
#1

Hello,
I have very strange bug.
I'll try to explain it.
If I have $1 000 000 in my account and I deposit the money in the bank, I will have $0.
After I die I get the same amount $1 000 000, but I should have $-1000.
I think the problem is somewhere in OnPlayerDeath, so I'll give you some code.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	djSetInt("stats.json","players/died",djInt("stats.json","players/died")+1);
	pInfo[playerid][Deaths]++;
    if(killerid != INVALID_PLAYER_ID && killerid != playerid)
    {
    pInfo[killerid][Kills]++;
	}
	GivePlayerMoney(killerid, 5000);
	GivePlayerMoney(playerid, -1000);
	pInfo[playerid][Money] = GetPlayerMoney(playerid);
	SetPlayerScore(killerid, GetPlayerScore(killerid) + 5);
As far as I can see, the money is saved in the variable pInfo[playerid][Money].
When you respawn, the money is loaded from the same variable and should not be a problem, but it has, as described above.
Any ideas?
P.S. Sorry for my bad English and I hope you can understand my problem.
Reply
#2

I think the problem may be that you don't update the value of the variable when the player makes his deposit at the bank
Reply
#3

No, If I deposit the money in the bank and I exit the server, I'll have $0 when I enter the server again.
I have tested.
The problem is only with OnPlayerDeath, but I can't realize why.
Reply
#4

When you deposit your money , do you set player variable to -(that amount that you deposited) ?
Reply
#5

Yes.
Now I found something very strange.
When I load into account [BG]bobsona(which have $0), the system loads the money from account [BG]BOBSONA, which is totally different account from this.
I'm using pInfo, any ideas how to make the accounts to be case-sensitive?
Reply
#6

When you format the query you need to insert

Quote:

COLLATE NOCASE

After you use "WHERE" and the name variable.
Reply
#7

I'm not using MySQL.
I save users info in files /scriptfiles/Users/nick.ini
The operating system is Linux, which is case-sensitive.
Reply
#8

It is weird, however I can redirect you to both ******' post and a register system that uses Y_INI since I am not really good with ini files since I've never used them.

******' post: Here
System by newbienoob: Here
Reply
#9

I posted a question there, but I'm waiting for more suggestions here.
Reply
#10

Quote:
Originally Posted by bobsona
Посмотреть сообщение
Yes.
Now I found something very strange.
When I load into account [BG]bobsona(which have $0), the system loads the money from account [BG]BOBSONA, which is totally different account from this.
I'm using pInfo, any ideas how to make the accounts to be case-sensitive?
I now think that all problems come from this problem.
You want more code from OnPlayerSpawn?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)