[Tutorial] Loot system + inventory
#21

Quote:
Originally Posted by Immortal_LTU
View Post
Code:
LootObjects[0] = CreateObject(356, 2384.59448, -1674.36279, 13.74557,   87.72005, -23.87996, 0.00000); //M4A1
LootObjects[1] = CreateObject(355, 2409.01392, -1673.93286, 12.65986,   87.36000, -16.68000, 0.00000); //AK47
LootObjects[2] = CreateObject(358, 2362.54614, -1644.61816, 12.61388,   -101.64005, -18.41999, 0.00000); //Sniper Rifle
LootObjects[3] = CreateObject(357, 2393.15576, -1647.44202, 12.58709,   -94.92001, -69.59998, -58.37999); //Counry Rifle
LootObjects[4] = CreateObject(349, 2326.31885, -1646.21326, 13.87297,   -97.07997, -51.83994, -90.54002); //Shotgun
LootObjects[5] = CreateObject(351, 2324.06274, -1646.22961, 13.86012,   -94.55995, -61.14002, 0.00000); //Spas
LootObjects[6] = CreateObject(346, 2328.17944, -1681.76965, 13.70912,   88.20000, 23.28000, 0.00000); //9mm pistol
LootObjects[7] = CreateObject(347, 2413.82813, -1647.04639, 13.05190,   -84.78008, -118.08011, 0.00000); //9mm silenced
LootObjects[8] = CreateObject(348, 2306.93921, -1678.13745, 12.99543,   80.76003, 0.72000, 11.22000); //Desert Eagle
So these are the objects who are laying on the ground ?
Yes, those lines get the ID of the LootObject[loot id here] and then create the object with the desired object id and the co ords of where u want it to be.

check here for more info about createobject:
https://sampwiki.blast.hk/wiki/CreateObject
Reply
#22

Nice I like this.
Reply
#23

Quote:
Originally Posted by J4mmyHD
View Post
Nice I like this.
Thank you!
Reply
#24

Sorry for eventual bumping. I made myself objects and they won't let me pick them up. Even when being near them
Reply
#25

Quote:
Originally Posted by [WA]iRonan
View Post
Sorry for eventual bumping. I made myself objects and they won't let me pick them up. Even when being near them
No problem man, did you increase the MAX_LOOTS? its default 100 but if you have more loot objects than 100 you need to increase it.

and you have to be sure you have this:
pawn Code:
//example
if(IsValidObject(LootObjects[0]) && IsPlayerInRangeOfPoint(playerid,2.0,2384.59448,-1674.36279,13.74557))
Reply
#26

Quote:
Originally Posted by Voxel
View Post
No problem man, did you increase the MAX_LOOTS? its default 100 but if you have more loot objects than 100 you need to increase it.

and you have to be sure you have this:
pawn Code:
//example
if(IsValidObject(LootObjects[0]) && IsPlayerInRangeOfPoint(playerid,2.0,2384.59448,-1674.36279,13.74557))
I only have 2 loots as I'm creating more. ANd I do have that.

Code:
        if(IsValidObject(LootObjects[0]) && IsPlayerInRangeOfPoint(playerid, 10.0, 233.95, 4106.39, 5.69))
        {
            AddItem(playerid,"Beer Bottle", 1);
            SendClientMessage(playerid, -1, "* Beer bottle added to your inventory.");
            DestroyObject(LootObjects[0]);
        }
Reply
#27

And you're sure you have it on OnPlayerKeyStateChange or under a command?

May I see your callback where you have this code?
Reply
#28

Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (newkeys & KEY_WALK)
    {
        ShowInventory(playerid);
        return 1;
    }
    if (newkeys & KEY_CROUCH)
    {
        if(IsValidObject(LootObjects[0]) && IsPlayerInRangeOfPoint(playerid, 10.0, 233.95, 4106.39, 5.69))
        {
            AddItem(playerid,"Beer Bottle", 1);
            SendClientMessage(playerid, -1, "* Beer bottle added to your inventory.");
            DestroyObject(LootObjects[0]);
        }
        if(IsValidObject(LootObjects[1]) && IsPlayerInRangeOfPoint(playerid, 3.0, 233.95, 4106.39, 5.69))
        {
            AddItem(playerid,"Pork Chop", 1);
            SendClientMessage(playerid, -1, "* Pork Chop added to your inventory.");
            DestroyObject(LootObjects[1]);
        }
        else
        {
            SendClientMessage(playerid, -1, "You are not near an object.");
            return 1;
        }
    }
	return 1;
}
I know, they are both at the same position. I tried using 1 object too but it wouldn't work
Reply
#29

I think the problem is with your coordinates, the fact that they are both in the same position doesnt matter.
I noticed that your coords are not in the correct format (if you know what i mean)
pawn Code:
233.95, 4106.39, 5.69 //notice how your coords have less numbers (i have 5 numbers after the "." and you dont.

2393.15576, -1647.44202, 12.58709 //all 5 numbers behind the ".'
Did you go in game and use /save to get the coords? if not please do so. if you did that than goto your samp user files and you will find a file with your saved locations, copy the first 3 coords from there and use those.
Reply
#30

ye guy how open inventory ?
Reply
#31

Quote:
Originally Posted by Toxik
View Post
ye guy how open inventory ?
Press LALT (left alt).
Reply
#32

How would you go about dropping the objects when a player dies?
Reply
#33

Quote:
Originally Posted by Unfriendly
View Post
How would you go about dropping the objects when a player dies?
This tutorial doesnt focus on that.
Reply
#34

Ty alot bro!
Its very useful!
Reply
#35

No problem
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)