Help with armory
#1

I recently made a dialog with armory for the police in my RP server, Now i am wondering how i could make this so you need to refill the armory?
Here is the command, please show me where and what to put in it in order to make it "not infinite" example truckers can deliver weapons and armour and medics can deliver medical kit.
pawn Код:
if(strcmp(cmd, "/armory", true) == 0)// By Tyler Acres
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInRangeOfPoint(playerid, 6, 233.5504,124.9487,1003.2188) || IsPlayerInRangeOfPoint(playerid, 6,1456.9180,-1761.4631,3285.2859))
            {
                if(PlayerInfo[playerid][pMember] != 1 && PlayerInfo[playerid][pLeader] != 1) return SendClientMessage(playerid,COLOR_GREY,"** You are not in SAPD!");
                else if (PlayerInfo[playerid][pDuty] == 0) return SendClientMessage(playerid,COLOR_GREY,"** You are NOT on duty!");
               
                new pdarmory[] = "1\tArmour\n2\tMedical Kit\n3\tMP5\n4\tShot Gun\n5\tRiot Shield";
                ShowPlayerDialog(playerid,501,DIALOG_STYLE_LIST,"SAPD Armory",pdarmory,"Select","Cancel");
                SendClientMessage(playerid, COLOR_GREY,"* REMEMBER, You may not be able to Select EVERYTHING, Each Item needs it's Specified Rank!");
                return 1;
            }
        }
        return 1;
    }
Reply
#2

I do not understand what you said. Tell me it IN COMPLETE ENGLISH
Reply
#3

Quote:
Originally Posted by California_
Посмотреть сообщение
I do not understand what you said. Tell me it IN COMPLETE ENGLISH
Made sense to me. Perhaps YOU are the problem?
Reply
#4

Quote:
Originally Posted by California_
Посмотреть сообщение
I do not understand what you said. Tell me it IN COMPLETE ENGLISH
Well then maybe now you can understand... right now you can do /armory and choose for example MP5 how many time as you want without any stop, I want it to be limited and when it is empty a trucker needs to go to some place and get some more and refill the armory with armour,MP5,Shotgun and riot shield. And if the Medical Kits goes out a medic must take some from the hospital and go deliver it to PD. You understand now?
Reply
#5

Anyone please?
Reply
#6

Well you gotta make something like

Код:
CMD:buy(playerid, params[])
{
	if(GetPlayerMoney(playerid) < 500)
	{
	    GivePlayerWeapon(playerid, 25, 100);
	    pInfo[playerid][Shotgun]++;
	}
	return 1;
}
It's just an example of how it should work.

And later on when you store it just make that pInfo[playerid][Shotgun] to be set to 0.
Reply
#7

I didnt understand that
Reply
#8

Just make a variable (enum is the best here) which will handle number of guns avaiable in the armory. Then, if player had bought weapon, variable which holds number of current weapon of type player had bought will decerase.

Still here?
Greetz,
LetsOWN
Reply
#9

Well this is my first time on this so is there any tutorial on how to make those ?
Reply
#10

Okay, I try to do a little sample armory for you.
So:

First, you must make these variables:
pawn Код:
#define DEF_MP5COUNT 10
#define DEF_AK47COUNT 15
#define DEF_M4COUNT 21
enum armassets
{
MP5,
AK47,
M4
}

new Armory[armassets];
I think you understand everything on this part.

Later on, on gamemodeinit you must assign to Armory these defined values.
It goes this way:
pawn Код:
Armory[MP5] = DEF_MP5COUNT;
Armory[AK47] = DEF_AK47COUNT;
Armory[M4] = DEF_M4COUNT;
Simple?

Your '/armory' cmd is fine, but i modified it a little for the needs of this.. Tutorial??
pawn Код:
if(strcmp(cmd, "/armory", true) == 0)// By Tyler Acres
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInRangeOfPoint(playerid, 6, 233.5504,124.9487,1003.2188) || IsPlayerInRangeOfPoint(playerid, 6,1456.9180,-1761.4631,3285.2859))
            {
                if(PlayerInfo[playerid][pMember] != 1 && PlayerInfo[playerid][pLeader] != 1) return SendClientMessage(playerid,COLOR_GREY,"** You are not in SAPD!");
                else if (PlayerInfo[playerid][pDuty] == 0) return SendClientMessage(playerid,COLOR_GREY,"** You are NOT on duty!");

                new pdarmory[] = "1\MP5\n2\AK47\n3\M4";
                ShowPlayerDialog(playerid,501,DIALOG_STYLE_LIST,"SAPD Armory",pdarmory,"Select","Cancel");
                SendClientMessage(playerid, COLOR_GREY,"* REMEMBER, You may not be able to Select EVERYTHING, Each Item needs it's Specified Rank!");
                return 1;
            }
        }
        return 1;
    }

Okay, so lets head over to event after selecting item in the dialog:

pawn Код:
if(dialogid == 501)
{
    if(listitem == 0) // mp5
    {
        if(Armory[MP5] > 0)
        {
            //give player MP5, send clinet message, whatever
            Armory[MP5]--;
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000FF, "There isnt any MP5 left.");
        }
    }
    if(listitem == 1) // AK47
    {
        if(Armory[AK47] > 0)
        {
            //give player AK47, send clinet message, whatever
            Armory[AK47]--;
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000FF, "There isnt any AK47 left.");
        }
    }
// and so on..
}
So, if player selects 1 row, then listitem equals [b]0[/0].
Then, server checks if, in this case, Armory[MP5] is greater than 0.
If yes, then you can proceed with arming player, sending him a clientmessage, whatever.
But you must deduct the value of this variable by 1.
If Armory[MP5] equals or is less than 0, then it will show send player's message, that there is not any MP5 left.
If you get used with it, you can basically do whatever you want.

I am not good at explaining, but i tried my best
Greetz,
LetsOWN
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)