How to make /enter [tutorial]
#1

Hello all. In this tutorial, I will show scripting beginers, how to make /enter and /exit for house. First of all, copy this into your script (bottom of script).

Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  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;
  }
  return 0;
}
This will get players position (for enter icon) with radius. Now, let's start.

So, you've decided to make police department. So, you go to police department in debug and type /save to get coordinates for enterance and for icon. When you get your coordinates (example: 2290.0496,2430.2283,10.8203), you can create icon at police department. So you make icon at OnGameModeInit(). First disable enter/exit (yellow thingy) with adding line under OnGameModeInt()
Код:
DisableInteriorEnterExits();
Then add:

Код:
CreatePickup(1239,1,2290.0496,2430.2283,10.8203); // ICON for POLICE DEPARTMENT
So, now we created icon (Info icon...) at PD. Now we have to script /enter and /exit command right? You do it like this.

Under OnPlayerCommandText(playerid, cmdtext[]) you can script every player command. So, lets make /enter shall we?

Код:
if(strcmp(cmdtext, "/enter", true, 6) == 0)
	{
		if(PlayerToPoint(3, playerid, 2290.0496,2430.2283,10.8203)) // Police enterance
		{
		  SetPlayerInterior(playerid, 3); // This is important! This sets player to interior id 3!
		  SetPlayerPos(playerid, 238.6620,141.0520,1003.0234); // these are coordinates where he'll spawn (PD INT)
		  return 1;
		}
        return 1;
    }
Now we made /enter but we need to get out, right?

Код:
if (strcmp(cmdtext, "/exit", true, 5) == 0)
{
      if(PlayerToPoint(3, playerid, 238.6620,141.0520,1003.0234)) // Police enterance 
	  {
	    SetPlayerInterior(playerid, 0); // this is important..interior 0 is outside...
	    SetPlayerPos(playerid, 2290.0496,2430.2283,10.8203); // this is where player will stand...
	    return 1;
	  }
      return 1;
}

That's basicly it...If you dont understand what line means, just say it here. I'll explain. Thanks for reading. Bye!
Reply
#2

Hmm.. i did understand the /enter and the /exit.. but the icon i didn't, mind to help me?

thank, Oshri
Reply
#3

Useful for beginers but,,,same suggestions i've given you before

Reply
#4

Well the icon is like this, CreateObject(objectid, type, positions); You put that under OnGameModeInit(). You can see the types of icons on wiki...https://sampwiki.blast.hk/wiki/CreatePickup Understand now? PlayerToPoint works for me perfectly on 3 gamemodes
Reply
#5

This is what I have;


pawn Код:
#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("Admin Crib Loaded");
    return 1;
}

// -----------------------------------------------------------------------------

public OnFilterScriptExit()
{
    pring("Admin Crib Unloaded");
    return 1;
}

// -----------------------------------------------------------------------------

#else

// -----------------------------------------------------------------------------

#endif

// -----------------------------------------------------------------------------

public OnGameModeInit()
{
  DisableInteriorEnterExits();
  CreatePickup(1239,1,2049.48,2763.07,10.82); // Icon
    return 1;
}

// -----------------------------------------------------------------------------

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/enter", true, 6) == 0)
    {
        if(PlayerToPoint(3, playerid, 2049.48,2763.07,10.82)) // House Entramce
        {
          SetPlayerInterior(playerid, 12); // Sets Player to Interior 12
          SetPlayerPos(playerid, 2324.4199,-1145.5699,1050.7101); // Spawn position inside
          return 1;
        }
        return 1;
    }
    if (strcmp(cmdtext, "/exit", true, 5) == 0)
    {
        if(PlayerToPoint(3, playerid, 2049.48,2763.07,10.82)) // House Entrance
      {
        SetPlayerInterior(playerid, 0); // this is important..interior 0 is outside...
        SetPlayerPos(playerid, 2290.0496,2430.2283,10.8203); // this is where player will stand...
        return 1;
      }
        return 1;
}

// -----------------------------------------------------------------------------

stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  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 < 3) && (tempposx > -3)) && ((tempposy < 3) && (tempposy > -3)) && ((tempposz < 3) && (tempposz > -3)))
  {
    return 1;
  }
  return 0;
}

And this is what I get;


Код:
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(42) : error 017: undefined symbol "PlayerToPoint"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(52) : error 017: undefined symbol "PlayerToPoint"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(63) : warning 217: loose indentation
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(63) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(63) : error 017: undefined symbol "PlayerToPoint"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(68) : error 017: undefined symbol "x"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(69) : error 017: undefined symbol "y"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(70) : error 017: undefined symbol "z"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(77) : error 030: compound statement not closed at the end of file (started at line 40)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


8 Errors.
Help me out please
Reply
#6

1. You must have missed a bracket somewhere, Check that all { have an adjacent }
2.
pawn Код:
public OnFilterScriptExit()
{
pring("Admin Crib Unloaded");
return 1;
}
Its print not pring
3. You dont have to have the #if defined filterscript, Take that out if you like
Reply
#7

Hi,

This command worked great. I started to play around with it so that if I made another pickup somewhere else and I typed the /enter command again it will enter the new interior with the new co-ordinates but like most of the things that I try, I failed. I was wondering if anyone could give me an example of how to create it so it does what i have explained above.

Many Thanks,
Jonny.
Reply
#8

I'm revivingg this topic because many people is asking how to make on the 1st page.

sorry for any incovinience.
Reply
#9

Is there a way you can add text? Gametext?

Like:
Police Department
Type /enter to enter.
Reply
#10

Yeah, I think he described it as CreateObject, but instead use this:

new houseicon;

//PICKUP ID MODEL ID Wont disappear on pickup
// \/ \/ \/
houseicon = AddStaticPickup( 1273, 23, 1503.3359, 1432.3585, 10.1191 );
// ^Co ordinates for pickup^


public OnPlayerPickUpPickup(playerid, pickupid)
{
if (pickupid == houseicon)
{
SendClientMessage(playerid, 0x21DD00FF, "Type /enter to enter!");//when he stands on the icon this message gets sent

}
}

Correct me if I have gone wrong somewhere here....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)