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;
}
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;
}
Use the PlayerToPoint function, and set a timer onto the door.
pawn Код:
|
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
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;
}
if(PlayerToPoint(playerid, X, Y, Z))
{
MoveObject (open,-702.41857910156, 437.17742919922, 18.92423248291, 1.0);
SetTimer("doorclose", 3000, false)
}