#define PRESSED(%0)
#define MAX_LOOTS 100 //the amount of loot you allow in your world
static LootObjects[MAX_LOOTS] = { INVALID_OBJECT_ID, ... }; //if theres a invalid object
#include <j_inventory_v2>
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
public OnPlayerDisconnect(playerid, reason)
{
SaveInventory(playerid);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys & KEY_WALK)
{
ShowInventory(playerid);
return 1;
}
if (newkeys & KEY_CROUCH)
{
if(IsValidObject(LootObjects[0]) && IsPlayerInRangeOfPoint(playerid,2.0,2384.59448,-1674.36279,13.74557))
{
AddItem(playerid,"M4A1",1);
SendClientMessage(playerid, COLOR_GREEN, "* 1 M4A1 has been added to your inventory");
DestroyObject(LootObjects[0]);
}
if(IsValidObject(LootObjects[1]) && IsPlayerInRangeOfPoint(playerid,2.0,2409.01392, -1673.93286, 12.65986))
{
AddItem(playerid,"AK47",1);
SendClientMessage(playerid, COLOR_GREEN, "* 1 AK47 has been added to your inventory");
DestroyObject(LootObjects[1]);
}
if(IsValidObject(LootObjects[2]) && IsPlayerInRangeOfPoint(playerid,2.0,2362.54614, -1644.61816, 12.61388))
{
AddItem(playerid,"Sniper Rifle",1);
SendClientMessage(playerid, COLOR_GREEN, "* 1 Sniper Rifle has been added to your inventory");
DestroyObject(LootObjects[2]);
}
if(IsValidObject(LootObjects[3]) && IsPlayerInRangeOfPoint(playerid,2.0,2393.15576, -1647.44202, 12.58709))
{
AddItem(playerid,"Country Rifle",1);
SendClientMessage(playerid, COLOR_GREEN, "* 1 Country Rifle has been added to your inventory");
DestroyObject(LootObjects[3]);
}
if(IsValidObject(LootObjects[4]) && IsPlayerInRangeOfPoint(playerid,2.0,2326.31885, -1646.21326, 13.87297))
{
AddItem(playerid,"Shotgun",1);
SendClientMessage(playerid, COLOR_GREEN, "* 1 Shotgun has been added to your inventory");
DestroyObject(LootObjects[4]);
}
if(IsValidObject(LootObjects[5]) && IsPlayerInRangeOfPoint(playerid,2.0,2324.06274, -1646.22961, 13.86012))
{
AddItem(playerid,"Spas",1);
SendClientMessage(playerid, COLOR_GREEN, "* 1 Spas has been added to your inventory");
DestroyObject(LootObjects[5]);
}
if(IsValidObject(LootObjects[6]) && IsPlayerInRangeOfPoint(playerid,2.0,2328.17944, -1681.76965, 13.70912))
{
AddItem(playerid,"9mm Pistol",1);
SendClientMessage(playerid, COLOR_GREEN, "* 1 9mm Pistol has been added to your inventory");
DestroyObject(LootObjects[6]);
}
if(IsValidObject(LootObjects[7]) && IsPlayerInRangeOfPoint(playerid,2.0,2413.82813, -1647.04639, 13.05190))
{
AddItem(playerid,"9mm Silenced",1);
SendClientMessage(playerid, COLOR_GREEN, "* 1 9mm Silenced has been added to your inventory");
DestroyObject(LootObjects[7]);
}
if(IsValidObject(LootObjects[8]) && IsPlayerInRangeOfPoint(playerid,2.0,2306.93921, -1678.13745, 12.99543))
{
AddItem(playerid,"Desert Eagle",1);
SendClientMessage(playerid, COLOR_GREEN, "* 1 Desert Eagle has been added to your inventory");
DestroyObject(LootObjects[8]);
}
else
{
//DEBUG MESSAGE
SendClientMessage(playerid, COLOR_RED, "Your not close enough!");
return 1;
}
}
return 0;
}
public OnPlayerUseItem(playerid,ItemName[])
{
if(!strcmp(ItemName,"Full Medkit",true))
{
new Float:hp;
GetPlayerHealth(playerid,hp);
if(hp>=100)return SendClientMessage(playerid,COLOR_RED,"* You already have full health!");
SetPlayerHealth(playerid,100);
RemoveItem(playerid,ItemName,1);
return SendClientMessage(playerid,COLOR_WHITE,"* You used a medkit.");
}
if(!strcmp(ItemName,"Small Medkit",true))
{
new Float:hp;
GetPlayerHealth(playerid,hp);
if(hp>=50)return SendClientMessage(playerid,COLOR_RED,"* You already have more then half health!");
SetPlayerHealth(playerid,50);
RemoveItem(playerid,ItemName,1);
return SendClientMessage(playerid,COLOR_WHITE,"* You used a small medkit.");
}
if(!strcmp(ItemName,"Full Armour",true))
{
new Float:armour;
GetPlayerArmour(playerid,armour);
if(armour>=100)return SendClientMessage(playerid,COLOR_RED,"* You already have full armour!");
SetPlayerArmour(playerid,100);
RemoveItem(playerid,ItemName,1);
return SendClientMessage(playerid,COLOR_WHITE,"* You used your full armour.");
}
if(!strcmp(ItemName,"Small Armour",true))
{
new Float:armour;
GetPlayerArmour(playerid,armour);
if(armour<=50)return SendClientMessage(playerid,COLOR_RED,"* You already have more then half armour!");
SetPlayerArmour(playerid,50);
RemoveItem(playerid,ItemName,1);
return SendClientMessage(playerid,COLOR_WHITE,"* You used your small armour.");
}
if(!strcmp(ItemName,"Sniper Rifle",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 34, 25);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your Sniper Rifle.");
}
if(!strcmp(ItemName,"Country Rifle",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 33, 30);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your Country Rifle.");
}
if(!strcmp(ItemName,"M4A1",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 31, 100);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your M4A1.");
}
if(!strcmp(ItemName,"AK47",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 30, 100);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your AK47.");
}
if(!strcmp(ItemName,"MP5",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 29, 150);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your MP5.");
}
if(!strcmp(ItemName,"Spas",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 27, 40);
ApplyAnimation(playerid,"BUDDY","buddy_reload",4.1,0,1,1,1,1);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your Spas.");
}
if(!strcmp(ItemName,"Shotgun",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 25, 70);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your Shotgun.");
}
if(!strcmp(ItemName,"9mm Pistol",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 22, 60);
ApplyAnimation(playerid,"COLT45","colt45_reload",4.1,0,1,1,1,1);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your 9mm Pistol.");
}
if(!strcmp(ItemName,"9mm Silenced",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 23, 70);
ApplyAnimation(playerid,"SILENCED","Silence_reload",4.1,0,1,1,1,1);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your 9mm Silenced.");
}
if(!strcmp(ItemName,"Desert Eagle",true))
{
RemoveItem(playerid,ItemName,1);
GivePlayerWeapon(playerid, 24, 40);
return SendClientMessage(playerid,COLOR_WHITE,"* You have taken out your Desert Eagle.");
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
InventoryOnDialogResponse(playerid, dialogid, response, inputtext);
//rest of your code
LoadInventory(playerid);
Really Nice dude i Like it But how can i add object like hat ,Other Objects
|
public OnPlayerDisconnect(playerid, reason)
{
SaveInventory(playerid);
return 1;
}
Can you add a download link? When I compile, I always get errors.
|
I wouldn't say so. You used "SaveInventory" in your tutorial, but you never made the function for it!
It also barely does anything. TBH, i wouldn't make tutorials if i wouldn't even know how to script myself. Remember, a toddler has never teached an adult to do his job. |
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