Hali!
Találtam egy jó gate készítõt ami ingame csinálja és elég könnyû kezelni és maga a szkript is egyszerûnek tûnt. Persze amíg mûködött...
Szóval itt az eredeti:
http://pastebin.com/862f9RhNItt az enyém. Amiben hozzáadtam egy dialogot, hogy én választhassam meg a gate objectjét. De nem mûködik...
#include a_samp
#include zcmd
#include Dini
#define DIALOG_x 1
#define MAX_GATES 20
//#define GATE_OBJECT 980
#define GATE_STATE_CLOSED 0
#define GATE_STATE_OPEN 1
new GATE_OBJECT;
enum fs_gates
{
gCreated,
Float:gX,
Float:gY,
Float:gZ,
Float:gA,
gObject,
gPlacedBy[24],
gStatus,
gPassword
}
new GateInfo[MAX_GATES][fs_gates];
COMMAND:model(playerid, params[])
{
ShowPlayerDialog(playerid, DIALOG_x, DIALOG_STYLE_INPUT, \"GATE\'S MODEL:\", \"Type it:\", \"Submit\", \"Cancel\");
return 1;
}
CMD:placegate( 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 Float:pPos[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[gCreated] == 1 )
if( strval( params ) == GateInfo[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[gCreated] == 1 )
if( strval( params ) == GateInfo[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[gCreated] == 1 )
{
if( IsPlayerInRangeOfPoint( playerid, 10.0, GateInfo[gX], GateInfo[gY], GateInfo[gZ] ) )
{
new szName[24];
GetPlayerName( playerid, szName, 24 );
if( !strcmp( szName, GateInfo[gPlacedBy], true ) || IsPlayerAdmin( playerid ) )
{
DestroyObject( GateInfo[gObject] );
format( GateInfo[gPlacedBy], 24, \"None\" );
GateInfo[gCreated] = 0;
GateInfo[gX] = 0.0;
GateInfo[gY] = 0.0;
GateInfo[gZ] = 0.0;
GateInfo[gA] = 0.0;
GateInfo[gPassword] = 0;
GateInfo[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[gCreated] == 1 )
{
if( IsPlayerInRangeOfPoint( playerid, 5.0, GateInfo[gX], GateInfo[gY], GateInfo[gZ] ) )
{
new szString[128];
format( szString, 128, \"Gate Info( Placed by: %s | Password: %d)\", GateInfo[gPlacedBy], GateInfo[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[gCreated] == 0 )
{
new file[64];
format( file, 64, \"Gates/gate_%d.ini\", i );
if( fexist( file ) )
{
GateInfo[gCreated] = 1;
GateInfo[gX] = dini_Float( file, \"X\" );
GateInfo[gY] = dini_Float( file, \"Y\" );
GateInfo[gZ] = dini_Float( file, \"Z\" );
GateInfo[gA] = dini_Float( file, \"A\" );
GateInfo[gStatus] = dini_Int( file, \"Status\" );
GateInfo[gPassword] = dini_Int( file, \"Password\" );
format( GateInfo[gPlacedBy], 24, dini_Get( file, \"PlacedBy\" ) );
GateInfo[gObject] = CreateObject( GATE_OBJECT, GateInfo[gX], GateInfo[gY], GateInfo[gZ], 0, 0, GateInfo[gA] );
}
}
}
return 1;
}
public OnFilterScriptExit( )
{
for( new i = 0; i != MAX_GATES; i++ )
{
if( GateInfo[gCreated] == 1 )
{
new file[64];
format( file, 64, \"Gates/gate_%d.ini\", i );
if( fexist( file ) )
{
dini_IntSet( file, \"Object\", GateInfo[gObject] );
dini_FloatSet( file, \"X\", GateInfo[gX] );
dini_FloatSet( file, \"Y\", GateInfo[gY] );
dini_FloatSet( file, \"Z\", GateInfo[gZ] );
dini_FloatSet( file, \"A\", GateInfo[gA] );
dini_IntSet( file, \"Status\", GateInfo[gStatus] );
dini_IntSet( file, \"Password\", GateInfo[gPassword] );
dini_Set( file, \"PlacedBy\", GateInfo[gPlacedBy] );
DestroyObject( GateInfo[gObject] );
format( GateInfo[gPlacedBy], 24, \"None\" );
GateInfo[gCreated] = 0;
GateInfo[gX] = 0.0;
GateInfo[gY] = 0.0;
GateInfo[gZ] = 0.0;
GateInfo[gA] = 0.0;
GateInfo[gStatus] = GATE_STATE_CLOSED;
}
}
}
return 1;
}
public OnObjectMoved( objectid )
{
for( new i = 0; i != MAX_GATES; i++ )
{
if( GateInfo[gCreated] == 1 )
{
if( GateInfo[gObject] == objectid )
{
if( GateInfo[gStatus] == GATE_STATE_CLOSED )
GateInfo[gStatus] = GATE_STATE_OPEN;
else if( GateInfo[gStatus] == GATE_STATE_OPEN )
GateInfo[gStatus] = GATE_STATE_CLOSED;
// Update the variables.
new Float:oPos[3];
GetObjectPos( objectid, oPos[0], oPos[1], oPos[2] );
GateInfo[gX] = oPos[0];
GateInfo[gY] = oPos[1];
GateInfo[gZ] = oPos[2];
break;
}
}
}
return 1;
}
stock CreateGate( playerid, password, Float:x, Float:y, Float:z, Float:a )
{
for( new i = 0; i != MAX_GATES; i++ )
{
if( GateInfo[gCreated] == 0 )
{
new szName[24];
GetPlayerName( playerid, szName, 24 );
GateInfo[gObject] = CreateObject( GATE_OBJECT, x, y, z+1.5, 0, 0, a );
format( GateInfo[gPlacedBy], 24, \"%s\", szName );
GateInfo[gCreated] = 1;
GateInfo[gX] = x;
GateInfo[gY] = y;
GateInfo[gZ] = z+1.5; // comment the +1.5 if you\'re not using object 980.
GateInfo[gA] = a;
GateInfo[gStatus] = GATE_STATE_CLOSED;
GateInfo[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[gObject] );
dini_FloatSet( file, \"X\", GateInfo[gX] );
dini_FloatSet( file, \"Y\", GateInfo[gY] );
dini_FloatSet( file, \"Z\", GateInfo[gZ] );
dini_FloatSet( file, \"A\", GateInfo[gA] );
dini_IntSet( file, \"Status\", GateInfo[gStatus] );
dini_Set( file, \"PlacedBy\", GateInfo[gPlacedBy] );
}
break;
}
}
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_x)
{
if(response == 1)
{
//=inputtext[20];
GATE_OBJECT=strval(inputtext);
}
else
{
SendClientMessage(playerid, 0xEB000FFF, \":(\");
}
return 1;
}
return 1;
}
A probléma pedig a következõ. Megadom az ID-t. Majd /gateplace és nem rak le semmit. Illetve a camera kicsit közelebb jön mintha még is lerakott volna valamit. De nincs ott semmi. Megnéztem h hátha a földbe rakja de nem...
Kérlek segítsetek! :$