/i give help
#1

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.

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);
                        }
It compiles with no errors, so idk what the problem could be.
Reply
#2

if(Player[playerid][InventorySlot1Item] == 1)
hare u check if is slot = 1
under this u check same slot if he is not = 1 , so if u above check if hes = 1 when u check if is it not =1 is never calls i think so
if(Player[id][InventorySlot1Item] != 1

try to comment this check if(Player[playerid][InventorySlot1Item] == 1)
Reply
#3

This thing is anonying .. and there is no LOGIC here
PHP код:

 
if(Player[playerid][InventorySlot1Item] == 1)
                {
                    if(
Player[id][InventorySlot1Item] != || Player[id][InventorySlot2Item] != || Player[id][InventorySlot3Item] != || Player[id][InventorySlot4Item] != || Player[id][InventorySlot5Item] != || Player[id][InventorySlot6Item] != || Player[id][InventorySlot7Item] != || Player[id][InventorySlot8Item] != ||
                    
Player[id][InventorySlot9Item] != || Player[id][InventorySlot10Item] != || Player[id][InventorySlot11Item] != || Player[id][InventorySlot12Item] != 1)
                    {
                        if(
Player[id][InventorySlot1Item] == 0)
                        { 
You said to the server to check if(Player[playerid][InventorySlot1Item] == 1 if it IS 1 , he'll continue , and after it you're telling hem if it's not 1 he will continue , there is a misunderstanding to your form , try to do the inverse in your code , or Start debuging the code , it will never work like that ..

for advance help : tell me if it gives you the USAGE or no .
Reply
#4

Quote:
Originally Posted by MCZOFT
Посмотреть сообщение
This thing is anonying .. and there is no LOGIC here
PHP код:

 
if(Player[playerid][InventorySlot1Item] == 1)
                {
                    if(
Player[id][InventorySlot1Item] != || Player[id][InventorySlot2Item] != || Player[id][InventorySlot3Item] != || Player[id][InventorySlot4Item] != || Player[id][InventorySlot5Item] != || Player[id][InventorySlot6Item] != || Player[id][InventorySlot7Item] != || Player[id][InventorySlot8Item] != ||
                    
Player[id][InventorySlot9Item] != || Player[id][InventorySlot10Item] != || Player[id][InventorySlot11Item] != || Player[id][InventorySlot12Item] != 1)
                    {
                        if(
Player[id][InventorySlot1Item] == 0)
                        { 
You said to the server to check if(Player[playerid][InventorySlot1Item] == 1 if it IS 1 , he'll continue , and after it you're telling hem if it's not 1 he will continue , there is a misunderstanding to your form , try to do the inverse in your code , or Start debuging the code , it will never work like that ..

for advance help : tell me if it gives you the USAGE or no .
No, it checks the PLAYERID (player A) if their item is 1, then it checks ID (Player B) if any of there slots aren't 1. If ID (Player B) has the item in one of those slots however, or doesn't have any room for the item, this code is called:

pawn Код:
if(Player[id][InventorySlot1Item] == 1) return Player[id][InventorySlot1Amount] += amount;
                        else if(Player[id][InventorySlot2Item] == 1) return Player[id][InventorySlot2Amount] += amount;
                        else if(Player[id][InventorySlot3Item] == 1) return Player[id][InventorySlot3Amount] += amount;
                        else if(Player[id][InventorySlot4Item] == 1) return Player[id][InventorySlot4Amount] += amount;
                        else if(Player[id][InventorySlot5Item] == 1) return Player[id][InventorySlot5Amount] += amount;
                        else if(Player[id][InventorySlot6Item] == 1) return Player[id][InventorySlot6Amount] += amount;
                        else if(Player[id][InventorySlot7Item] == 1) return Player[id][InventorySlot7Amount] += amount;
                        else if(Player[id][InventorySlot8Item] == 1) return Player[id][InventorySlot8Amount] += amount;
                        else if(Player[id][InventorySlot9Item] == 1) return Player[id][InventorySlot9Amount] += amount;
                        else if(Player[id][InventorySlot10Item] == 1) return Player[id][InventorySlot10Amount] += amount;
                        else if(Player[id][InventorySlot11Item] == 1) return Player[id][InventorySlot11Amount] += amount;
                        else if(Player[id][InventorySlot12Item] == 1) return Player[id][InventorySlot12Amount] += amount;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)