27.12.2014, 21:08
I'm trying to script a command that gives items to another person, but it just won't give the item to the other player.
It compiles with no errors, so idk what the problem could be.
pawn Код:
if(!strcmp(choice, "give", true, 4))
{
//slot amount id
new Float: x, Float: y, Float: z;
new string[128];
GetPlayerPos(id, x, y, z);
//if(!IsNumeric(strval(slot))) return SendClientMessage(playerid, -1, "Command Usage: /i give [slot] [amount] [playerid]");
if(!slot) return SendClientMessage(playerid, -1, "Command Usage: /i give [slot] [amount] [playerid]");
if(slot == 1)
{
//if(amount > Player[playerid][InventorySlot1Amount] || !amount) return SendClientMessage(playerid, -1, "Command Usage: /i give slot [amount] [playerid]");
//if(id == INVALID_PLAYER_ID || IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Command Usage: /i give slot amount [playerid]");
if(IsPlayerInRangeOfPoint(playerid, 3, x, y, z))
{
if(Player[playerid][InventorySlot1Item] == 1)
{
if(Player[id][InventorySlot1Item] != 1 || Player[id][InventorySlot2Item] != 1 || Player[id][InventorySlot3Item] != 1 || Player[id][InventorySlot4Item] != 1 || Player[id][InventorySlot5Item] != 1 || Player[id][InventorySlot6Item] != 1 || Player[id][InventorySlot7Item] != 1 || Player[id][InventorySlot8Item] != 1 ||
Player[id][InventorySlot9Item] != 1 || Player[id][InventorySlot10Item] != 1 || Player[id][InventorySlot11Item] != 1 || Player[id][InventorySlot12Item] != 1)
{
if(Player[id][InventorySlot1Item] == 0)
{
Player[id][InventorySlot1Item] = 1;
Player[id][InventorySlot1Amount] += amount;
Player[playerid][InventorySlot1Amount] -= amount;
format(string, sizeof(string), "You gave %s %i bottle(s) of water.", GetName(id));
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "%s gave you %i bottle(s) of water.", GetName(playerid));
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "*%s gave %s %i bottle(s) of water.", GetName(playerid), GetName(id));
SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000);
}