SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 24/05/2009, 09:22 PM   #1
Byrner
Big Clucker
 
Join Date: Sep 2007
Posts: 133
Reputation: 2
Default Strange variable/player file problem

pawn Code:
BankCash[playerid] = dUserINT(PlayerName(playerid)).("bankcash");
    new MoneyInPack =dUserINT(PlayerName(playerid)).("HasPackMoney");
    BankCash[playerid] +=MoneyInPack;
    HasPackMoney[playerid]=0;

The goal of the code is to take the players money from his Backpack ... deposit it into his bank account and set the backpack amount to 0.
It does ... nothing.
I've tried a few different ways to do it, this is the most recent.

The players packback keeps the same amount and the bank account doesn't increase.

Before you ask; this IS all the code you will need. All the other code in the command would have nothing to do with this part.
This is a very strange problem; one I can't seem to figure out, any help would be appreciated.
__________________
Pretty cool SA-MP server host https://evolution-host.com/GameOffers/?game=samp
Also providing VPS Hosting: https://evolution-host.com/vps-hosting.php
Byrner is offline  
Old 24/05/2009, 09:28 PM   #2
Badger(new)
Huge Clucker
 
Badger(new)'s Avatar
 
Join Date: May 2008
Posts: 354
Reputation: 4
Default Re: Strange variable/player file problem

could you explain what some of those functions do. e.g. dUserINT
__________________
New profile- http://forum.sa-mp.com/member.php?u=170114
Badger(new) is offline  
Old 24/05/2009, 09:29 PM   #3
Weirdosport
High-roller
 
Join Date: Jul 2008
Posts: 1,293
Reputation: 0
Default Re: Strange variable/player file problem

Could you explain exactly step by step what you're trying to do on each line.

e.g., Read value from file and store to this...

Weirdosport is offline  
Old 24/05/2009, 09:42 PM   #4
Byrner
Big Clucker
 
Join Date: Sep 2007
Posts: 133
Reputation: 2
Default Re: Strange variable/player file problem

pawn Code:
BankCash[playerid] = dUserINT(PlayerName(playerid)).("bankcash");
^^ Is letting the script know that when BankCash[playerid] is used that it's to read from the playerfiles bankcash line. (bankcash is the amount the player has in his bank account.)

pawn Code:
new MoneyInPack =dUserINT(PlayerName(playerid)).("HasPackMoney");
Makes MoneyInPack read from the players HasPackMoney line. (HasPackMoney is the amount of money the player has in his backpack.)

pawn Code:
BankCash[playerid] +=MoneyInPack;
Gets the players Bank account to increase by the amount the player has in his bank account.

pawn Code:
HasPackMoney[playerid]=0;
Gets the amount in the players backpack to reset to $0.
__________________
Pretty cool SA-MP server host https://evolution-host.com/GameOffers/?game=samp
Also providing VPS Hosting: https://evolution-host.com/vps-hosting.php
Byrner is offline  
Old 24/05/2009, 09:49 PM   #5
Weirdosport
High-roller
 
Join Date: Jul 2008
Posts: 1,293
Reputation: 0
Default Re: Strange variable/player file problem

Well from what I can see you need to set the value in the DUDB file back to 0, otherwise next time you use the command it will read the same number as before.

pawn Code:
BankCash[playerid] = dUserINT(PlayerName(playerid)).("bankcash");
BankCash[playerid] += dUserINT(PlayerName(playerid)).("HasPackMoney");
dUserSetINT(PlayerName(playerid)).("HasPackMoney", 0);
Weirdosport is offline  
Old 24/05/2009, 10:03 PM   #6
Byrner
Big Clucker
 
Join Date: Sep 2007
Posts: 133
Reputation: 2
Default Re: Strange variable/player file problem

That code fixed one of the problems.
It set the backpack to 0 ... but still didn't give the player the money in his bank account.

Then this code got it working:
pawn Code:
BankCash[playerid] = dUserINT(PlayerName(playerid)).("bankcash");
    new Total = HasPackMoney[playerid] + BankCash[playerid];
    dUserSetINT(PlayerName(playerid)).("bankcash", Total);
    dUserSetINT(PlayerName(playerid)).("HasPackMoney", 0);
Thanks alot for your help m8.
__________________
Pretty cool SA-MP server host https://evolution-host.com/GameOffers/?game=samp
Also providing VPS Hosting: https://evolution-host.com/vps-hosting.php
Byrner is offline  
Old 24/05/2009, 10:52 PM   #7
Byrner
Big Clucker
 
Join Date: Sep 2007
Posts: 133
Reputation: 2
Default Re: Strange variable/player file problem

Ok, I've another similar problem now.

pawn Code:
BankCash[giveplayerid] = dUserINT(PlayerName(giveplayerid)).("bankcash");
    new Total = cashsend + BankCash[giveplayerid];
    dUserSetINT(PlayerName(giveplayerid)).("bankcash", Total);
    BankCash[giveplayerid]=Total;
    new Minus = BankCash[playerid] - cashsend;
    BankCash[playerid]=Minus;
    dUserSetINT(PlayerName(playerid)).("bankcash", Minus);
This is meant to get the 'cashsend' (The amount is set in the command) and transfer it from playerid's bank account to giveplayerid's.
Giveplayerid gets the cash ... playerid loses too much.
__________________
Pretty cool SA-MP server host https://evolution-host.com/GameOffers/?game=samp
Also providing VPS Hosting: https://evolution-host.com/vps-hosting.php
Byrner is offline  
Old 24/05/2009, 11:07 PM   #8
Weirdosport
High-roller
 
Join Date: Jul 2008
Posts: 1,293
Reputation: 0
Default Re: Strange variable/player file problem

I don't know if this'll make a different but here's a bit of a re-arrangement:

pawn Code:
BankCash[giveplayerid] = cashsend + dUserINT(PlayerName(giveplayerid)).("bankcash");
    dUserSetINT(PlayerName(giveplayerid)).("bankcash", BankCash[giveplayerid]);
    BankCash[playerid] = dUserINT(PlayerName(playerid)).("bankcash") - cashsend;
    dUserSetINT(PlayerName(playerid)).("bankcash", BankCash[playerid]);
Weirdosport is offline  
Old 24/05/2009, 11:25 PM   #9
Byrner
Big Clucker
 
Join Date: Sep 2007
Posts: 133
Reputation: 2
Default Re: Strange variable/player file problem

I already got it, thanks tho m8.
__________________
Pretty cool SA-MP server host https://evolution-host.com/GameOffers/?game=samp
Also providing VPS Hosting: https://evolution-host.com/vps-hosting.php
Byrner is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TextDraws as server variable?? How to i change to Player Variable? DarrenReeder Help Archive 2 06/04/2010 07:02 AM
Not setting a file variable to 0. jameskmonger Help Archive 4 14/01/2010 06:10 AM
Problem with dini_Get("file", variable); ronyx69 Help Archive 10 27/07/2009 04:28 PM
system32 strange file luxeon Everything and Nothing 2 01/01/2009 05:50 PM


All times are GMT. The time now is 06:21 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.