SA-MP Forums Archive
How To Create Pressing Key To Enter Exit Building - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How To Create Pressing Key To Enter Exit Building (/showthread.php?tid=614639)



How To Create Pressing Key To Enter Exit Building - DhanZ - 10.08.2016

How To Create Pressing Key Y To Entering/Exit Building With /me?
With Command :
if(strcmp(cmd, "/enter", true) == 0)
if(strcmp(cmd, "/exit", true) == 0)


Re: How To Create Pressing Key To Enter Exit Building - Sh4dow04 - 28.08.2016

Well. If you want to use /enter and /exit nears pickups you can try this:
Код:
new EnterPickup; // you can change the name of this variable
Go to OnGameModeInit callback
Код:
public OnGameModeInit()
{
	EnterPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld) // Put your own coordonates and IDs
	return 1;
}
And now, the command /enter
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/enter", cmdtext, true, 10) == 0)
	{
		if(IsPlayerInRangeOfPoint(playerid,4, Float:x, Float:y, Float:z); // Replace Float:X,Float:y,Float:z with the coordonates of your pickup
		SetPlayerPos(playerid, Float:x, Float:y, Float:z) // Replace Float:X,Float:y,Float:z with the coordonates of your interior
		SetPlayerInterior(playerid,1);
		SendClientMessage(playerid,-1,"You have entered in ...");
		return 1;
	}
	return 0;
}
The same thing for /exit, only that is reversed.
If you want to enter by pressing Y instead of /enter /exit you can replace the commands with
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_YES))
    {
        // Code here
    }
	return 1;
}
P.S. If you choose the way by pressing Y you must add this on top of your gamemode.
Код:
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))