@Snake. here you are..but change prefix and set proper model location...it worked for me
Code:
#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < engine >
#include < hamsandwich >
#include < colorchat >
//#pragma tabsize 0
//#pragma semicolon 1
new MapName[32]
new g_SpawnFile[256]
new const g_sPluginInfo[ ][ ] =
{
"DR TP",
"1.1",
"deniS"
};
new const g_sPrefix[ ] = "[Deathrun]";
new const g_sButtonModel[ ] = "models/deathrun/timer/teleport_button.mdl";
new g_pFuncButton, g_pDelayCvar;
new g_iButton;
new g_iButtonAngle;
new const Float: g_fButtonAngles[ 4 ] =
{
90.0,
180.0,
270.0,
360.0
};
new Float: g_fButtonOrigin[ 3 ];
new Float: g_fPlayerOrigin[ 3 ];
new Float: g_fPlayerDelay[ 33 ];
new Float: g_fGameTimeCheck;
public plugin_init( )
{
register_plugin
(
g_sPluginInfo[ 0 ],
g_sPluginInfo[ 1 ],
g_sPluginInfo[ 2 ]
);
register_clcmd( "say /teleport", "DTBM" );
register_clcmd( "say_team /teleport", "DTBM" );
g_pDelayCvar = register_cvar( "deathrun_teleport_delay", "5.0" );
RegisterHam( Ham_Use, "func_button", "fwButtonUsed" );
LoadBTP( );
}
public plugin_precache( )
{
precache_model( g_sButtonModel );
g_pFuncButton = engfunc( EngFunc_AllocString, "func_button" );
new configdir[128]
get_configsdir(configdir, 127 )
new spawndir[256]
format(spawndir,255,"%s/dr_tr",configdir)
if (!dir_exists(spawndir))
{
if (mkdir(spawndir)==0)
{
log_amx("Create [%s] dir successfully finished.",spawndir)
}
else
{
log_error(AMX_ERR_NOTFOUND,"Couldn't create [%s] dir,plugin stoped.",spawndir)
pause("ad")
}
}
get_mapname(MapName, 31)
format(g_SpawnFile, 255, "%s/%s.txt",spawndir, MapName)
}
public DTBM( iClient )
{
if ( !( get_user_flags( iClient ) & ADMIN_RCON ) )
{
ColorChat( iClient, BLUE, "^4%s^1 You don't have access to this command", g_sPrefix );
return PLUGIN_HANDLED;
}
if ( !is_user_alive( iClient ) )
{
ColorChat( iClient, BLUE, "^4%s^1 You must be Alive.", g_sPrefix );
return PLUGIN_HANDLED;
}
new iMenu = menu_create( "DTB Menu", "DTBM_Handler" );
menu_additem( iMenu, "Create button" );
menu_additem( iMenu, "Rotate button" );
menu_additem( iMenu, "Set teleport position" );
menu_additem( iMenu, "Save button & teleport position" );
menu_display( iClient, iMenu, 0 );
return PLUGIN_HANDLED;
}
public DTBM_Handler( iClient, iMenu, iItem )
{
if ( iItem == MENU_EXIT )
{
menu_destroy( iMenu );
return PLUGIN_HANDLED;
}
switch ( iItem )
{
case 0:
{
CreateButton( iClient );
DTBM( iClient );
}
case 1:
{
if ( g_iButtonAngle == 3 )
g_iButtonAngle = 0;
else
g_iButtonAngle++;
new Float: fButtonAngles[ 3 ]; fButtonAngles[ 1 ] = g_fButtonAngles[ g_iButtonAngle ];
set_pev( g_iButton, pev_angles, fButtonAngles );
DTBM( iClient );
}
case 2:
{
if ( !is_user_alive( iClient ) ) {
ColorChat( iClient, BLUE, "^4%s^1 You must be Alive.", g_sPrefix );
}
new iOrigin[ 3 ];
get_user_origin( iClient, iOrigin );
new Float: fOrigin[ 3 ];
IVecFVec( iOrigin, fOrigin );
g_fPlayerOrigin[ 0 ] = fOrigin[ 0 ];
g_fPlayerOrigin[ 1 ] = fOrigin[ 1 ];
g_fPlayerOrigin[ 2 ] = fOrigin[ 2 ] + 20.0;
ColorChat( iClient, BLUE, "^4%s^3 Teleport^1 position has successfully set.", g_sPrefix );
DTBM( iClient );
}
case 3:
{
SaveBTP();
}
}
return PLUGIN_HANDLED;
}
stock CreateButton( iClient, Float: fButtonOrigin[ 3 ] = { 0.0, 0.0, 0.0 } )
{
if ( !g_iButton )
{
new iEntity = engfunc( EngFunc_CreateNamedEntity, g_pFuncButton );
set_pev( iEntity, pev_classname, "DTB" );
set_pev( iEntity, pev_solid, SOLID_BBOX );
set_pev( iEntity, pev_movetype, MOVETYPE_NONE );
engfunc( EngFunc_SetModel, iEntity, g_sButtonModel );
engfunc( EngFunc_SetSize, iEntity, Float: { -16.0, -16.0, 0.0 }, Float: { 16.0, 16.0, 60.0 } );
g_iButton = iEntity;
}
if ( iClient )
{
new iOrigin[ 3 ];
get_user_origin( iClient, iOrigin, 3 );
new Float: fOrigin[ 3 ];
IVecFVec( iOrigin, fOrigin );
engfunc( EngFunc_SetOrigin, g_iButton, fOrigin );
g_fButtonOrigin[ 0 ] = fOrigin[ 0 ];
g_fButtonOrigin[ 1 ] = fOrigin[ 1 ];
g_fButtonOrigin[ 2 ] = fOrigin[ 2 ];
}
else
{
engfunc( EngFunc_SetOrigin, g_iButton, fButtonOrigin );
new Float: fButtonsAngles[ 3 ]; fButtonsAngles[ 1 ] = g_fButtonAngles[ g_iButtonAngle ];
set_pev( g_iButton, pev_angles, fButtonsAngles );
}
return PLUGIN_HANDLED;
}
public SaveBTP( )
{
new sMap[ 32 ], sConfig[ 32 ], sMapFile[ 128 ];
if (file_exists(g_SpawnFile))
delete_file(g_SpawnFile)
new sData[ 128 ];
formatex( sData, charsmax( sData ), "%f %f %f %i %f %f %f", g_fButtonOrigin[ 0 ], g_fButtonOrigin[ 1 ], g_fButtonOrigin[ 2 ], g_iButtonAngle, g_fPlayerOrigin[ 0 ], g_fPlayerOrigin[ 1 ], g_fPlayerOrigin[ 2 ] );
write_file( g_SpawnFile, sData );
ColorChat( 0, BLUE, "^4%s^1 Position for timer and teleport saved.", g_sPrefix );
}
bool: LoadBTP( )
{
if ( file_exists( g_SpawnFile ) )
{
new sData[ 128 ], iLen, iLine, sButtonOrigin[ 3 ][ 8 ], sButtonAngle[ 2 ], sPlayerOrigin[ 3 ][ 8 ];
while( ( iLine = read_file( g_SpawnFile, iLine, sData , charsmax( sData ) , iLen ) ) != 0)
{
if ( sData[ 0 ] == ';' )
continue;
parse( sData, sButtonOrigin[ 0 ], 7, sButtonOrigin[ 1 ], 7, sButtonOrigin[ 2 ], 7, sButtonAngle, 2, sPlayerOrigin[ 0 ], 7, sPlayerOrigin[ 1 ], 7, sPlayerOrigin[ 2 ], 7 );
g_fButtonOrigin[ 0 ] = str_to_float( sButtonOrigin[ 0 ] );
g_fButtonOrigin[ 1 ] = str_to_float( sButtonOrigin[ 1 ] );
g_fButtonOrigin[ 2 ] = str_to_float( sButtonOrigin[ 2 ] );
g_iButtonAngle = str_to_num( sButtonAngle );
g_fPlayerOrigin[ 0 ] = str_to_float( sPlayerOrigin[ 0 ] );
g_fPlayerOrigin[ 1 ] = str_to_float( sPlayerOrigin[ 1 ] );
g_fPlayerOrigin[ 2 ] = str_to_float( sPlayerOrigin[ 2 ] );
CreateButton( 0, g_fButtonOrigin );
}
}
else
{
return false;
}
return true;
}
public fwButtonUsed( iEntity, iClient )
{
if ( !is_user_alive( iClient ) || get_user_team( iClient ) != 2 || iEntity != g_iButton )
return HAM_IGNORED;
g_fGameTimeCheck = get_gametime( );
if ( g_fPlayerDelay[ iClient ] > g_fGameTimeCheck )
{
ColorChat( iClient, BLUE, "^4%s^1 Next use for^3 %.1f^1 seconds.", g_sPrefix, g_fPlayerDelay[ iClient ] - g_fGameTimeCheck );
return HAM_IGNORED;
}
static iPlayers[ 32 ], iNum;
get_players( iPlayers, iNum, "aeh", "TERRORIST" );
if ( !iNum )
{
ColorChat( iClient, BLUE, "^4%s^1 No^3 Terrorist^1 detected.", g_sPrefix );
return HAM_IGNORED;
}
//engfunc( EngFunc_SetOrigin, iClient, g_fPlayerOrigin );
set_pev(iPlayers[0], pev_origin, g_fPlayerOrigin)
set_pev(iPlayers[0], pev_velocity, 0.0)
g_fPlayerDelay[ iClient ] = g_fGameTimeCheck + get_pcvar_float( g_pDelayCvar );
return HAM_IGNORED;
}