/Usegate // /usedoor
#1

Hey everyone, I'm new to PAWN really and i've just written this as a temporary solution...

pawn Код:
if (strcmp("/opendoor", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInRangeOfPoint(playerid,4,-2093.3371582031, -843.95068359375, -29.267526626587))
        {

            MoveObject(Gate1,-2091.6669921875, -844.0361328125, -29.267526626587, 1);
            SendClientMessage(playerid,COLOR_GREY,"ID Accepted: Door Opening");
            return 1;

        }
        if (IsPlayerInRangeOfPoint(playerid,4,-2126.1982421875, -868.763671875, -23.452175140381))
        {
            MoveObject(Gate2,-2126.1416015625, -870.2109375, -23.452175140381, 1);
            SendClientMessage(playerid,COLOR_GREY,"ID Accepted: Door Opening");
            return 1;
        }
        else
        {
            SendClientMessage(playerid,COLOR_GREY,"Error: You Are Not Near A Useable Door");
            return 1;
        }
    }
But how would i be able to change it from /opendoor /closedoor to /usedoor where the script knows if it is open or closed. I tried using variables so 1 = open 0 = closed but i had no luck.. So i would be grateful if you guys could help me.

Thanks

Gibson
Reply
#2

pawn Код:
new door1;
new door2;
new bool:door1opened;
new bool:door2opened;

OnGameModeInit()
{
    door = CreateObject,---,-2091.6669921875, -844.0361328125, -29.267526626587);
    return 1;
}

if (strcmp("/door1", cmdtext, true, 10) == 0)
{
    if (IsPlayerInRangeOfPoint(playerid,4,-2093.3371582031, -843.95068359375, -29.267526626587) && door1opened == false)
    {
        MoveObject(Gate1,-2091.6669921875, -844.0361328125, -29.267526626587, 1);
        SendClientMessage(playerid,COLOR_GREY,"ID Accepted: Door1 Opening");
        door1opened = true;
        return 1;
    }
    else
    {
        MoveObject(Gate1,-2093.3371582031, -843.95068359375, -29.267526626587, 1);
        SendClientMessage(playerid,COLOR_GREY,"ID Accepted: Door1 Closing");
        door1opened = false;
    }
    return 1;
}
if (strcmp("/door2", cmdtext, true, 10) == 0)
   
    else if (IsPlayerInRangeOfPoint(playerid,4,-2126.1982421875, -868.763671875, -23.452175140381) && door2opened == true)
    {
        MoveObject(Gate2,-2126.1416015625, -870.2109375, -23.452175140381, 1);
        SendClientMessage(playerid,COLOR_GREY,"ID Accepted: Door2 Opening");
        door2opened = false;
        return 1;
    }
    else
    {
        MoveObject(Gate2,-2126.1982421875, -868.763671875, -23.452175140381,1);
        SendClientMessage(playerid,COLOR_GREY,"ID Accepted: Door2 Closing");
        door2opened = false;
        return 1;
    }
    return 1;
}
This works, I've edited it!! This will work
Reply
#3

Ah man.. im kicking myself right now....

Why didnt i think of boolean..

Hahhaa thanks alot man. As i said new to pawn <--- My excuse.
Reply
#4

Quote:
Originally Posted by =AV=Gibson
Посмотреть сообщение
Ah man.. im kicking myself right now....

Why didnt i think of boolean..

Hahhaa thanks alot man. As i said new to pawn <--- My excuse.
No Problem.. Glad I could help!

Take care, and succes with further scripting etc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)