SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 25/10/2013, 04:06 PM   #21
Immortal_LTU
Big Clucker
 
Join Date: Feb 2011
Location: Lithuania
Posts: 123
Reputation: 1
Default Re: Loot system + inventory

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 ?
Immortal_LTU is offline   Reply With Quote
Old 26/10/2013, 08:28 AM   #22
Voxel
Gangsta
 
Voxel's Avatar
 
Join Date: Sep 2013
Location: The Netherlands
Posts: 580
Reputation: 70
Default Re: Loot system + inventory

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:
http://wiki.sa-mp.com/wiki/CreateObject
__________________
My Work:
[GameMode]The Nether Survival
[Filterscript]SQLite Database Start
[Tutorial]SQLite Commands
[Tutorial]Loot/ Inventory System
[Tutorial]Simple Hunger/Thirst System
[Tutorial]Converting Binary
[Map]Tropical Island + Pier
[Map]San Fierro Apocalypse
Voxel is offline   Reply With Quote
Old 18/11/2013, 08:54 PM   #23
J4mmyHD
Huge Clucker
 
J4mmyHD's Avatar
 
Join Date: Oct 2012
Location: United Kingdom
Posts: 274
Reputation: 42
Default Re: Loot system + inventory

Nice I like this.
__________________
J4mmyHD is offline   Reply With Quote
Old 19/11/2013, 04:41 PM   #24
Voxel
Gangsta
 
Voxel's Avatar
 
Join Date: Sep 2013
Location: The Netherlands
Posts: 580
Reputation: 70
Default Re: Loot system + inventory

Quote:
Originally Posted by J4mmyHD View Post
Nice I like this.
Thank you!
__________________
My Work:
[GameMode]The Nether Survival
[Filterscript]SQLite Database Start
[Tutorial]SQLite Commands
[Tutorial]Loot/ Inventory System
[Tutorial]Simple Hunger/Thirst System
[Tutorial]Converting Binary
[Map]Tropical Island + Pier
[Map]San Fierro Apocalypse
Voxel is offline   Reply With Quote
Old 01/12/2013, 03:18 PM   #25
[WA]iRonan
Huge Clucker
 
Join Date: May 2012
Location: A box in the sea
Posts: 446
Reputation: 101
Default Re: Loot system + inventory

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



Save Our Souls - A SAMP Survival Server - 151.236.29.108:7960
[WA]iRonan is offline   Reply With Quote
Old 01/12/2013, 04:50 PM   #26
Voxel
Gangsta
 
Voxel's Avatar
 
Join Date: Sep 2013
Location: The Netherlands
Posts: 580
Reputation: 70
Default Re: Loot system + inventory

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))
__________________
My Work:
[GameMode]The Nether Survival
[Filterscript]SQLite Database Start
[Tutorial]SQLite Commands
[Tutorial]Loot/ Inventory System
[Tutorial]Simple Hunger/Thirst System
[Tutorial]Converting Binary
[Map]Tropical Island + Pier
[Map]San Fierro Apocalypse
Voxel is offline   Reply With Quote
Old 02/12/2013, 05:33 PM   #27
[WA]iRonan
Huge Clucker
 
Join Date: May 2012
Location: A box in the sea
Posts: 446
Reputation: 101
Default Re: Loot system + inventory

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]);
        }
__________________



Save Our Souls - A SAMP Survival Server - 151.236.29.108:7960
[WA]iRonan is offline   Reply With Quote
Old 02/12/2013, 08:14 PM   #28
Voxel
Gangsta
 
Voxel's Avatar
 
Join Date: Sep 2013
Location: The Netherlands
Posts: 580
Reputation: 70
Default Re: Loot system + inventory

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

May I see your callback where you have this code?
__________________
My Work:
[GameMode]The Nether Survival
[Filterscript]SQLite Database Start
[Tutorial]SQLite Commands
[Tutorial]Loot/ Inventory System
[Tutorial]Simple Hunger/Thirst System
[Tutorial]Converting Binary
[Map]Tropical Island + Pier
[Map]San Fierro Apocalypse
Voxel is offline   Reply With Quote
Old 03/12/2013, 12:42 PM   #29
[WA]iRonan
Huge Clucker
 
Join Date: May 2012
Location: A box in the sea
Posts: 446
Reputation: 101
Default Re: Loot system + inventory

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
__________________



Save Our Souls - A SAMP Survival Server - 151.236.29.108:7960
[WA]iRonan is offline   Reply With Quote
Old 03/12/2013, 01:33 PM   #30
Voxel
Gangsta
 
Voxel's Avatar
 
Join Date: Sep 2013
Location: The Netherlands
Posts: 580
Reputation: 70
Default Re: Loot system + inventory

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.
__________________
My Work:
[GameMode]The Nether Survival
[Filterscript]SQLite Database Start
[Tutorial]SQLite Commands
[Tutorial]Loot/ Inventory System
[Tutorial]Simple Hunger/Thirst System
[Tutorial]Converting Binary
[Map]Tropical Island + Pier
[Map]San Fierro Apocalypse
Voxel is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
loot system Legend_Of_War Scripting Help 2 15/08/2013 03:05 AM
How does a loot system works? CrazyChoco Scripting Help 5 05/06/2013 10:57 AM
Loot system. iHaze. Scripting Help 7 30/03/2013 11:40 AM
Loot System Kitten Scripting Help 0 16/01/2013 02:45 AM


All times are GMT. The time now is 07:40 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.