[HELP PLEASE] Weapon System
#1

Okay I got that problem, I made a weapon system with bullets, and the thing I wanna do is that if a player is already holding a class of weapon, he can't purchase another weapon of the same class. For example, I purchased a Shotgun, and if I want to purchase a Spas12 while holding the shotgun, I want it to forbid it and tell "You are already carrying a weapon in that slot ". I want this to avoid people buying shotguns for cheap and get many bullets, then go buy only one Spas12 so they have lots of spas bullets for cheap.

Here is the spas12 code part:

Код:
if (strcmp("/createspas12", cmdtext, true, 10) == 0)
	{
		if(IsPlayerInRangeOfPoint(playerid,10,848.5450,-1360.4960,13.5469))//Spas12
	           {
                        if(GetPlayerMoney(playerid) < 22500) return SendClientMessage(playerid, 0xAFAFAFAA, "You don't have enough cash to create that weapon.");
                        GivePlayerWeapon(playerid, 27, 60);
                        PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-22500;
                        GivePlayerMoney(playerid, -22500);
                        SendClientMessage(playerid,0xFF9900AA,"You have created a brand new {FF6347}Combat Shotgun {FF9900}for 22500$");
                        ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
                        return 1;
                   }
                   else return SendClientMessage(playerid, 0xAFAFAFAA, "You are not near the High Armory Depot !");
         }
Reply
#2

pawn Код:
if (strcmp("/createspas12", cmdtext, true, 10) == 0)
{
        if(IsPlayerInRangeOfPoint(playerid,10,848.5450,-1360.4960,13.5469))//Spas12
        {
            if(!GetPlayerWeaponData(playerid, 3))
            {
                if(GetPlayerMoney(playerid) < 22500) return SendClientMessage(playerid, 0xAFAFAFAA, "You don't have enough cash to create that weapon.");
                GivePlayerWeapon(playerid, 27, 60);
                PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-22500;
                GivePlayerMoney(playerid, -22500);
                SendClientMessage(playerid,0xFF9900AA,"You have created a brand new {FF6347}Combat Shotgun {FF9900}for 22500$");
                ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
                return 1;
            }
            else return SendClientMessage(playerid, 0xAFAFAFAA, "You are already carrying a weapon in that slot");
        }
        else return SendClientMessage(playerid, 0xAFAFAFAA, "You are not near the High Armory Depot !");
}
Reply
#3

I'll try.
Reply
#4

Код:
C:\Users\Chaccour\Desktop\Work\filterscripts\eurp6.pwn(20366) : warning 202: number of arguments does not match definition
C:\Users\Chaccour\Desktop\Work\filterscripts\eurp6.pwn(20366) : warning 202: number of arguments does not match definition



Line 20366 is the " if(!GetPlayerWeaponData(playerid, 3)) "

But thanks I tested it works, just got the warnings.
Reply
#5

pawn Код:
if (strcmp("/createspas12", cmdtext, true, 10) == 0)
{
        if(IsPlayerInRangeOfPoint(playerid,10,848.5450,-1360.4960,13.5469))//Spas12
        {
            new weapons[2];
            GetPlayerWeaponData(playerid, 3, weapons[0], weapons[1]);
            if(weapons[0] == 0)
            {
                if(GetPlayerMoney(playerid) < 22500) return SendClientMessage(playerid, 0xAFAFAFAA, "You don't have enough cash to create that weapon.");
                GivePlayerWeapon(playerid, 27, 60);
                PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-22500;
                GivePlayerMoney(playerid, -22500);
                SendClientMessage(playerid,0xFF9900AA,"You have created a brand new {FF6347}Combat Shotgun {FF9900}for 22500$");
                ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
                return 1;
            }
            else return SendClientMessage(playerid, 0xAFAFAFAA, "You are already carrying a weapon in that slot");
        }
        else return SendClientMessage(playerid, 0xAFAFAFAA, "You are not near the High Armory Depot !");
}
Try that.
Reply
#6

Thanks man, works perfectly.

Another thing, how can I make the weapon save when I quit the game, so when I come back I still have it in hand?
Reply
#7

Also that:

Код:
if (strcmp("/createspas12", cmdtext, true, 10) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid,10,848.5450,-1360.4960,13.5469))//Spas12
        {
            new weapons[2];
            GetPlayerWeaponData(playerid, 3, weapons[0], weapons[1]);
            if(weapons[0] != 0)
            {
                if(GetPlayerMoney(playerid) < 22500) return SendClientMessage(playerid, 0xAFAFAFAA, "You don't have enough cash to create that weapon.");
                GivePlayerWeapon(playerid, 27, 60);
                PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-22500;
                GivePlayerMoney(playerid, -22500);
                SendClientMessage(playerid,0xFF9900AA,"You have created a brand new {FF6347}Combat Shotgun {FF9900}for 22500$");
                ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
                return 1;
            }
            else return SendClientMessage(playerid, 0xAFAFAFAA, "You are already carrying a weapon in that slot");
        }
        else return SendClientMessage(playerid, 0xAFAFAFAA, "You are not near the High Armory Depot !");
    }
    if (strcmp("/createsniper", cmdtext, true, 10) == 0)
	{
		if(IsPlayerInRangeOfPoint(playerid,10,848.5450,-1360.4960,13.5469))//Sniper
		{
             new weapons[2];
             GetPlayerWeaponData(playerid, 6, weapons[0], weapons[1]);
             if(weapons[0] != 0)
             {
                if(GetPlayerMoney(playerid) < 22500) return SendClientMessage(playerid, 0xAFAFAFAA, "You don't have enough cash to create that weapon.");
                GivePlayerWeapon(playerid, 34, 50);
                PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-22500;
                GivePlayerMoney(playerid, -22500);
                SendClientMessage(playerid,0xFF9900AA,"You have have created a brand new {FF6347}Sniper Rifle {FF9900}for 22500$");
                ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
                return 1;
             }
             else return SendClientMessage(playerid, 0xAFAFAFAA, "You are already carrying a weapon in that slot");
		}
		else return SendClientMessage(playerid, 0xAFAFAFAA, "You are not near the High Armory Depot !");
    }
I copied the same you made but with sniper, it didnt work, what do I have to modify each time I wanna do it for another weapon?
Reply
#8

You could try

pawn Код:
if(weapons[0] != 6)
{

}
Reply
#9

@ [HiC]TheKiller, actually I thought it was working, but the thing is it doesn't allow me to buy the Spas12 at all now, no matter what I'm holding, even with bare hands. Can you help me please?
Reply
#10

Bump, I really need that today.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)