Wednesday, December 1, 2010

SAMP Scripting Tutorial: Interiors | /enter - /exit Commands

Here is the code

// Declarations
new Float:saveX[MAX_PLAYERS],Float:saveY[MAX_PLAYERS],Float:saveZ[MAX_PLAYERS];
new cityHall;

// OnGameModeInit
cityHall = CreatePickup(1318,1,1480.9467773438,-1772.1303710938,19.966495513916);

// Uses standard player walking animation (animation of CJ)
UsePlayerPedAnims();
//-------------------------------------------------------------------------------//

// OnPlayerCommandText
if(strcmp(cmdtext,"/enter",true)==0)
{
 if(IsPlayerInRangeOfPoint(playerid,5.0,1480.9467773438,-1772.1303710938,19.966495513916))
 {
  GetPlayerPos(playerid,saveX[playerid],saveY[playerid],saveZ[playerid]);
  SetPlayerPos(playerid,388.8720,173.8050,1008.3828);
  SetPlayerInterior(playerid, 3);
 }
 return 1;
}

if(strcmp(cmdtext,"/exit",true)==0)
{
 
 SetPlayerPos(playerid,saveX[playerid],saveY[playerid],saveZ[playerid]);
 SetPlayerInterior(playerid, 0);
 
 return 1;
}


// OnPlayerPickUpPickup
if(pickupid == cityHall)
{
 GameTextForPlayer(playerid,"Type ~r~/enter",5000,5);
}

// OnPlayerUpdate
if(IsPlayerInRangeOfPoint(playerid,5.0,390.64190673828,173.77577209473,1009.553527832))
{
 GameTextForPlayer(playerid,"Type ~r~/exit",5000,5);
}

3 comments: