Gates Help
#1

SO I did a tutorial on how to make moving gates. Here is what I came up with:

Код:
#define FILTERSCRIPT
#include <a_samp>
#include <EasyNames>

public OnFilterScriptInit()
{
	{
	CreateObject(987,1006.49169922,-2104.39648438,12.14295101,0.00000000,0.00000000,158.46972656);
	CreateObject(975,1000.75781250,-2218.58496094,13.76844025,0.00000000,0.00000000,190.24475098); 
	}
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext,"/openmaingate", true) == 0)
		  {
		   if(PlayerNameIs(playerid, "Chicken0895"))
		   {                                               
				 if(IsPlayerInRangeOfPoint(15.0, playerid,1002.49169922,-2106.39648438,14.14295101))
				 {                                                             // |
		 	   		MoveObject(987, 1006.49169922,-2104.39648438,6.14295101, 1.500000);  
		     		return 1;
		     }    
		  }                                                                         
		}                                                                           
  if(strcmp(cmdtext,"/closemaingate", true) == 0)
		  {                                                                            
  	 	if(PlayerNameIs(playerid, "Chicken0895"))
		   {                                                                             
				 if(IsPlayerInRangeOfPoint(15.0, playerid,1002.49169922,-2106.39648438,14.14295101))
				 {
		 	   MoveObject(987, 1006.49169922,-2104.39648438,12.14295101, 1.500000);
		 	   return 1;
			}
		  }
	}
}
It does not work. When I use the commands I get "unknown command". I don't know if it is relevant, but when I unloaded the fs via rcon, the gates stayed where they were.

Any help would be greatly appreciated. And yes, I made sure my name was Chicken0895.
Reply
#2

The best indentation I have ever see =P

pawn Код:
new
    objGate, // Gamemaker style :P
    bool: objGateState = false
;

public OnFilterScriptInit( )
{
    objGate = CreateObject( 987, 1006.49169922, -2104.39648438, 12.14295101, 0.00000000, 0.00000000, 158.46972656 );

    return 1;
}

public OnFilterScriptExit( )
{
    DestroyObject( objGate );

    return 1;
}

public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if ( !strcmp( cmdtext, "/openmaingate", true ) )
    {
        if ( PlayerNameIs( playerid, "Chicken0895" ) )
        {
            if ( IsPlayerInRangeOfPoint( playerid, 15.0, 1002.49169922, -2106.39648438, 14.14295101 ) )
            {
                if ( objGateState )
                    return SendClientMessage( playerid, -1, "Gate is already opened." );

                 MoveObject( objGate, 1006.49169922, -2104.39648438, 6.14295101, 1.500000 );

                 objGateState = true;
             }
             else return SendClientMessage( playerid, -1, "You aren't near of the gate." ):
         }
         else return SendClientMessage( playerid, -1, "You aren't Chicken0985." );

         return 1;
    }

    if ( !strcmp( cmdtext, "/closemaingate", true  ) )
    {
        if ( PlayerNameIs( playerid, "Chicken0895" ) )
        {
            if ( IsPlayerInRangeOfPoint( playerid, 15.0, 1002.49169922, -2106.39648438, 14.14295101 ) )
            {
                if ( !objGateState )
                    return SendClientMessage( playerid, -1, "Gate is already closed." );

                 MoveObject( objGate, 1006.49169922, -2104.39648438, 12.14295101, 1.500000 );

                 objGateState = false;
             }

             else return SendClientMessage( playerid, -1, "You aren't near of the gate." ):
         }

         else return SendClientMessage( playerid, -1, "You aren't Chicken0985." );

         return 1;
    }

    return 0;
}
Try this one.
Reply
#3

Quote:
Originally Posted by Basicz
Посмотреть сообщение
The best indentation I have ever see =P

pawn Код:
new
    objGate, // Gamemaker style :P
    bool: objGateState = false
;

public OnFilterScriptInit( )
{
    objGate = CreateObject( 987, 1006.49169922, -2104.39648438, 12.14295101, 0.00000000, 0.00000000, 158.46972656 );

    return 1;
}

public OnFilterScriptExit( )
{
    DestroyObject( objGate );

    return 1;
}

public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if ( !strcmp( cmdtext, "/openmaingate", true ) )
    {
        if ( PlayerNameIs( playerid, "Chicken0895" ) )
        {
            if ( IsPlayerInRangeOfPoint( playerid, 15.0, 1002.49169922, -2106.39648438, 14.14295101 ) )
            {
                if ( objGateState )
                    return SendClientMessage( playerid, -1, "Gate is already opened." );

                 MoveObject( objGate, 1006.49169922, -2104.39648438, 6.14295101, 1.500000 );

                 objGateState = true;
             }
             else return SendClientMessage( playerid, -1, "You aren't near of the gate." ):
         }
         else return SendClientMessage( playerid, -1, "You aren't Chicken0985." );

         return 1;
    }

    if ( !strcmp( cmdtext, "/closemaingate", true  ) )
    {
        if ( PlayerNameIs( playerid, "Chicken0895" ) )
        {
            if ( IsPlayerInRangeOfPoint( playerid, 15.0, 1002.49169922, -2106.39648438, 14.14295101 ) )
            {
                if ( !objGateState )
                    return SendClientMessage( playerid, -1, "Gate is already closed." );

                 MoveObject( objGate, 1006.49169922, -2104.39648438, 12.14295101, 1.500000 );

                 objGateState = false;
             }

             else return SendClientMessage( playerid, -1, "You aren't near of the gate." ):
         }

         else return SendClientMessage( playerid, -1, "You aren't Chicken0985." );

         return 1;
    }

    return 0;
}
Try this one.
Thanks, but then I get all these:

C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(6) : warning 235: public function lacks forward declaration (symbol "OnFilterScriptInit")
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn( : error 017: undefined symbol "CreateObject"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(13) : warning 235: public function lacks forward declaration (symbol "OnFilterScriptExit")
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(15) : error 017: undefined symbol "DestroyObject"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(20) : warning 235: public function lacks forward declaration (symbol "OnPlayerCommandText")
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(22) : error 017: undefined symbol "strcmp"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(24) : error 017: undefined symbol "PlayerNameIs"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(26) : error 017: undefined symbol "IsPlayerInRangeOfPoint"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(29) : error 017: undefined symbol "SendClientMessage"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(31) : warning 217: loose indentation
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(31) : error 017: undefined symbol "MoveObject"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(35) : error 017: undefined symbol "SendClientMessage"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(35) : warning 217: loose indentation
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(35) : error 029: invalid expression, assumed zero
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(37) : error 017: undefined symbol "SendClientMessage"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(39) : warning 217: loose indentation
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(42) : error 017: undefined symbol "strcmp"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(44) : error 017: undefined symbol "PlayerNameIs"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(46) : error 017: undefined symbol "IsPlayerInRangeOfPoint"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(49) : error 017: undefined symbol "SendClientMessage"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(51) : warning 217: loose indentation
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(51) : error 017: undefined symbol "MoveObject"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(56) : error 017: undefined symbol "SendClientMessage"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(56) : warning 217: loose indentation
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(56) : error 029: invalid expression, assumed zero
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(59) : error 017: undefined symbol "SendClientMessage"
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn(61) : warning 217: loose indentation
C:\Users\.\Desktop\SA-MP Server\filterscripts\cliffhousegates2.pwn( : warning 204: symbol is assigned a value that is never used: "objGate"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


18 Errors.
Reply
#4

If you don't get the message, you have to check if you put the right coordinate

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/openmaingate", true) == 0)
    {
        if(PlayerNameIs(playerid, "Chicken0895"))
        {                                              
            if(IsPlayerInRangeOfPoint(15.0, playerid,1002.49169922,-2106.39648438,14.14295101))
            {
                SendClientMessage(playerid,0,"Opened");
                MoveObject(987, 1006.49169922,-2104.39648438,6.14295101, 1.500000);  
                return 1;
            }    
        }                                                                        
    }                                                                          
    if(strcmp(cmdtext,"/closemaingate", true) == 0)
    {                                                                            
        if(PlayerNameIs(playerid, "Chicken0895"))
        {                                                                            
            if(IsPlayerInRangeOfPoint(15.0, playerid,1002.49169922,-2106.39648438,14.14295101))
            {
                SendClientMessage(playerid,0,"Closed");
                MoveObject(987, 1006.49169922,-2104.39648438,12.14295101, 1.500000);
                return 1;
            }
        }
    }
    return 0;
}
Reply
#5

Ahaha

pawn Код:
// Add this on top of the script
#define FILTERSCRIPT
#include < a_samp >
#include < easyNames >
Duh
Reply
#6

Quote:
Originally Posted by Basicz
Посмотреть сообщение
Ahaha

pawn Код:
// Add this on top of the script
#define FILTERSCRIPT
#include < a_samp >
#include < easyNames >
Duh
I am a dumb-ass. It now works perfectly. Thanks for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)