Moving Gate Help
#1

PHP Code:
#include a_samp
#include zcmd
#include Dini
#define MAX_GATES                       20
#define GATE_OBJECT                     980
#define GATE_STATE_CLOSED       0
#define GATE_STATE_OPEN         1
enum fs_gates
{
        
gCreated,
        
Float:gX,
        
Float:gY,
        
Float:gZ,
        
Float:gA,
        
gObject,
        
gPlacedBy[24],
        
gStatus,
        
gPassword
}
new 
GateInfo[MAX_GATES][fs_gates];
CMD:placegateplayeridparams[] )
{
        if( 
isnullparams) )
            return 
SendClientMessageplayerid, -1"Syntax: /placegate [password]" );
        if( !
strvalparams ) )
            return 
SendClientMessageplayerid, -1"You need to input numbers." );
        if( 
IsPlayerInAnyVehicleplayerid ) )
            return 
SendClientMessageplayerid, -1"You need to exit your vehicle." );
        new 
Float:pPos[4];
        
GetPlayerPosplayeridpPos[0], pPos[1], pPos[2] );
        
GetPlayerFacingAngleplayeridpPos[3] );
        
CreateGateplayeridstrvalparams ), pPos[0], pPos[1], pPos[2], pPos[3] );
        
SendClientMessageplayerid, -1"You succesfully created a movable gate. Use /gopen or /gclose." );
        return 
1;
}
CMD:gopenplayeridparams[] )
{
        if( 
isnullparams ) )
            return 
SendClientMessageplayerid, -1"Syntax: /gopen [password]" );
        new 
szName[24], gate = -1;
        
GetPlayerNameplayeridszName24 );
        for( new 
0!= MAX_GATESi++ )
                if( 
GateInfo[i][gCreated] == )
                        if( 
strvalparams ) == GateInfo[i][gPassword] )
                                { 
gate i; break; }
        if( 
gate != -)
        {
            if( !
IsObjectMovingGateInfo[gate][gObject] ) )
            {
                if( 
IsPlayerInRangeOfPointplayerid10.0GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ] ) )
                        {
                                if( 
GateInfo[gate][gStatus] == GATE_STATE_CLOSED )
                        {
                                    
MoveObjectGateInfo[gate][gObject], GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ]-5.37.0 );
                                        
SendClientMessageplayerid, -1"You opened the gate." );
                                }
                                else
                                return 
SendClientMessageplayerid, -1"The gate is already open." );
                        }
                        else
                        return 
SendClientMessageplayerid, -1"You're not near any gate." );
        }
        else
                return 
SendClientMessageplayerid, -1"You must wait untill the gate has moved." );
        }
        else
            return 
SendClientMessageplayerid, -1"Invalid password." );
        return 
1;
}
CMD:gcloseplayeridparams[] )
{
        if( 
isnullparams ) )
            return 
SendClientMessageplayerid, -1"Syntax: /gclose [password]" );
        new 
szName[24], gate = -1;
        
GetPlayerNameplayeridszName24 );
        for( new 
0!= MAX_GATESi++ )
                if( 
GateInfo[i][gCreated] == )
                        if( 
strvalparams ) == GateInfo[i][gPassword] )
                                { 
gate i; break; }
        if( 
gate != -)
        {
            if( !
IsObjectMovingGateInfo[gate][gObject] ) )
            {
                if( 
IsPlayerInRangeOfPointplayerid10.0GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ] ) )
                        {
                                if( 
GateInfo[gate][gStatus] == GATE_STATE_OPEN )
                        {
                                    
MoveObjectGateInfo[gate][gObject], GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ]+5.37.0 );
                                        
SendClientMessageplayerid, -1"You closed the gate." );
                                }
                                else
                                return 
SendClientMessageplayerid, -1"The gate is already closed." );
                        }
                        else
                                return 
SendClientMessageplayerid, -1"You're not near any gate." );
        }
        else
                return 
SendClientMessageplayerid, -1"You must wait untill the gate has moved." );
        }
        else
            return 
SendClientMessageplayerid, -1"Invalid password." );
        return 
1;
}
CMD:removegateplayeridparams[] )
{
        for( new 
0!= MAX_GATESi++ )
        {
                if( 
GateInfo[i][gCreated] == )
                {
                    if( 
IsPlayerInRangeOfPointplayerid10.0GateInfo[i][gX], GateInfo[i][gY], GateInfo[i][gZ] ) )
                        {
                                new 
szName[24];
                                
GetPlayerNameplayeridszName24 );
                                if( !
strcmpszNameGateInfo[i][gPlacedBy], true ) || IsPlayerAdminplayerid ) )
                                {
                                        
DestroyObjectGateInfo[i][gObject] );
                                        
formatGateInfo[i][gPlacedBy], 24"None" );
                                
GateInfo[i][gCreated] = 0;
                                
GateInfo[i][gX] = 0.0;
                                
GateInfo[i][gY] = 0.0;
                                
GateInfo[i][gZ] = 0.0;
                                
GateInfo[i][gA] = 0.0;
                                
GateInfo[i][gPassword] = 0;
                                
GateInfo[i][gStatus] = GATE_STATE_CLOSED;
                                
SendClientMessageplayerid, -1"You removed the gate." );
                                        new 
file[32];
                                        
formatfile32"Gates/gate_%d.ini");
                                        if( 
dini_Existsfile ) )
                                        
dini_Removefile );
                                        break;
                }
                                else
                                        return 
SendClientMessageplayerid, -1"You don't own this gate." );
                        }
                        else
                                return 
SendClientMessageplayerid, -1"You're not near any gate." );
        }
    }
        return 
1;
}
CMD:gateinfoplayeridparams[] )
{
        if( 
IsPlayerAdminplayerid ) )
        {
                for( new 
0!= MAX_GATESi++ )
                {
                        if( 
GateInfo[i][gCreated] == )
                        {
                            if( 
IsPlayerInRangeOfPointplayerid5.0GateInfo[i][gX], GateInfo[i][gY], GateInfo[i][gZ] ) )
                                {
                                        new 
szString[128];
                                        
formatszString128"Gate Info( Placed by: %s | Password: %d)"GateInfo[i][gPlacedBy], GateInfo[i][gPassword] );
                                        
SendClientMessageplayerid, -1szString );
                                        return 
1;
                                }
                                else
                                        return 
SendClientMessageplayerid, -1"You're not near any gate." );
                }
            }
    }
        else
                return 
SendClientMessageplayerid, -1"You're not an admin." );
        return 
1;
}
public 
OnFilterScriptInit( )
{
        for( new 
0!= MAX_GATESi++ )
        {
            if( 
GateInfo[i][gCreated] == )
            {
                        new 
file[64];
                        
formatfile64"Gates/gate_%d.ini");
                        if( 
fexistfile ) )
                        {
                            
GateInfo[i][gCreated] = 1;
                                
GateInfo[i][gX] = dini_Floatfile"X" );
                                
GateInfo[i][gY] = dini_Floatfile"Y" );
                                
GateInfo[i][gZ] = dini_Floatfile"Z" );
                                
GateInfo[i][gA] = dini_Floatfile"A" );
                                
GateInfo[i][gStatus] = dini_Intfile"Status" );
                                
GateInfo[i][gPassword] = dini_Intfile"Password" );
                                
formatGateInfo[i][gPlacedBy], 24dini_Getfile"PlacedBy" ) );
                                
GateInfo[i][gObject] = CreateObjectGATE_OBJECTGateInfo[i][gX], GateInfo[i][gY], GateInfo[i][gZ], 00GateInfo[i][gA] );
            }
        }
    }
        return 
1;
}
public 
OnFilterScriptExit( )
{
        for( new 
0!= MAX_GATESi++ )
        {
            if( 
GateInfo[i][gCreated] == )
            {
                        new 
file[64];
                        
formatfile64"Gates/gate_%d.ini");
                        if( 
fexistfile ) )
                        {
                                
dini_IntSetfile"Object"GateInfo[i][gObject] );
                                
dini_FloatSetfile"X"GateInfo[i][gX] );
                                
dini_FloatSetfile"Y"GateInfo[i][gY] );
                                
dini_FloatSetfile"Z"GateInfo[i][gZ] );
                                
dini_FloatSetfile"A"GateInfo[i][gA] );
                                
dini_IntSetfile"Status"GateInfo[i][gStatus] );
                                
dini_IntSetfile"Password"GateInfo[i][gPassword] );
                                
dini_Setfile"PlacedBy"GateInfo[i][gPlacedBy] );
                                
DestroyObjectGateInfo[i][gObject] );
                                
formatGateInfo[i][gPlacedBy], 24"None" );
                        
GateInfo[i][gCreated] = 0;
                        
GateInfo[i][gX] = 0.0;
                        
GateInfo[i][gY] = 0.0;
                        
GateInfo[i][gZ] = 0.0;
                        
GateInfo[i][gA] = 0.0;
                        
GateInfo[i][gStatus] = GATE_STATE_CLOSED;
            }
        }
    }
        return 
1;
}
public 
OnObjectMovedobjectid )
{
        for( new 
0!= MAX_GATESi++ )
        {
            if( 
GateInfo[i][gCreated] == )
            {
                if( 
GateInfo[i][gObject] == objectid )
                {
                    if( 
GateInfo[i][gStatus] == GATE_STATE_CLOSED )
                        
GateInfo[i][gStatus] = GATE_STATE_OPEN;
                                else if( 
GateInfo[i][gStatus] == GATE_STATE_OPEN )
                                    
GateInfo[i][gStatus] = GATE_STATE_CLOSED;
                                
// Update the variables.
                                
new Float:oPos[3];
                                
GetObjectPosobjectidoPos[0], oPos[1], oPos[2] );
                                
GateInfo[i][gX] = oPos[0];
                        
GateInfo[i][gY] = oPos[1];
                        
GateInfo[i][gZ] = oPos[2];
                                break;
            }
        }
    }
    return 
1;
}
stock CreateGateplayeridpasswordFloat:xFloat:yFloat:zFloat:)
{
        for( new 
0!= MAX_GATESi++ )
        {
            if( 
GateInfo[i][gCreated] == )
            {
                        new 
szName[24];
                        
GetPlayerNameplayeridszName24 );
                        
GateInfo[i][gObject] = CreateObjectGATE_OBJECTxyz+1.500);
                        
formatGateInfo[i][gPlacedBy], 24"%s"szName );
                
GateInfo[i][gCreated] = 1;
                
GateInfo[i][gX] = x;
                
GateInfo[i][gY] = y;
                
GateInfo[i][gZ] = z+1.5// comment the +1.5 if you're not using object 980.
                
GateInfo[i][gA] = a;
                        
GateInfo[i][gStatus] = GATE_STATE_CLOSED;
                        
GateInfo[i][gPassword] = password;
                        
SetPlayerPosplayeridx+1y+1);
                        new 
file[64];
                        
formatfile64"Gates/gate_%d.ini");
                        if( !
fexistfile ) )
                        {
                            
dini_Createfile );
                                
dini_IntSetfile"Object"GateInfo[i][gObject] );
                                
dini_FloatSetfile"X"GateInfo[i][gX] );
                                
dini_FloatSetfile"Y"GateInfo[i][gY] );
                                
dini_FloatSetfile"Z"GateInfo[i][gZ] );
                                
dini_FloatSetfile"A"GateInfo[i][gA] );
                                
dini_IntSetfile"Status"GateInfo[i][gStatus] );
                                
dini_Setfile"PlacedBy"GateInfo[i][gPlacedBy] );
            }
                        break;
        }
    }

So this is code i see it here in samp

so all i want to do it only admin lvl 6 can use this [pAdmin]
All of cmd given by me !

thanks in advance ! i will give you +rep
Reply


Messages In This Thread
Moving Gate Help - by ChuckyBabe - 08.03.2014, 00:49
Re: Moving Gate Help - by Keyhead - 08.03.2014, 00:56
Re: Moving Gate Help - by ChuckyBabe - 08.03.2014, 01:04
Re: Moving Gate Help - by ChuckyBabe - 08.03.2014, 01:10
Re: Moving Gate Help - by ChuckyBabe - 08.03.2014, 01:14
Re: Moving Gate Help - by Pottus - 08.03.2014, 02:15

Forum Jump:


Users browsing this thread: 2 Guest(s)