Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: KAKAN on Sep 19, 2015, 06:20 AM

Title: Cash error
Post by: KAKAN on Sep 19, 2015, 06:20 AM
I use a array for cash which is:- stats[ player.ID ].Cash
Now when I do, stats[player.ID].Cash += 200;
Its 200, but the player.Cash is not getting updated, what to do?
If i use player.Cash, its not getting updated, so what shall i do now?
How to ensure that player.Cash = stats[ player.ID ].Cash, don't say me to change it, I have added it on many things
Title: Re: Cash error
Post by: FinchDon on Sep 19, 2015, 06:27 AM
probably yes you need to change it First time this error also occur on my script you must use

player.Cash = stats[ player.ID ].Cash;
Title: Re: Cash error
Post by: KAKAN on Sep 19, 2015, 06:31 AM
So where shall I add it?, and yes for sure you haven't read the whole topic
Title: Re: Cash error
Post by: DizzasTeR on Sep 19, 2015, 07:19 AM
Just set player.Cash = pstats Cash when a player logins, then use player.Cash to increase, decrease or condition something. Do not use the pstats Cash. When the player leaves set player.Cash = pstats Cash.

I hope you got the point.
Title: Re: Cash error
Post by: KAKAN on Sep 19, 2015, 07:20 AM
I know that, I have done stats cash everywhere(about 19 times), and I don't have time to edit that, anyways your trick is good, I'll surely use it!
Title: Re: Cash error
Post by: KAKAN on Sep 19, 2015, 07:51 AM
Fixed. Thanks @Doom_Killer
Title: Re: Cash error
Post by: FinchDon on Sep 19, 2015, 08:01 AM
Haha Nice Trick @Doom_Killer
Title: Re: Cash error
Post by: rObInX on Sep 19, 2015, 10:53 AM
If a player hacks and sets his cash to $xxxx, he'll have that much cash for free.

Instead use some function like AddCash( player, Cash )

Eg:

function AddCash( p, c )
{
    pstats[p.ID].Cash += c.tointeger();
    player.Cash = pstats[p.ID].Cash.tointeger();
}
Title: Re: Cash error
Post by: Thijn on Sep 19, 2015, 11:14 AM
That argument wont work, use
function AddCash( p, c )
{
    pstats[p.ID].Cash += c.tointeger();
    player.Cash = pstats[p.ID].Cash.tointeger();
}
Title: Re: Cash error
Post by: KAKAN on Sep 19, 2015, 11:40 AM
"If a player hacks and sets his cash to $xxxx, he'll have that much cash for free.

Instead use some function like AddCash( player, Cash )"
Hacking still works?
Title: Re: Cash error
Post by: rObInX on Sep 20, 2015, 08:00 AM
Quote from: KAKAN on Sep 19, 2015, 11:40 AM"If a player hacks and sets his cash to $xxxx, he'll have that much cash for free.

Instead use some function like AddCash( player, Cash )"
Hacking still works?
Nope.
Player can only set his cash, not the server side one (if you use my method).

And, thanks Thijn.
Title: Re: Cash error
Post by: KAKAN on Sep 20, 2015, 08:14 AM
Okay!