Making Weapon and Ammo difference -
Deviant96 - 23.04.2012
Hello guys, i need your help.
I'm in the making of RolePlay server. I thought it's better to have the gun difference with ammo.
So if player bought gun they wouldn't receive ammo. If player bought ammo they wouldn't receive weapon.
Please tell me how?
Re: Making Weapon and Ammo difference -
Yuryfury - 23.04.2012
pawn Код:
#include <a_samp>
new DesertEagle[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/buydeagle", cmdtext, true, 10) == 0)
{
DesertEagle[playerid]=1;
return 1;
}
if (strcmp("/buyammo", cmdtext, true, 10) == 0)
{
if(GetPlayerWeapon(playerid)==24||DesertEagle[playerid]==1)
{
GivePlayerWeapon(playerid,24,100);
}
return 1;
}
return 0;
}
Look over it, understand it, modify it, improve it.
Re: Making Weapon and Ammo difference -
MP2 - 23.04.2012
You don't want to do
100+GetPlayerAmmo(playerid));
Because that will add 100 AND double their ammo, just give 100 and it will add 100.
Re: Making Weapon and Ammo difference -
Yuryfury - 23.04.2012
Quote:
Originally Posted by MP2
You don't want to do
100+GetPlayerAmmo(playerid));
Because that will add 100 AND double their ammo, just give 100 and it will add 100.
|
Ah, good catch. Modified the code. Thanks.
Re: Making Weapon and Ammo difference -
MP2 - 23.04.2012
Also, you only need one line:
GivePlayerWeapon(playerid, GetPlayerWeapon(playerid), 100);
If I were you I'd make an array with two values - min. ammo and price. i.e. deagle has 7 ammo, /buyammo should give you 7 ammo and you should set a price for that.
Re: Making Weapon and Ammo difference -
Yuryfury - 23.04.2012
Quote:
Originally Posted by MP2
Also, you only need one line:
GivePlayerWeapon(playerid, GetPlayerWeapon(playerid), 100);
If I were you I'd make an array with two values - min. ammo and price. i.e. deagle has 7 ammo, /buyammo should give you 7 ammo and you should set a price for that.
|
Ideally yes, but it would be hard to explain to a beginner and I don't want people to think that asking for help leads to a personalized script. You start by scripting a basic array then progress to large arrays or enumerations. That's how I did it.
Re: Making Weapon and Ammo difference -
Deviant96 - 23.04.2012
Yuryfury please, can you give me the Input Dialog based code?
Re: Making Weapon and Ammo difference -
MrEnd - 23.04.2012
Deviant96 go to the
SAMP Wiki and search. Then learn the scripting
Re: Making Weapon and Ammo difference -
Ballu Miaa - 23.04.2012
Quote:
Originally Posted by MrEnd
Deviant96 go to the SAMP Wiki and search. Then learn the scripting
|
Boy. Even Earth tells us to learn from anything. Human race learned the basic survival on this planet. We are here for help if anyway we can. SAMP Wiki its just a guide with few instructions. You will never get the Advance Pawno Scripting with it. And You're not making your ancestors proud of yourself , Respect The Learners mate and the same goes for everyone.
@Deviant - All that is enough for you mate?
Re: Making Weapon and Ammo difference -
Deviant96 - 23.04.2012
Thanks Yuryfury
PHP код:
new DesertEagle[MAX_PLAYERS];
CMD:buydeagle(playerid, params[])
{
DesertEagle[playerid]=1;
SendClientMessage(playerid,COLOR_RED,"You bought Desert Eagle.");
GivePlayerMoney(playerid,-2000);
return 1;
}
CMD:buyammo(playerid, params[])
{
if(GetPlayerWeapon(playerid)==24||DesertEagle[playerid]==1)
{
GivePlayerWeapon(playerid,24,7);
GivePlayerMoney(playerid,-100);
SendClientMessage(playerid,COLOR_RED,"You bought 1 pack ammo of Desert Eagle.");
}
else SendClientMessage(playerid,COLOR_RED,"You don't have Desert Eagle!");
return 1;
}
@Ballu Mia yap, you're the best