Checking if doors are open problems
#1

Hello I got some scripting problems at my project :P so I need someone to help me fix this, how can I check that doors are closed/open ?

here is a code what I've tried

pawn Код:
case 0:
                    {
                        if (Close = 1)
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already closed!");
                        }
                        else
                        {
                            MoveObject(Jail1,1575.4000244,-1704.5999756,3620.5000000,1.0);// Closing gates at jail cell 1
                            Close = 1;
                        }
                    }
And I got those warnings:
pawn Код:
C:\Users\Bohinec Nejc\Desktop\Scripting\gamemodes\NEW.pwn(186) : warning 211: possibly unintended assignment
C:\Users\Bohinec Nejc\Desktop\Scripting\gamemodes\NEW.pwn(204) : warning 204: symbol is assigned a value that is never used: "Close"
How can I make this working ? :/

Thank you for help in advance
Reply
#2

Quote:

warning 211: possibly unintended assignment

It said exactly what is wrong with the code.
pawn Код:
if (Close = 1)
//change to
if (Close == 1)
= is for assignment
== is for comparison
Reply
#3

Thank you =)
Reply
#4

Uff but now I found new problem, I can't find out how can I make if door will be closed and if player want to close them again there will MSG appears, I was thinking about it and I can't find out how can I set those Close = 1/0 and Open = 1/0 so the message would appear

Here is my current code for opening door
pawn Код:
if (Open == 1)
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already open!");
                        }
                        else
                        {
                            MoveObject(Jail1,1575.4000244,-1704.5999756,3620.5000000 +2.0,1.0);// Opening gates at jail cell 1
                            Close = 0;
                        }
                    }
                    case 1:
                    {
                        if (Open == 1)
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already open!");
                        }
                        else
                        {
                            MoveObject(Jail2,1572.6999512,-1704.6999512,3620.5000000 +2.0,1.0);// Opening gates at jail cell 2
                            Close = 0;
                        }
                    }
                    case 2:
                    {
                        if (Open == 1)
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already open!");
                        }
                        else
                        {
                            MoveObject(Jail3,1566.5000000,-1704.5999756,3620.5000000 +2.0,1.0);// Opening gates at jail cell 3
                            Close = 0;
                        }
                    }
                }
            }
And current code for closing the door
pawn Код:
if (Close == 1)
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already closed!");
                        }
                        else
                        {
                            MoveObject(Jail1,1575.4000244,-1704.5999756,3620.5000000,1.0);// Closing gates at jail cell 1
                            Open = 0;
                        }
                    }
                    case 1:
                    {
                        if (Close == 1)
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already closed!");
                        }
                        else
                        {
                        MoveObject(Jail2,1572.6999512,-1704.6999512,3620.5000000,1.0);// Closing gates at jail cell 2
                        Open = 0;
                        }
                    }
                    case 2:
                    {
                        if (Close == 1)
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already closed!");
                        }
                        else
                        {
                            MoveObject(Jail3,1566.5000000,-1704.5999756,3620.5000000,1.0);// Closing gates at jail cell 3
                            Open = 0;
                        }
How can I make if player want to close closed doors the message will appear? because now doors are opening and closing but when I tried to close closed door the message won't appear, I know there are my assignments wrong but I can't figure out how could I change them to make it work :/

Thanks for help in advance!
Reply
#5

First of all, you have a lot of doors, but only single variable. So, when you close doors in one place, all doors in your world are "closed".

pawn Код:
new OpenedDoors[NUMBER OF DOORS];
We created array of door statuses, yay. I won't say anything about chararrays and bool type to avoid confusion. Now - let's take a look:
pawn Код:
case X:
                    {
                        if (Close == 1)
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already closed!");
                        }
                        else
                        {
                        MoveObject(Jail2,1572.6999512,-1704.6999512,3620.5000000,1.0);// Closing gates at jail cell 2
                        Open = 0;
                        }
                    }
Doesn't look too good.

pawn Код:
case X:
{
    if (!OpenedDoors[X]) {
        SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already closed!");
    }
    else {
        MoveObject(Jail2,1572.6999512,-1704.6999512,3620.5000000,1.0);// Closing gates at jail cell 2
        OpenedDoors[X] = 0;
    }
}
Much better
Reply
#6

Don't lose your patience but this is what I made

pawn Код:
case 0:
                    {
                        if (!OpenedDoors[1])
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already open!");
                        }
                        else
                        {
                            MoveObject(Jail1,1575.4000244,-1704.5999756,3620.5000000 +2.0,1.0);// Opening gates at jail cell 1
                            OpenedDoors[1] = 0;
                        }
                    }
                    case 1:
                    {
                        if (!OpenedDoors[2])
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already open!");
                        }
                        else
                        {
                            MoveObject(Jail2,1572.6999512,-1704.6999512,3620.5000000 +2.0,1.0);// Opening gates at jail cell 2
                            OpenedDoors[2] = 0;
                        }
                    }
                    case 2:
                    {
                        if (!OpenedDoors[3])
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already open!");
                        }
                        else
                        {
                            MoveObject(Jail3,1566.5000000,-1704.5999756,3620.5000000 +2.0,1.0);// Opening gates at jail cell 3
                            OpenedDoors[3] = 0;
                        }
                    }
                }
            }
            case 3: // Third dialog: Closing the jail cells
            {
                switch(listitem)
                {
                    case 0:
                    {
                        if (!OpenedDoors[4])
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already closed!");
                        }
                        else
                        {
                            MoveObject(Jail1,1575.4000244,-1704.5999756,3620.5000000,1.0);// Closing gates at jail cell 1
                            OpenedDoors[4] = 0;
                        }
                    }
                    case 1:
                    {
                        if (!OpenedDoors[5])
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already closed!");
                        }
                        else
                        {
                            MoveObject(Jail2,1572.6999512,-1704.6999512,3620.5000000,1.0);// Closing gates at jail cell 2
                            OpenedDoors[5] = 0;
                        }
                    }
                    case 2:
                    {
                        if (!OpenedDoors[6])
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already closed!");
                        }
                        else
                        {
                            MoveObject(Jail3,1566.5000000,-1704.5999756,3620.5000000,1.0);// Closing gates at jail cell 3
                            OpenedDoors[6] = 0;
                        }
                    }
Now it's saying only MSG and it don't want to open/close me the doors
Reply
#7

Anyone please, I can't figure out on my own :/
Reply
#8

Bump
Reply
#9

Closing doors code is diffrent now:

Instead of
pawn Код:
if (!OpenedDoors[1])
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already open!");
                        }
                        else
                        {
                            MoveObject(Jail1,1575.4000244,-1704.5999756,3620.5000000 +2.0,1.0);// Opening gates at jail cell 1
                            OpenedDoors[1] = 0;
                        }
pawn Код:
if (OpenedDoors[1])
                        {
                            SendClientMessage(playerid,0xAA3333AA,"INFO: Those doors are already open!");
                        }
                        else
                        {
                            MoveObject(Jail1,1575.4000244,-1704.5999756,3620.5000000 +2.0,1.0);// Opening gates at jail cell 1
                            OpenedDoors[1] = 1;
                        }
And later you use the same variable for closing doors (so not OpenedDoors[4] but OpenedDoors[0])
Reply
#10

Thank you, I am really new to those veriables or what ever they are but you helped me to figure out, I really appreciate it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)