Trunk system
#10

Anyone please? this is storing weapons in EVERY vehicle so I can take if from any car I want.. here is the code you might need to help me with fixing that problem:

What I want to make is.. the weapon I store it will be stored in car I'm standing at (I'm not using this code INSIDE of vehicle I'm using code if I'm near trunk.. -outside of vehicle) so weapons will be stored only at that car and I won't be able to take them out from another car, help me to figure out with this please ^^

pawn Код:
enum Trunk
{
    tWeapon1,
    tWeapon2,
    tWeapon3,
    tWeapon4,
    tWeapon5,
    tAmmo1,
    tAmmo2,
    tAmmo3,
    tAmmo4,
    tAmmo5
};
new iTrunk[MAX_VEHICLES][Trunk];
If player will choose "put in trunk" option
pawn Код:
if(listitem == 1) // Put in trunk
            {
                for(new i; i<MAX_VEHICLES; i++)
                {
                    new vehicleid = GetPlayerVehicleID(playerid);
                    new Float: vx, Float:vy, Float:vz;
                    new e, l, a, d, b, bo, o;
                    GetVehicleParamsEx(i,e,l,a,d,b,bo,o);
                    GetVehiclePos(i,vx,vy,vz);
                    GetXYBehindCar(i, vx, vy, 2.5);
                    if(IsPlayerInRangeOfPoint(playerid,2.5,vx,vy,vz))
                    {
                        if(bo > 0)
                        {
                            new tstr[255];
                            format(tstr, sizeof(tstr), "Slot 1 - %s (%d)\nSlot 2 - %s (%d)\nSlot 3 - %s (%d)\nSlot 4 - %s (%d)\nSlot 5 - %s (%d)", GetGunName(iTrunk[vehicleid][tWeapon1]),iTrunk[vehicleid][tAmmo1], GetGunName(iTrunk[vehicleid][tWeapon2]),iTrunk[vehicleid][tAmmo2], GetGunName(iTrunk[vehicleid][tWeapon3]),iTrunk[vehicleid][tAmmo3], GetGunName(iTrunk[vehicleid][tWeapon4]),iTrunk[vehicleid][tAmmo4],GetGunName(iTrunk[vehicleid][tWeapon5]),iTrunk[vehicleid][tAmmo5]);
                            ShowPlayerDialog(playerid, DIALOG_PUT, DIALOG_STYLE_LIST, "Store a weapon", tstr, "Select", "Cancel");
                            return 1;
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_RED,"{00FF00}INFO: {FFFFFF} Open it first.");
                            return 1;
                        }
                    }
                }
            }
If player will choose take from trunk option
pawn Код:
if(listitem == 2) // Take from trunk
            {
                for(new i; i<MAX_VEHICLES; i++)
                {
                    new vehicleid = GetPlayerVehicleID(playerid);
                    new Float: vx, Float:vy, Float:vz;
                    new e, l, a, d, b, bo, o;
                    GetVehicleParamsEx(i,e,l,a,d,b,bo,o);
                    GetVehiclePos(i,vx,vy,vz);
                    GetXYBehindCar(i, vx, vy, 2.5);
                    if(IsPlayerInRangeOfPoint(playerid,2.5,vx,vy,vz))
                    {
                        if(bo > 0)
                        {
                            new tstr[255];
                            format(tstr, sizeof(tstr), "Slot 1 - %s (%d)\nSlot 2 - %s (%d)\nSlot 3 - %s (%d)\nSlot 4 - %s (%d)\nSlot 5 - %s (%d)", GetGunName(iTrunk[vehicleid][tWeapon1]),iTrunk[vehicleid][tAmmo1], GetGunName(iTrunk[vehicleid][tWeapon2]),iTrunk[vehicleid][tAmmo2], GetGunName(iTrunk[vehicleid][tWeapon3]),iTrunk[vehicleid][tAmmo3], GetGunName(iTrunk[vehicleid][tWeapon4]),iTrunk[vehicleid][tAmmo4],GetGunName(iTrunk[vehicleid][tWeapon5]),iTrunk[vehicleid][tAmmo5]);
                            ShowPlayerDialog(playerid, DIALOG_TAKE, DIALOG_STYLE_LIST, "Take A Weapon", tstr, "Select", "Cancel");
                            return 1;
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_RED,"{00FF00}INFO: {FFFFFF} Open it before putting something in it1");
                            return 1;
                        }
                    }
                }
            }
        }
        return 1;
    }
PUT in trunk and TAKE from trunk dialogs and functions ...
pawn Код:
if(dialogid == DIALOG_PUT) // Put items in trunk
    {
        new gunID = GetPlayerWeapon(playerid);
        if(gunID == 0) return SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} You need to have weapon in your hands.");
        new gunAmmo = GetPlayerAmmo(playerid);
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == INVALID_VEHICLE_ID) return 1;
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    if(iTrunk[vehicleid][tWeapon1] != 0 && iTrunk[vehicleid][tAmmo1] != 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is already used!");
                        return 1;
                    }
                    iTrunk[vehicleid][tWeapon1] = gunID;
                    iTrunk[vehicleid][tAmmo1] = gunAmmo;
                }
                case 1:
                {
                    if(iTrunk[vehicleid][tWeapon2] != 0 && iTrunk[vehicleid][tAmmo2] != 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is already used!");
                        return 1;
                    }
                    iTrunk[vehicleid][tWeapon2] = gunID;
                    iTrunk[vehicleid][tAmmo2] = gunAmmo;
                }
                case 2:
                {
                    if(iTrunk[vehicleid][tWeapon3] != 0 && iTrunk[vehicleid][tAmmo3] != 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is already used!");
                        return 1;
                    }
                    iTrunk[vehicleid][tWeapon3] = gunID;
                    iTrunk[vehicleid][tAmmo3] = gunAmmo;
                }
                case 3:
                {
                    if(iTrunk[vehicleid][tWeapon4] !=0 && iTrunk[vehicleid][tAmmo4] != 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is already used!");
                        return 1;
                    }
                    iTrunk[vehicleid][tWeapon4] = gunID;
                    iTrunk[vehicleid][tAmmo4] = gunAmmo;
                }
                case 4:
                {
                    if(iTrunk[vehicleid][tWeapon5] != 0 && iTrunk[vehicleid][tAmmo5] != 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is already used!");
                        return 1;
                    }
                    iTrunk[vehicleid][tWeapon5] = gunID;
                    iTrunk[vehicleid][tAmmo5] = gunAmmo;
                }
            }
            RemovePlayerWeapon(playerid, gunID);
        }
        return 1;
    }

    if(dialogid == DIALOG_TAKE) // Take items from trunk
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == INVALID_VEHICLE_ID) return 1;
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    if(iTrunk[vehicleid][tWeapon1] == 0 && iTrunk[vehicleid][tAmmo1] == 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is empty!");
                        return 1;
                    }
                    GivePlayerWeapon(playerid, iTrunk[vehicleid][tWeapon1], iTrunk[vehicleid][tAmmo1]);
                    iTrunk[vehicleid][tWeapon1] = 0;
                    iTrunk[vehicleid][tAmmo1] = 0;
                }
                case 1:
                {
                    if(iTrunk[vehicleid][tWeapon2] == 0 && iTrunk[vehicleid][tAmmo2] == 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is empty!");
                        return 1;
                    }
                    GivePlayerWeapon(playerid, iTrunk[vehicleid][tWeapon2], iTrunk[vehicleid][tAmmo2]);
                    iTrunk[vehicleid][tWeapon2] = 0;
                    iTrunk[vehicleid][tAmmo2] = 0;
                }
                case 2:
                {
                    if(iTrunk[vehicleid][tWeapon3] == 0 && iTrunk[vehicleid][tAmmo3] == 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is empty!");
                        return 1;
                    }
                    GivePlayerWeapon(playerid, iTrunk[vehicleid][tWeapon3], iTrunk[vehicleid][tAmmo3]);
                    iTrunk[vehicleid][tWeapon3] = 0;
                    iTrunk[vehicleid][tAmmo3] = 0;
                }
                case 3:
                {
                    if(iTrunk[vehicleid][tWeapon4] == 0 && iTrunk[vehicleid][tAmmo4] == 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is empty!");
                        return 1;
                    }
                    GivePlayerWeapon(playerid, iTrunk[vehicleid][tWeapon4], iTrunk[vehicleid][tAmmo4]);
                    iTrunk[vehicleid][tWeapon4] = 0;
                    iTrunk[vehicleid][tAmmo4] = 0;
                }
                case 4:
                {
                    if(iTrunk[vehicleid][tWeapon5] == 0 && iTrunk[vehicleid][tAmmo5] == 0)
                    {
                        SendClientMessage(playerid, -1,"{00FF00}INFO: {FFFFFF} This slot is empty!");
                        return 1;
                    }
                    GivePlayerWeapon(playerid, iTrunk[vehicleid][tWeapon5], iTrunk[vehicleid][tAmmo5]);
                    iTrunk[vehicleid][tWeapon5] = 0;
                    iTrunk[vehicleid][tAmmo5] = 0;
                }
            }
        }
        return 1;
    }
Rep+ for helpers, Thanks for help in advance
Reply


Messages In This Thread
Trunk system - by Lajko1 - 16.02.2014, 14:30
Re: Trunk system - by Lajko1 - 16.02.2014, 20:29
Re: Trunk system - by Lajko1 - 16.02.2014, 20:31
Re: Trunk system - by Lajko1 - 16.02.2014, 21:51
Re: Trunk system - by Jimmy0wns - 16.02.2014, 21:53
Re: Trunk system - by Lajko1 - 16.02.2014, 22:04
Re: Trunk system - by JJB562 - 16.02.2014, 22:39
Re: Trunk system - by Threshold - 17.02.2014, 00:46
Re: Trunk system - by Lajko1 - 17.02.2014, 13:34
Re: Trunk system - by Lajko1 - 17.02.2014, 19:28

Forum Jump:


Users browsing this thread: 1 Guest(s)