Help with briefcase system
#1

I am currently working on a briefcase system. In the briefcase you can store money, drugs and a gun.

What I need help with is how to make it so that when I click to put a gun into my inventory, that it takes the gun out of my hand and puts it into the inventory with the ammo and when I click to get it back it will give me that same gun with the same ammount of ammo.

I also need help with putting money in. When I put in the money I want it to take all the money I have and transfer it to my briefcase and when I click to take it back it will show a ShowPlayerDialog input dialog to ask how much money you want to take out.

Here is my code for the guns
To Put In
pawn Code:
case 2:
            {
                if(GetPlayerWeapon(playerid) == 0)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"You do not have any weapons to add to your Briefcase.");
                    return 1;
                }
                if(IsSpawned[playerid] != 1)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned to use your Briefcase.");
                    return 1;
                }
                SendClientMessage(playerid,COLOR_GREEN,"You have added a weapon into your Briefcase.");
                new wname[24];
                HasPackWeapon[playerid] +=GetPlayerWeapon(playerid);
                GetWeaponName(GetPlayerWeapon(playerid),wname,sizeof(wname));
                ResetPlayerWeapons(playerid,GetPlayerWeapon(playerid));
                return 1;
            }
To Take Out
pawn Code:
case 5:
            {
                if(HasPackWeapon[playerid] == 0)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"You do not have weapons to remove from your Briefcase.");
                    return 1;
                }
                if(IsSpawned[playerid] != 1)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned to use your Briefcase.");
                    return 1;
                }
                SendClientMessage(playerid,COLOR_GREEN,"You have taken a weapon from your Briefcase.");
                GivePlayerWeapon(playerid,HasPackWeapon[playerid]);
                HasPackWeapon[playerid] -=GetPlayerWeapon(playerid);
                return 1;
            }
Here is the code for the money
To Put In
pawn Code:
case 0:
            {
                if(GetPlayerMoney(playerid) <= 0)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"You do not have any Money to add to your Briefcase.");
                    return 1;
                }
                if(IsSpawned[playerid] != 1)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned to use your Briefcase.");
                    return 1;
                }
                new total =HasPackMoney[playerid] + GetPlayerMoney(playerid);
                if(total > 2000000)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"Your Briefcase cannot hold more than $2 Million. Put some in the bank.");
                    return 1;
                }
                SendClientMessage(playerid, COLOR_GREEN, "You have put all your money inside the Briefcase.");
                HasPackMoney[playerid] +=GetPlayerMoney(playerid);
                GivePlayerMoney(playerid,-GetPlayerMoney(playerid));
                return 1;
            }
To Take Out
pawn Code:
case 3:
            {
                if(HasPackMoney[playerid] == 0)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"You do not have any Money in your Briefcase.");
                    return 1;
                }
                if(IsSpawned[playerid] != 1)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned to use your Briefcase.");
                    return 1;
                }
                new total =HasPackMoney[playerid] + GetPlayerMoney(playerid);
                if(total > 250000)
                {
                    SendClientMessage(playerid,COLOR_ERROR,"You must put some money in your bank before getting out of your Briefcase.");
                }
                else
                {
                    GivePlayerMoney(playerid,HasPackMoney[playerid]);
                    HasPackMoney[playerid] -=GetPlayerMoney(playerid);
                }
                return 1;
            }
Any help is greatly appreciated!
Reply
#2

pawn Code:
HasPackWeapon[playerid] +=GetPlayerWeapon(playerid);
Ehr, that's weird. I understand what you're trying to do here, but it won't work like that. Suppose you have a baseball bat (id 5) and a pistol (id 22) in there. You'll end with a value of 27 for HasPackWeapon. Now, how will you decide which weapon to take out? There might as well be a silenced pistol (id 23) and a knife (id 4) in there.
Reply
#3

What I am saying is, when I press Put Weapon in, it will take the weapon i have in my hand and place it into the briefcase. What happens is when I try that it takes all of my weapons away instead of the one that I have in my hand.
Reply
#4

Quote:
Originally Posted by PCheriyan007
View Post
What I am saying is, when I press Put Weapon in, it will take the weapon i have in my hand and place it into the briefcase. What happens is when I try that it takes all of my weapons away instead of the one that I have in my hand.
You used ResetPlayerWeapons which actually removes all your weapons

Search for ResetPlayerWeapon (without s) [thats not a native]
Or you use SetPlayerAmmo which is easier

This will fix that but you should read Vince's reply again which states an important problem in your code
Reply
#5

I've got it working perfectly now, thanks for all of the help guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)