auto close
#1

can somebody help me to change this code

Код:
gate =CreateObject(980, 2287.30004883, 605.29998779, 12.50,0.0, 0.0, 359.98901367); //object(airportgate) (1)
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/Open", cmdtext, true, 10) == 0)
{
	    MoveObject(gate, 2287.30004883, 605.29998779, 6.50, 7);
return 1;
}
if (strcmp("/ohouse", cmdtext, true,10) == 0)
{
SetPlayerPos(playerid,837.1106, -1875.3643, 13.4764);
return 1;
}
if (strcmp("/close", cmdtext, true, 10) == 0)
{
MoveObject(gate,2287.30004883, 605.29998779, 12.50,7);
return 1;
		}
	return 0;
Reply
#2

Set a repeating timer to check if anyone I'd near the gate. If not - close.
Reply
#3

Quote:
Originally Posted by hydronic
Посмотреть сообщение
can somebody help me to change this code

Код:
gate =CreateObject(980, 2287.30004883, 605.29998779, 12.50,0.0, 0.0, 359.98901367); //object(airportgate) (1)
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/Open", cmdtext, true, 10) == 0)
{
	    MoveObject(gate, 2287.30004883, 605.29998779, 6.50, 7);
return 1;
}
if (strcmp("/ohouse", cmdtext, true,10) == 0)
{
SetPlayerPos(playerid,837.1106, -1875.3643, 13.4764);
return 1;
}
if (strcmp("/close", cmdtext, true, 10) == 0)
{
MoveObject(gate,2287.30004883, 605.29998779, 12.50,7);
return 1;
		}
	return 0;

pawn Код:
gate = CreateObject(980, 2287.30004883, 605.29998779, 12.50,0.0, 0.0, 359.98901367); //object(airportgate) (1)

public OnPlayerUpdate(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 25.0, 2287.30004883, 605.29998779, 12.50))
    {
        MoveObject(gate, 2287.30004883, 605.29998779, 6.50, 7);
    }
    else
    {
        MoveObject(gate,2287.30004883, 605.29998779, 12.50,7);
    }
    return 1;
}
Reply
#4

pawn Код:
new gate; //On top of script..

//Inside OnGameModeInit or OnFilterScriptInit:
gate = CreateObject(980, 2287.30004883, 605.29998779, 12.50,0.0, 0.0, 359.98901367); //object(airportgate) (1)

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/Open", cmdtext, true, 5) == 0)
    {
        MoveObject(gate, 2287.30004883, 605.29998779, 6.50, 7);
        return 1;
    }
    if (strcmp("/ohouse", cmdtext, true, 7) == 0)
    {
        SetPlayerPos(playerid,837.1106, -1875.3643, 13.4764);
        return 1;
    }
    if (strcmp("/close", cmdtext, true, 6) == 0)
    {
        MoveObject(gate,2287.30004883, 605.29998779, 12.50,7);
        return 1;
    }
    return 0;
}
Reply
#5

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
pawn Код:
gate = CreateObject(980, 2287.30004883, 605.29998779, 12.50,0.0, 0.0, 359.98901367); //object(airportgate) (1)

public OnPlayerUpdate(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 25.0, 2287.30004883, 605.29998779, 12.50))
    {
        MoveObject(gate, 2287.30004883, 605.29998779, 6.50, 7);
    }
    else
    {
        MoveObject(gate,2287.30004883, 605.29998779, 12.50,7);
    }
    return 1;
}


yes but i needed for open with /open..... and autoclose not only auto open and close
Reply
#6

So you want to /open then let it auto close?
Reply
#7

Quote:
Originally Posted by Tee
Посмотреть сообщение
So you want to /open then let it auto close?

yes i want to make gate with /open and close automatic
Reply
#8

here is the code

PHP код:
public OnGameModeInit
gate 
CreateObject(9802287.30004883605.2999877912.50,0.00.0359.98901367); //
public OnPlayerCommandText(playeridcmdtext[])
{
if (
strcmp("/Open"cmdtexttrue10) == 0)
{
    
MoveObject(gate,2287.30004883605.299987796.507);// 7 is thespeed of opening the gate
    
return 1;
    }
    if (
strcmp("/ohouse"cmdtexttrue,10) == 0)
    {
    
SetPlayerPos(playerid,837.1106, -1875.364313.4764);
    return 
1;
    }
return 
0;
}
public 
OnPlayerUpdate(playerid)
{
    if(
IsPlayerInRangeOfPoint(playerid,5here the coords of the position where you will the gate starts to close))//5 is the range!
    
{
        
MoveObject(gate2287.30004883605.2999877912.507);//7 is thespeed of opening the gate
    
}
    return 
1;

Reply
#9

Quote:
Originally Posted by Pasa
Посмотреть сообщение
here is the code

PHP код:
public OnGameModeInit
gate 
CreateObject(9802287.30004883605.2999877912.50,0.00.0359.98901367); //
public OnPlayerCommandText(playeridcmdtext[])
{
if (
strcmp("/Open"cmdtexttrue10) == 0)
{
    
MoveObject(gate,2287.30004883605.299987796.507);// 7 is thespeed of opening the gate
    
return 1;
    }
    if (
strcmp("/ohouse"cmdtexttrue,10) == 0)
    {
    
SetPlayerPos(playerid,837.1106, -1875.364313.4764);
    return 
1;
    }
return 
0;
}
public 
OnPlayerUpdate(playerid)
{
    if(
IsPlayerInRangeOfPoint(playerid,5here the coords of the position where you will the gate starts to close))//5 is the range!
    
{
        
MoveObject(gate2287.30004883605.2999877912.507);//7 is thespeed of opening the gate
    
}
    return 
1;

That auto opens it too.

pawn Код:
public OnGameModeInit( ) {
    gate = CreateObject( 980, 2287.30004883, 605.29998779, 12.50,0.0, 0.0, 359.98901367 );
    SetTimer( "gatecheck", 1000, 1 );
    return true;
}

public OnPlayerCommandText( playerid, cmdtext[ ] ) {
    if( !strcmp( cmdtext, "/open", true, 5 ) )
        return MoveObject( gate, 2287.30004883, 605.29998779, 6.50, 7 ), true;
    return false;
}

forward gatecheck( );
public gatecheck( ) {
    new
        Float:x
        ,Float:y
        ,Float:z
        ,c = 0
    ;
    GetObjectPos( gate, x, y, z );
    if( x != 2287.30004883 && y != 605.29998779 && z != 12.50 ) {
        for( new i = 0; i < MAX_PLAYERS; i++ )
            if( IsPlayerInRangeOfPoint( i, 5.0, x, y, z ) )
                c++;
            if( c == 0 )
                MoveObject( gate, 2287.30004883, 605.29998779, 12.50, 7 );
    }
    return true;
}
Untested.
Reply
#10

Quote:
Originally Posted by Mean
Посмотреть сообщение
That auto opens it too.

pawn Код:
public OnGameModeInit( ) {
    gate = CreateObject( 980, 2287.30004883, 605.29998779, 12.50,0.0, 0.0, 359.98901367 );
    SetTimer( "gatecheck", 1000, 1 );
    return true;
}

public OnPlayerCommandText( playerid, cmdtext[ ] ) {
    if( !strcmp( cmdtext, "/open", true, 5 ) )
        return MoveObject( gate, 2287.30004883, 605.29998779, 6.50, 7 ), true;
    return false;
}

forward gatecheck( );
public gatecheck( ) {
    new
        Float:x
        ,Float:y
        ,Float:z
        ,c = 0
    ;
    GetObjectPos( gate, x, y, z );
    if( x != 2287.30004883 && y != 605.29998779 && z != 12.50 ) {
        for( new i = 0; i < MAX_PLAYERS; i++ )
            if( IsPlayerInRangeOfPoint( i, 5.0, x, y, z ) )
                c++;
            if( c == 0 )
                MoveObject( gate, 2287.30004883, 605.29998779, 12.50, 7 );
    }
    return true;
}
Untested.
tnx now i have... cripts.... tnx alll so much
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)