Making Weapon and Ammo difference
#1

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?
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply
#5

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.
Reply
#6

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.
Reply
#7

Yuryfury please, can you give me the Input Dialog based code?
Reply
#8

Deviant96 go to the SAMP Wiki and search. Then learn the scripting
Reply
#9

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?
Reply
#10

Thanks Yuryfury

PHP код:
new DesertEagle[MAX_PLAYERS];
CMD:buydeagle(playeridparams[])
{
    
DesertEagle[playerid]=1;
    
SendClientMessage(playerid,COLOR_RED,"You bought Desert Eagle.");
    
GivePlayerMoney(playerid,-2000);
    return 
1;
}
CMD:buyammo(playeridparams[])
{
    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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)