[FilterScript] FS:Gates - Dynamic Movable Gates System
#41

//I noticed some issues with "waring 217" so i fixed it , your welcome and enjoy //

#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];


CMDlacegate( playerid, params[] )

{

if( isnull( params) )

return SendClientMessage( playerid, -1, "Syntax: /placegate [password]" );


if( !strval( params ) )

return SendClientMessage( playerid, -1, "You need to input numbers." );


if( IsPlayerInAnyVehicle( playerid ) )

return SendClientMessage( playerid, -1, "You need to exit your vehicle." );


new FloatPos[4];

GetPlayerPos( playerid, pPos[0], pPos[1], pPos[2] );

GetPlayerFacingAngle( playerid, pPos[3] );

CreateGate( playerid, strval( params ), pPos[0], pPos[1], pPos[2], pPos[3] );

SendClientMessage( playerid, -1, "You succesfully created a movable gate. Use /gopen or /gclose." );


return 1;

}


CMD:gopen( playerid, params[] )

{

if( isnull( params ) )

return SendClientMessage( playerid, -1, "Syntax: /gopen [password]" );


new szName[24], gate = -1;

GetPlayerName( playerid, szName, 24 );

for( new i = 0; i != MAX_GATES; i++ )

if( GateInfo[i][gCreated] == 1 )

if( strval( params ) == GateInfo[i][gPassword] )

{ gate = i; break; }


if( gate != -1 )

{

if( !IsObjectMoving( GateInfo[gate][gObject] ) )

{

if( IsPlayerInRangeOfPoint( playerid, 10.0, GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ] ) )

{

if( GateInfo[gate][gStatus] == GATE_STATE_CLOSED )

{

MoveObject( GateInfo[gate][gObject], GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ]-5.3, 7.0 );

SendClientMessage( playerid, -1, "You opened the gate." );

}


else

return SendClientMessage( playerid, -1, "The gate is already open." );

}


else

return SendClientMessage( playerid, -1, "You\'re not near any gate." );

}


else

return SendClientMessage( playerid, -1, "You must wait untill the gate has moved." );

}


else

return SendClientMessage( playerid, -1, "Invalid password." );


return 1;

}


CMD:gclose( playerid, params[] )

{

if( isnull( params ) )

return SendClientMessage( playerid, -1, "Syntax: /gclose [password]" );


new szName[24], gate = -1;

GetPlayerName( playerid, szName, 24 );

for( new i = 0; i != MAX_GATES; i++ )

if( GateInfo[i][gCreated] == 1 )

if( strval( params ) == GateInfo[i][gPassword] )

{ gate = i; break; }


if( gate != -1 )

{

if( !IsObjectMoving( GateInfo[gate][gObject] ) )

{

if( IsPlayerInRangeOfPoint( playerid, 10.0, GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ] ) )

{

if( GateInfo[gate][gStatus] == GATE_STATE_OPEN )

{

MoveObject( GateInfo[gate][gObject], GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ]+5.3, 7.0 );

SendClientMessage( playerid, -1, "You closed the gate." );

}


else

return SendClientMessage( playerid, -1, "The gate is already closed." );

}


else

return SendClientMessage( playerid, -1, "You\'re not near any gate." );

}


else

return SendClientMessage( playerid, -1, "You must wait untill the gate has moved." );

}


else

return SendClientMessage( playerid, -1, "Invalid password." );


return 1;

}


CMD:removegate( playerid, params[] )

{

for( new i = 0; i != MAX_GATES; i++ )

{

if( GateInfo[i][gCreated] == 1 )

{

if( IsPlayerInRangeOfPoint( playerid, 10.0, GateInfo[i][gX], GateInfo[i][gY], GateInfo[i][gZ] ) )

{

new szName[24];

GetPlayerName( playerid, szName, 24 );

if( !strcmp( szName, GateInfo[i][gPlacedBy], true ) || IsPlayerAdmin( playerid ) )

{

DestroyObject( GateInfo[i][gObject] );

format( GateInfo[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;

SendClientMessage( playerid, -1, "You removed the gate." );


new file[32];

format( file, 32, "Gates/gate_%d.ini", i );

if( dini_Exists( file ) )

dini_Remove( file );

break;

}


else

return SendClientMessage( playerid, -1, "You don\'t own this gate." );

}


else

return SendClientMessage( playerid, -1, "You\'re not near any gate." );

}

}


return 1;

}


CMD:gateinfo( playerid, params[] )

{

if( IsPlayerAdmin( playerid ) )

{

for( new i = 0; i != MAX_GATES; i++ )

{

if( GateInfo[i][gCreated] == 1 )

{

if( IsPlayerInRangeOfPoint( playerid, 5.0, GateInfo[i][gX], GateInfo[i][gY], GateInfo[i][gZ] ) )

{

new szString[128];

format( szString, 128, "Gate Info( Placed by: %s | Password: %d)", GateInfo[i][gPlacedBy], GateInfo[i][gPassword] );

SendClientMessage( playerid, -1, szString );

return 1;

}


else

return SendClientMessage( playerid, -1, "You\'re not near any gate." );

}

}

}


else

return SendClientMessage( playerid, -1, "You\'re not an admin." );

return 1;

}


public OnFilterScriptInit( )

{

for( new i = 0; i != MAX_GATES; i++ )

{

if( GateInfo[i][gCreated] == 0 )

{

new file[64];

format( file, 64, "Gates/gate_%d.ini", i );

if( fexist( file ) )

{

GateInfo[i][gCreated] = 1;

GateInfo[i][gX] = dini_Float( file, "X" );

GateInfo[i][gY] = dini_Float( file, "Y" );

GateInfo[i][gZ] = dini_Float( file, "Z" );

GateInfo[i][gA] = dini_Float( file, "A" );

GateInfo[i][gStatus] = dini_Int( file, "Status" );

GateInfo[i][gPassword] = dini_Int( file, "Password" );

format( GateInfo[i][gPlacedBy], 24, dini_Get( file, "PlacedBy" ) );

GateInfo[i][gObject] = CreateObject( GATE_OBJECT, GateInfo[i][gX], GateInfo[i][gY], GateInfo[i][gZ], 0, 0, GateInfo[i][gA] );

}

}

}


return 1;

}


public OnFilterScriptExit( )

{

for( new i = 0; i != MAX_GATES; i++ )

{

if( GateInfo[i][gCreated] == 1 )

{

new file[64];

format( file, 64, "Gates/gate_%d.ini", i );

if( fexist( file ) )

{

dini_IntSet( file, "Object", GateInfo[i][gObject] );

dini_FloatSet( file, "X", GateInfo[i][gX] );

dini_FloatSet( file, "Y", GateInfo[i][gY] );

dini_FloatSet( file, "Z", GateInfo[i][gZ] );

dini_FloatSet( file, "A", GateInfo[i][gA] );

dini_IntSet( file, "Status", GateInfo[i][gStatus] );

dini_IntSet( file, "Password", GateInfo[i][gPassword] );

dini_Set( file, "PlacedBy", GateInfo[i][gPlacedBy] );

DestroyObject( GateInfo[i][gObject] );

format( GateInfo[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 OnObjectMoved( objectid )

{

for( new i = 0; i != MAX_GATES; i++ )

{

if( GateInfo[i][gCreated] == 1 )

{

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 FloatPos[3];

GetObjectPos( objectid, oPos[0], oPos[1], oPos[2] );

GateInfo[i][gX] = oPos[0];

GateInfo[i][gY] = oPos[1];

GateInfo[i][gZ] = oPos[2];

break;

}

}

}

return 1;

}


stock CreateGate( playerid, password, Float, Float:y, Float:z, Float:a )

{

for( new i = 0; i != MAX_GATES; i++ )

{

if( GateInfo[i][gCreated] == 0 )

{

new szName[24];

GetPlayerName( playerid, szName, 24 );


GateInfo[i][gObject] = CreateObject( GATE_OBJECT, x, y, z+1.5, 0, 0, a );

format( GateInfo[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;

SetPlayerPos( playerid, x+1, y+1, z );


new file[64];

format( file, 64, "Gates/gate_%d.ini", i );

if( !fexist( file ) )

{

dini_Create( file );

dini_IntSet( file, "Object", GateInfo[i][gObject] );

dini_FloatSet( file, "X", GateInfo[i][gX] );

dini_FloatSet( file, "Y", GateInfo[i][gY] );

dini_FloatSet( file, "Z", GateInfo[i][gZ] );

dini_FloatSet( file, "A", GateInfo[i][gA] );

dini_IntSet( file, "Status", GateInfo[i][gStatus] );

dini_Set( file, "PlacedBy", GateInfo[i][gPlacedBy] );

}

break;

}

}

}
Reply


Messages In This Thread
FS:Gates - Dynamic Movable Gates System - by Marricio - 26.05.2012, 18:00
Re: FS:Gates - Dynamic Movable Gates System - by se7evolution - 26.05.2012, 18:18
Re: FS:Gates - Dynamic Movable Gates System - by Marricio - 26.05.2012, 18:27
Re: FS:Gates - Dynamic Movable Gates System - by Infinity90 - 26.05.2012, 18:49
Re: FS:Gates - Dynamic Movable Gates System - by admantis - 26.05.2012, 19:13
Re: FS:Gates - Dynamic Movable Gates System - by Kathleen - 26.05.2012, 19:15
Re: FS:Gates - Dynamic Movable Gates System - by Madox123 - 27.05.2012, 11:52
Re: FS:Gates - Dynamic Movable Gates System - by Aleks7 - 27.05.2012, 12:40
Re: FS:Gates - Dynamic Movable Gates System - by Kathleen - 27.05.2012, 12:40
Re: FS:Gates - Dynamic Movable Gates System - by Я@жR - 27.05.2012, 16:09
Re: FS:Gates - Dynamic Movable Gates System - by JordanMaddox - 27.05.2012, 17:03
Re: FS:Gates - Dynamic Movable Gates System - by Marricio - 27.05.2012, 17:54
Re: FS:Gates - Dynamic Movable Gates System - by Я@жR - 27.05.2012, 18:45
Re: FS:Gates - Dynamic Movable Gates System - by Orhun_Kaya - 27.05.2012, 19:07
Re: FS:Gates - Dynamic Movable Gates System - by Darklom - 27.05.2012, 22:56
Re: FS:Gates - Dynamic Movable Gates System - by AndreSAMP - 27.05.2012, 22:57
Re: FS:Gates - Dynamic Movable Gates System - by AndreSAMP - 27.05.2012, 23:06
Re: FS:Gates - Dynamic Movable Gates System - by iFederal - 28.05.2012, 06:29
Re: FS:Gates - Dynamic Movable Gates System - by ParadiseRP - 28.05.2012, 09:20
Re: FS:Gates - Dynamic Movable Gates System - by AndreSAMP - 28.05.2012, 09:48
Re: FS:Gates - Dynamic Movable Gates System - by ParadiseRP - 28.05.2012, 10:00
Re: FS:Gates - Dynamic Movable Gates System - by Marricio - 28.05.2012, 11:01
Re: FS:Gates - Dynamic Movable Gates System - by AndreSAMP - 28.05.2012, 11:32
Re: FS:Gates - Dynamic Movable Gates System - by Geeboi_Mehdi - 28.05.2012, 18:10
Respuesta: Re: FS:Gates - Dynamic Movable Gates System - by Marricio - 28.05.2012, 20:53
Re: FS:Gates - Dynamic Movable Gates System - by $exy - 29.05.2012, 18:53
Re: FS:Gates - Dynamic Movable Gates System - by Marricio - 29.05.2012, 20:29
Re: FS:Gates - Dynamic Movable Gates System - by N0FeaR - 29.05.2012, 22:22
Re: FS:Gates - Dynamic Movable Gates System - by $exy - 30.05.2012, 14:56
Re: FS:Gates - Dynamic Movable Gates System - by $exy - 30.05.2012, 14:59
Re: FS:Gates - Dynamic Movable Gates System - by Genicide[HC4L] - 30.05.2012, 18:11
Re: FS:Gates - Dynamic Movable Gates System - by $exy - 30.05.2012, 18:37
Re: FS:Gates - Dynamic Movable Gates System - by Genicide[HC4L] - 30.05.2012, 19:10
Re: FS:Gates - Dynamic Movable Gates System - by $exy - 30.05.2012, 20:13
Respuesta: FS:Gates - Dynamic Movable Gates System - by Marricio - 30.05.2012, 20:19
Re: FS:Gates - Dynamic Movable Gates System - by Geeboi_Mehdi - 31.05.2012, 20:53
Re: FS:Gates - Dynamic Movable Gates System - by awsomedude - 31.05.2012, 21:19
Re: FS:Gates - Dynamic Movable Gates System - by DwayneVanKom - 16.09.2012, 12:53
Re: FS:Gates - Dynamic Movable Gates System - by ~Pawno~ - 05.10.2012, 11:04
Re: FS:Gates - Dynamic Movable Gates System - by davve95 - 06.10.2012, 18:30
Re: FS:Gates - Dynamic Movable Gates System - by TwTJustin - 08.12.2013, 01:40

Forum Jump:


Users browsing this thread: 2 Guest(s)