28.08.2016, 14:02
Well. If you want to use /enter and /exit nears pickups you can try this:
Go to OnGameModeInit callback
And now, the command /enter
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
P.S. If you choose the way by pressing Y you must add this on top of your gamemode.
Код:
new EnterPickup; // you can change the name of this variable
Код:
public OnGameModeInit() { EnterPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld) // Put your own coordonates and IDs return 1; }
Код:
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; }
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; }
Код:
#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))