08.06.2011, 20:46
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
To Take Out
Here is the code for the money
To Put In
To Take Out
Any help is greatly appreciated!
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;
}
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;
}
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;
}
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;
}