02.05.2015, 22:34
A few weeks ago I posted about having trouble with an item's 3d text label not disappear when picking up an item and I thought I fixed it, but it appears I was wrong. When I pick up any items when I login, it works fine, does it's job fine. However, when I drop any item and go to pick up any other item, the text label stays behind.
pawn Код:
//Creating the Item
stock CreateItem(model, amount, type, Float:X, Float:Y, Float:Z, world, interior)
{
if(model != 0)
{
for(new i=0; i<MAX_ITEMS; i++)
{
if(Item[i][ItemPosX] == 0 && Item[i][ItemPosY] == 0 && Item[i][ItemPosZ] == 0)
{
Item[i][ItemModel] = model;
Item[i][ItemAmount] = amount;
Item[i][ItemType] = type;
Item[i][ItemPosX] = X;
Item[i][ItemPosY] = Y;
Item[i][ItemPosZ] = Z;
Item[i][ItemVWorld] = world;
Item[i][ItemInterior] = interior;
DropObject[i] = CreateObject(model, X, Y, Z, 0, 0, 0, world);
break;
}
}
}
return 1;
}
pawn Код:
//OnPlayerPickUpItem
forward OnPlayerPickupItem(playerid);
public OnPlayerPickupItem(playerid)
{
new string[128];
for(new i=0; i<MAX_ITEMS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.5, Item[i][ItemPosX], Item[i][ItemPosY], Item[i][ItemPosZ]) && GetPlayerInterior(playerid) == Item[i][ItemInterior] && GetPlayerVirtualWorld(playerid) == Item[i][ItemVWorld])
{
Item[i][ItemPosX] = 0;
Item[i][ItemPosY] = 0;
Item[i][ItemPosZ] = 0;
Delete3DTextLabel(ItemLabel[i]);
DestroyObject(DropObject[i]);
LoadItemVisual();
if(Item[i][ItemModel] == 2806 && Item[i][ItemType] == 1)
{
Player[playerid][BrahminMeat] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Brahmin Meat'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 2806 && Item[i][ItemType] == 2)
{
Player[playerid][BrahminSteak] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Brahmin Steak'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 2663 && Item[i][ItemType] == 1)
{
Player[playerid][Cram] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Cram'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 2663 && Item[i][ItemType] == 2)
{
Player[playerid][MacCheese] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'BlamCo Mac & Cheese'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 2769 && Item[i][ItemType] == 1)
{
Player[playerid][IguanaStick] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Iguana on a Stick'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 2769 && Item[i][ItemType] == 2)
{
Player[playerid][SquirrelStick] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Squirrel on a Stick'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 1580 && Item[i][ItemType] == 1)
{
Player[playerid][Stimpak] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Stimpak'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 1580 && Item[i][ItemType] == 2)
{
Player[playerid][DoctorBag] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Doctor's Bag'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 1575 && Item[i][ItemType] == 1)
{
Player[playerid][Jet] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Jet'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 1575 && Item[i][ItemType] == 2)
{
Player[playerid][Psycho] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Psycho'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 1575 && Item[i][ItemType] == 3)
{
Player[playerid][Mentats] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Mentats'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 1575 && Item[i][ItemType] == 4)
{
Player[playerid][Buffout] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Buffout'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 2647 && Item[i][ItemType] == 1)
{
Player[playerid][DirtyWater] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Dirty Water'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 2647 && Item[i][ItemType] == 2)
{
Player[playerid][PurifiedWater] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Purified Water'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 1484 && Item[i][ItemType] == 1)
{
Player[playerid][NukaCola] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'Nuka Cola'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else if(Item[i][ItemModel] == 1577 && Item[i][ItemType] == 1)
{
Player[playerid][RadAway] += Item[i][ItemAmount];
format(string, sizeof(string), "You have picked up 'RadAway'. Amount: %i", Item[i][ItemAmount]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " * %s has picked up something.", GetName(playerid));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
Item[i][ItemModel] = 0;
Item[i][ItemType] = 0;
Item[i][ItemAmount] = 0;
}
}
return 1;
}
pawn Код:
//Drop command
CMD:drop(playerid, params[])
{
if(GetPVarInt(playerid, "LoggedIn") == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be logged in to use this command.");
new string[128], item[24], itemamount, Float: x, Float: y, Float: z;
if(sscanf(params, "s[24]i", item, itemamount)) return SendClientMessage(playerid, COLOR_GREY, "[Server Command]: /drop [item (use /itemslist)] [amount]");
GetPlayerPos(playerid, x, y, z);
if(!strcmp(item, "BrahminMeat") || !strcmp(item, "brahminmeat"))
{
if(itemamount <= Player[playerid][BrahminMeat])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(2806, itemamount, 1, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][BrahminMeat] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Brahmin Meat.");
}
else if(!strcmp(item, "BrahminSteak") || !strcmp(item, "brahminsteak"))
{
if(itemamount <= Player[playerid][BrahminSteak])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(2806, itemamount, 2, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][BrahminSteak] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Brahmin Steak.");
}
else if(!strcmp(item, "Cram") || !strcmp(item, "cram"))
{
if(itemamount <= Player[playerid][Cram])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(2663, itemamount, 1, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][Cram] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Cram.");
}
else if(!strcmp(item, "MacCheese") || !strcmp(item, "maccheese"))
{
if(itemamount <= Player[playerid][MacCheese])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(2663, itemamount, 2, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][MacCheese] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much BlamCo Mac & Cheese.");
}
else if(!strcmp(item, "IguanaStick") || !strcmp(item, "iguanastick"))
{
if(itemamount <= Player[playerid][IguanaStick])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(2769, itemamount, 1, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][IguanaStick] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Iguana on a Stick.");
}
else if(!strcmp(item, "SquirrelStick") || !strcmp(item, "squirrelstick"))
{
if(itemamount <= Player[playerid][SquirrelStick])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(2769, itemamount, 2, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][SquirrelStick] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Squirrel on a Stick.");
}
else if(!strcmp(item, "Stimpak") || !strcmp(item, "stimpak"))
{
if(itemamount <= Player[playerid][Stimpak])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(1580, itemamount, 1, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][Stimpak] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Stimpak.");
}
else if(!strcmp(item, "DoctorBag") || !strcmp(item, "doctorbag"))
{
if(itemamount <= Player[playerid][DoctorBag])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(1580, itemamount, 2, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][DoctorBag] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Doctor's Bag.");
}
else if(!strcmp(item, "Jet") || !strcmp(item, "jet"))
{
if(itemamount <= Player[playerid][Jet])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(1575, itemamount, 1, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][Jet] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Jet.");
}
else if(!strcmp(item, "Psycho") || !strcmp(item, "psycho"))
{
if(itemamount <= Player[playerid][Psycho])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(1575, itemamount, 2, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][Psycho] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Psycho.");
}
else if(!strcmp(item, "Mentats") || !strcmp(item, "mentats"))
{
if(itemamount <= Player[playerid][Mentats])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(1575, itemamount, 3, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][Mentats] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Mentats.");
}
else if(!strcmp(item, "Buffout") || !strcmp(item, "buffout"))
{
if(itemamount <= Player[playerid][Buffout])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(1575, itemamount, 4, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][Buffout] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Buffout.");
}
else if(!strcmp(item, "DirtyWater") || !strcmp(item, "dirtywater"))
{
if(itemamount <= Player[playerid][DirtyWater])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(2647, itemamount, 1, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][DirtyWater] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Dirty Water.");
}
else if(!strcmp(item, "PurifiedWater") || !strcmp(item, "purifiedwater"))
{
if(itemamount <= Player[playerid][PurifiedWater])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(2647, itemamount, 2, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][PurifiedWater] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Purified Water.");
}
else if(!strcmp(item, "NukaCola") || !strcmp(item, "nukacola"))
{
if(itemamount <= Player[playerid][NukaCola])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(1484, itemamount, 1, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][NukaCola] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much Nuka Cola.");
}
else if(!strcmp(item, "RadAway") || !strcmp(item, "radaway"))
{
if(itemamount <= Player[playerid][RadAway])
{
format(string, sizeof(string), " * %s has dropped something.", GetName(playerid));
CreateItem(1577, itemamount, 1, x, y, z-1, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Player[playerid][RadAway] -= itemamount;
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
SendClientMessage(playerid, COLOR_LIGHTPURPLE, string);
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have that much RadAway.");
}
else if(!strcmp(item, "Armor") || !strcmp(item, "armor") || !strcmp(item, "Armour") || !strcmp(item, "armour"))
{
SendClientMessage(playerid, COLOR_GREY, "You can't drop this item.");
}
else return SendClientMessage(playerid, COLOR_GREY, "That is an invalid item (/itemslist).");
LoadItemVisual();
return 1;
}