Automatic door
#1

Hello!

im tired to type /open /close all the time, so i want it to go automatic
How do i convert this? here is the cmds

pawn Код:
COMMAND:open(playerid, params[])
{
    if(Member[playerid] == 0) return SendClientMessage(playerid,red,"You cant use our door");
    if(Member[playerid] == 1) return SendClientMessage(playerid,red,"You cant use our door");
    if(Member[playerid] == 2) return SendClientMessage(playerid,red,"You cant use our door");
    else if(Member[playerid] == 3)
    if(IsPlayerInRangeOfPoint(playerid, 2.0, -700.7123,437.2001,18.5800))
    MoveObject (open,-702.41857910156, 437.17742919922, 18.92423248291, 1.0);
    return 1;
}
COMMAND:close(playerid, params[])
{
    if(Member[playerid] == 0) return SendClientMessage(playerid,red,"You cant use our door");
    if(Member[playerid] == 1) return SendClientMessage(playerid,red,"You cant use our door");
    if(Member[playerid] == 2) return SendClientMessage(playerid,red,"You cant use our door");
    else if(Member[playerid] == 3)
    if(IsPlayerInRangeOfPoint(playerid, 2.0, -700.7123,437.2001,18.5800))
    MoveObject (open,-700.76788330078, 437.17742919922, 18.92423248291, 1.0);
    return 1;
}
Reply
#2

Use the PlayerToPoint function, and set a timer onto the door.

pawn Код:
forward doorclose;
public doorclose()
{
MoveObject (open,-700.76788330078, 437.17742919922, 18.92423248291, 1.0);
return 1;
}

if(PlayerToPoint(playerid, X, Y, Z))
{
MoveObject (open,-702.41857910156, 437.17742919922, 18.92423248291, 1.0);
SetTimer("doorclose", 3000, false)
SendClientMessage(playerid, COLOR, "Door will close in 3 seconds.");
return 1;
}
Might be some errors, but here you got the ground of it. Just edit / fix it as you like.
Reply
#3

Quote:
Originally Posted by Kayaque
Посмотреть сообщение
Use the PlayerToPoint function, and set a timer onto the door.

pawn Код:
forward doorclose;
public doorclose()
{
MoveObject (open,-700.76788330078, 437.17742919922, 18.92423248291, 1.0);
return 1;
}

if(PlayerToPoint(playerid, X, Y, Z))
{
MoveObject (open,-702.41857910156, 437.17742919922, 18.92423248291, 1.0);
SetTimer("doorclose", 3000, false)
SendClientMessage(playerid, COLOR, "Door will close in 3 seconds.");
return 1;
}
Might be some errors, but here you got the ground of it. Just edit / fix it as you like.
Can i use this? bc i cant fint the funktion on wiki
pawn Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
Reply
#4

Checkpoints or pickups can be more simple ?
Reply
#5

Instead of PlayerToPoint use IsPlayerInRangeOfPoint
Reply
#6

Quote:
Originally Posted by Retardedwolf
Посмотреть сообщение
Instead of PlayerToPoint use IsPlayerInRangeOfPoint
And how does the IsPlayerInRangeOfPoint funktion look like? sorry my sucky skills
Reply
#7

https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Reply
#8

Quote:
Originally Posted by Berlovan
Посмотреть сообщение
Thats how to make a cmd in OnPlayerCommandText not a pulic funtion for what i need

i have this, but it dioesnt work nbc of errors
pawn Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        tempposx = (oldposx -x);
        tempposy = (oldposy -y);
        tempposz = (oldposz -z);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    if(PlayerToPoint(playerid, X, Y, Z))
    {
        MoveObject (open,-702.41857910156, 437.17742919922, 18.92423248291, 1.0);
        SetTimer("doorclose", 3000, false)
    }
    return 0;
}
Reply
#9

You have an example in your own function.
Reply
#10

Quote:
Originally Posted by Berlovan
Посмотреть сообщение
You have an example in your own function.
I have put the code inside that funktion, but i cant get it compile without errors
pawn Код:
if(PlayerToPoint(playerid, X, Y, Z))
    {
        MoveObject (open,-702.41857910156, 437.17742919922, 18.92423248291, 1.0);
        SetTimer("doorclose", 3000, false)
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)