Attempting to script my own house
#1

Hello everyone,

I'm currently trying to make a house in my server, but things aren't going as i expected...
I checked wiki for making a house and i copied the code, changed some stuff.
This is what i got:

pawn Код:
#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Admin Crib");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

#endif

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp(cmdtext, "/enter", true)==0)
    {
        new i, Float:X, Float:Y, Float:Z; //this is where your coords will get stored
        for (i = 0; i < MAX_PLAYERS; i++) //this is a loop
        {
            GetPlayerPos(i, X, Y, Z); //stores your pos
            if(2049.48,2763.07,10.82) //coords for entering house
            {
                SetPlayerInterior(playerid, 12); //interiorID is the Interior the house is in
                SetPlayerPos(playerid, 2049.48, 2763.07, 10.82); // X, Y, Z are the coords where the house is located
            }
        }
        return 1;
}
But these are the errors i recieve while compiling;
Код:
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(30) : warning 206: redundant test: constant expression is non-zero
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(39) : error 030: compound statement not closed at the end of file (started at line 24)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
What do these 2 errors mean, and what can i do to fix it?
Reply
#2

Код:
if(2049.48,2763.07,10.82)
is not a valid expression. Use something like:

Код:
if(X == 2049.48 && Y == 2763.07 && Z == 10.82)
But because the coords are very precise, it's almost impossible to be exactly at those coords. Better search for a PlayerToPoint-function and use that.
Reply
#3

Quote:
Originally Posted by =>Sandra<=
Код:
if(X == 2049.48 && Y == 2763.07 && Z == 10.82)
Thanks, Sandra. That removes 1 error.
Still got this one;
Код:
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(39) : error 030: compound statement not closed at the end of file (started at line 24)
Quote:
Originally Posted by =>Sandra<=
But because the coords are very precise, it's almost impossible to be exactly at those coords. Better search for a PlayerToPoint-function and use that.
Since i'm kinda new at scripting, i don't understand PlayerToPoint . Can't really find a help topic about it.
Reply
#4

Quote:
Originally Posted by Mr. M
Quote:
Originally Posted by =>Sandra<=
Код:
if(X == 2049.48 && Y == 2763.07 && Z == 10.82)
Thanks, Sandra. That removes 1 error.
Still got this one;
Код:
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(39) : error 030: compound statement not closed at the end of file (started at line 24)
Quote:
Originally Posted by =>Sandra<=
But because the coords are very precise, it's almost impossible to be exactly at those coords. Better search for a PlayerToPoint-function and use that.
Since i'm kinda new at scripting, i don't understand PlayerToPoint . Can't really find a help topic about it.
Also you don't need a loop. Just take the player that did the /enter command (playerid) and get his position, then use PlayerToPoint.

pawn Код:
stock 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;
        }
    }
    return 0;
}
How to use it? use
pawn Код:
if(PlayerToPoint(3, playerid, x, y, z))
3 - the radius. 2 is normal. 5 is for cars.
playerid - which player to check
x, y, z - where the player shall be

Hope you got it
Reply
#5

Sorry to say this, but i don't understand that at all lol.
I've tried changing some stuff;

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
        stock PlayerToPoint(Float:3, playerid, Float:2049.48, Float:2763.07, Float:10.82)
        {
            if(IsPlayerConnected(playerid))
            {
                new Float:2049.48, Float:2763.07, Float:10.82;
                new Float:tempposx, Float:tempposy, Float:tempposz;
                GetPlayerPos(playerid, 2049.48, 2763.07, 10.82);
                tempposx = (2049.48);
                tempposy = (2763.07);
                tempposz = (10.82);

                if (((tempposx < 3) && (tempposx > -3)) && ((tempposy < 3) && (tempposy > -3)) && ((tempposz < 3) && (tempposz > -3)))
            {
                return 1;
            }
        }
            return 0;
}
But i get this;
Код:
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(24) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(24) : error 017: undefined symbol "PlayerToPoint"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(28) : error 001: expected token: "-identifier-", but found "-rational value-"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(30) : error 035: argument type mismatch (argument 2)
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(42) : error 030: compound statement not closed at the end of file (started at line 24)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#6

Its in the wrong place and you are not using it correctly my young Jedi. Here

http://forum.sa-mp.com/index.php?topic=87145.0
Reply
#7

Quote:
Originally Posted by ♦۞pкћп§-шŧųĄ۞♦
Its in the wrong place and you are not using it correctly my young Jedi. Here

http://forum.sa-mp.com/index.php?topic=87145.0
Thanks, i understand it now, i hope.
But one more thing,

How do i get the coordinates from the interior?
Because i'm scripting an house that isn't enterable in Single Player, so how do i get the coordinates of the location where the player spawns inside?
Reply
#8

https://sampwiki.blast.hk/wiki/Interiors

Go into one you want and too adjust position and get co-ordinates type /save. Then goto your GTA San Andreas folder you will see savedpositions.txt open that with notepad you will see

AddPlayerClass(274,1050.2039,-1357.6375,13.3828,274.1693,0,0,0,0,0,0); //

use:

1050.2039,-1357.6375,13.3828
Reply
#9

Ok, i found interior i wanted, Large modern unused Safehouse, but still get errors

pawn Код:
#include <a_samp>
#define PlayerToPoint

#if defined FILTERSCRIPT

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

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

public OnFilterScriptExit()
{
    print("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("/enter",cmdtext,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("/exit",cmdtext,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;
}
Errors:

Код:
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(43) : warning 206: redundant test: constant expression is non-zero
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(53) : warning 206: redundant test: constant expression is non-zero
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(64) : warning 217: loose indentation
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(64) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(64) : error 017: undefined symbol "radi"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(69) : error 017: undefined symbol "x"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(70) : error 017: undefined symbol "y"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(71) : error 017: undefined symbol "z"
C:\Documents and Settings\Mitch\Desktop\SERVER\filterscripts\AdminCrib.pwn(78) : error 030: compound statement not closed at the end of file (started at line 41)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#10

pawn Код:
#include <a_samp>

//Leave this line below.

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2])))))return 1

//Leave this here.

stock 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;
        }
    }
  return 0;
}

public OnFilterScriptInit()
{
  print("Admin Crib Loaded");
  DisableInteriorEnterExits();
  CreatePickup(1239, 1, 2049.48, 2763.07, 10.82); // Icon Where you placed your icon is the enter point.
  return 1;
}

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

public OnPlayerCommandText(playerid, cmdtext[])
{
  dcmd(enter, 5, cmdtext);//DCMD is very easy to use. Just put your cmdtext here.
  dcmd(exit, 4, cmdtext);
  return 0;
}

//Then make sure your code is at bottom of script.

dcmd_enter(playerid, params[])
{
  #pragma unused params
 
  if(PlayerToPoint(3,playerid, 2049.48,2763.07,10.82)) // House Entramce. Where you set icon.
    {
      SetPlayerInterior(playerid, 12); // Sets Player to Interior 12
      SetPlayerPos(playerid, 2324.4199, -1145.5699, 1050.7101); // Spawn position inside
      return 1;
    }
   return 1;
}

dcmd_exit(playerid, params[])
{
  #pragma unused params

  if(PlayerToPoint(3 ,playerid, 2324.4199, -1145.5699, 1050.7101)) // House Exit
    {
      SetPlayerInterior(playerid, 0); // this is important..interior 0 is outside...
      SetPlayerPos(playerid, 2049.48, 2763.07, 10.82); // this is where player will stand...
      return 1;
    }
  return 1;
}

//If you want to change the commands back by all means do so. Take note of how the co-ordinates are setup as yours where wrong.
As I have stated before don't really do filterscripts but I tested this and it works. I really recommend you use dcmd mate but change back to old commands if you want. I would suggest you fix the errors in them first.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)