Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************* Includes ***************/
- #include < amxmodx >
- #include < cstrike >
- #include < fakemeta >
- /************* Defines ***************/
- #define Prefix "AMXX"
- #define ADMIN_ACCESS ADMIN_IMMUNITY
- /************* News ***************/
- new bool: HasCheckPoint[ 33 ], MyTitle[ 33 ], InviteAcception[ 33 ], Float: MyXYZ[ 33 ][ 3 ], Float:LocationXYZ[ 3 ]
- public plugin_init()
- {
- register_plugin( "Teleport menu", "v1.0", "RanAway`" )
- /************* Commands ***************/
- register_clcmd( "say /teleport", "TeleportMenu" )
- register_clcmd( "say /tp", "TeleportMenu" )
- }
- /************* Connect ***************/
- public client_authorized( id ) HasCheckPoint[ id ] = false
- /************* Teleport menu ***************/
- public TeleportMenu( id )
- {
- if( cs_get_user_team( id ) == CS_TEAM_SPECTATOR )
- return ColorChat( id, "You can't teleport as ^3spectator" )
- new szMenu[ 500 ]
- pev( id, pev_origin, LocationXYZ )
- formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Teleport menu", Prefix )
- new menu = menu_create( szMenu, "sub_teleportmenu" )
- menu_additem( menu, "Save my current location as checkpoint" )
- menu_additem( menu, "Teleport to my last checkpoint", .callback = menu_makecallback( "blockitem" ) )
- menu_additem( menu, "Remove my checkpoint^n", .callback = menu_makecallback( "blockitem" ) )
- menu_additem( menu, "Teleport someone to your last checkpoint^n", .callback = menu_makecallback( "blockitem" ) )
- menu_additem( menu, "Teleport someone to your location" )
- menu_additem( menu, "Teleport to someone's location" )
- formatex( szMenu, charsmax( szMenu ), "check my location \d- \rX\w - \r%f\w | \rY\w - \r%f \w| \rZ\w - \r%f", LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- menu_additem( menu, szMenu )
- menu_display( id, menu )
- return 1
- }
- public blockitem( id, menu, item )
- {
- if( !HasCheckPoint[ id ] )
- return ITEM_DISABLED
- return 0
- }
- public sub_teleportmenu( id, menu, item )
- {
- if( item == MENU_EXIT )
- return menu_destroy( menu )
- if( cs_get_user_team( id ) == CS_TEAM_SPECTATOR )
- return ColorChat( id, "You can't teleport as ^3spectator" )
- if( item == 0 )
- {
- pev( id, pev_origin, LocationXYZ )
- ColorChat( id, "Your ^3checkpoint^1 has set to: ^3X^1 - ^3%f ^1| ^3Y^1 - ^3%f ^1| ^3Z^1 - ^3%f", LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- MyXYZ[ id ][ 0 ] = LocationXYZ[ 0 ]
- MyXYZ[ id ][ 1 ] = LocationXYZ[ 1 ]
- MyXYZ[ id ][ 2 ] = LocationXYZ[ 2 ]
- HasCheckPoint[ id ] = true
- }
- if( item == 1 )
- {
- ColorChat( id, "You have been ^3teleported^1 to your ^3checkpoint^1" )
- engfunc( EngFunc_SetOrigin, id, MyXYZ[ id ][ 0 ], MyXYZ[ id ][ 1 ], MyXYZ[ id ][ 2 ] )
- }
- if( item == 2 ) HasCheckPoint[ id ] = false
- if( item == 3 )
- {
- MyTitle[ id ] = 1
- return playermenu( id )
- }
- if( item == 4 )
- {
- MyTitle[ id ] = 2
- return playermenu( id )
- }
- if( item == 5 )
- {
- MyTitle[ id ] = 3
- return playermenu( id )
- }
- if( item == 6 )
- {
- pev( id, pev_origin, LocationXYZ )
- ColorChat( id, "Your location is: ^3X^1 - ^3%f ^1| ^3Y^1 - ^3%f ^1| ^3Z^1 - ^3%f", LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- }
- return TeleportMenu( id )
- }
- /************* Player menu ***************/
- public playermenu( id )
- {
- new szMenu[ 130 ], num[ 33 ]
- if( MyTitle[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Select player to teleport to your last checkpoint", Prefix )
- if( MyTitle[ id ] == 2 ) formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Select player to teleport to your location", Prefix )
- if( MyTitle[ id ] == 3 ) formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Select player to teleport to his location", Prefix )
- new menu = menu_create( szMenu, "sub_playermenu" )
- menu_additem( menu, "Everyone", .callback = menu_makecallback( "blockplayer" ) )
- menu_additem( menu, "Everyone except me", .callback = menu_makecallback( "blockplayer" ) )
- for( new i; i < get_maxplayers() ; i++ )
- {
- if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv(i) || i == id || cs_get_user_team( i ) == CS_TEAM_SPECTATOR ) continue
- num_to_str( i, num, charsmax( num ) )
- formatex( szMenu, charsmax( szMenu ), "\w%s", GetUserName( i ) )
- menu_additem( menu, szMenu, num )
- }
- menu_setprop( menu, MPROP_BACKNAME, "Previus Page" )
- menu_setprop( menu, MPROP_NEXTNAME, "Next Page" )
- menu_setprop( menu, MPROP_EXITNAME, "Back to the menu" )
- menu_display( id, menu )
- return 1
- }
- public blockplayer( id, menu, item )
- {
- if( MyTitle[ id ] == 3 || !( get_user_flags( id ) & ADMIN_ACCESS ) )
- return ITEM_DISABLED
- return 0
- }
- public sub_playermenu( id, menu, item )
- {
- if( item == MENU_EXIT ) return TeleportMenu( id )
- new Data[ 6 ], access, callback
- menu_item_getinfo( menu, item, access, Data, charsmax( Data ), "", 0, callback )
- new tempid = str_to_num( Data )
- if( item == 0 )
- {
- for( new i; i < get_maxplayers(); i++ )
- {
- if( MyTitle[ id ] == 1 ) engfunc( EngFunc_SetOrigin, i, MyXYZ[ id ][ 0 ], MyXYZ[ id ][ 1 ], MyXYZ[ id ][ 2 ] )
- if( MyTitle[ id ] == 2 )
- {
- pev( id, pev_origin, LocationXYZ )
- engfunc( EngFunc_SetOrigin, i, LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- }
- if( MyTitle[ id ] == 3 )
- {
- pev( tempid, pev_origin, LocationXYZ )
- engfunc( EngFunc_SetOrigin, i, LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- }
- }
- return playermenu( id )
- }
- if( item == 1 )
- {
- for( new i; i < get_maxplayers(); i++ )
- {
- if( i == id ) continue
- if( MyTitle[ id ] == 1 ) engfunc( EngFunc_SetOrigin, i, MyXYZ[ id ][ 0 ], MyXYZ[ id ][ 1 ], MyXYZ[ id ][ 2 ] )
- if( MyTitle[ id ] == 2 )
- {
- pev( id, pev_origin, LocationXYZ )
- engfunc( EngFunc_SetOrigin, i, LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- }
- if( MyTitle[ id ] == 3 )
- {
- pev( tempid, pev_origin, LocationXYZ )
- engfunc( EngFunc_SetOrigin, i, LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- }
- }
- return playermenu( id )
- }
- if( MyTitle[ id ] == 1 )
- {
- InviteAcception[ tempid ] = id
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) )
- {
- ColorChat( id, "You ask ^3%s^1 to teleport to you", GetUserName( tempid ) )
- ColorChat( tempid, "^3%s^1 want you to teleport to him. do you ^3agree?", GetUserName( id ) )
- return TeleportAcception( tempid )
- }
- if( get_user_flags( tempid ) & ADMIN_IMMUNITY )
- {
- ColorChat( id, "^3%s^1 is ^3immunity^1. you can't ^3teleport^1 him without asking", GetUserName( tempid ) )
- ColorChat( tempid, "^3%s^1 want you to teleport to him. do you ^3agree?", GetUserName( id ) )
- return TeleportAcception( tempid )
- }
- engfunc( EngFunc_SetOrigin, tempid, MyXYZ[ id ][ 0 ], MyXYZ[ id ][ 1 ], MyXYZ[ id ][ 2 ] )
- }
- if( MyTitle[ id ] == 2 )
- {
- InviteAcception[ tempid ] = id
- pev( id, pev_origin, LocationXYZ )
- if( !( get_user_flags( id ) & ADMIN_ACCESS ) )
- {
- ColorChat( id, "You ask ^3%s^1 to teleport to you", GetUserName( tempid ) )
- ColorChat( tempid, "^3%s^1 want you to teleport to him. do you ^3agree?", GetUserName( id ) )
- return TeleportAcception( tempid )
- }
- if( get_user_flags( tempid ) & ADMIN_IMMUNITY )
- {
- ColorChat( id, "^3%s^1 is ^3immunity^1. you can't ^3teleport^1 him without asking", GetUserName( tempid ) )
- ColorChat( tempid, "^3%s^1 want you to teleport to him. do you ^3agree?", GetUserName( id ) )
- return TeleportAcception( tempid )
- }
- engfunc( EngFunc_SetOrigin, tempid, LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- }
- if( MyTitle[ id ] == 3 )
- {
- pev( tempid, pev_origin, LocationXYZ )
- engfunc( EngFunc_SetOrigin, id, LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- ColorChat( id, "You ^3teleported^1 to ^3%s^1", GetUserName( tempid ) )
- }
- return playermenu( id )
- }
- /************* Teleport Acception ***************/
- public TeleportAcception( id )
- {
- if( cs_get_user_team( id ) == CS_TEAM_SPECTATOR )
- return ColorChat( id, "You can't teleport as ^3spectator" )
- new szMenu[ 500 ]
- if( MyTitle[ InviteAcception[ id ] ] == 1 ) formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w You got teleportaion invite from \r%s's\w checkpoint", Prefix, GetUserName( InviteAcception[ id ] ) )
- else if( MyTitle[ InviteAcception[ id ] ] == 2 ) formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w You got teleportaion invite from \r%s", Prefix, GetUserName( InviteAcception[ id ] ) )
- new menu = menu_create( szMenu, "sub_teleportacception" )
- menu_additem( menu, "Accept" )
- menu_additem( menu, "Ignore" )
- menu_display( id, menu )
- return 1
- }
- public sub_teleportacception( id, menu, item )
- {
- if( item == MENU_EXIT ) return TeleportMenu( id )
- if( cs_get_user_team( id ) == CS_TEAM_SPECTATOR )
- return ColorChat( id, "You can't teleport as ^3spectator" )
- new Data[ 6 ], access, callback
- menu_item_getinfo( menu, item, access, Data, charsmax( Data ), "", 0, callback )
- new tempid = InviteAcception[ id ]
- if( item == 0 )
- {
- if( MyTitle[ InviteAcception[ id ] ] == 1 )
- {
- engfunc( EngFunc_SetOrigin, id, MyXYZ[ tempid ][ 0 ], MyXYZ[ tempid ][ 1 ], MyXYZ[ tempid ][ 2 ] )
- ColorChat( id, "You accepted to teleport to ^3%s's^1 checkpoint", GetUserName( tempid ) )
- }
- else if( MyTitle[ InviteAcception[ id ] ] == 2 )
- {
- pev( InviteAcception[ id ], pev_origin, LocationXYZ )
- engfunc( EngFunc_SetOrigin, id, LocationXYZ[ 0 ], LocationXYZ[ 1 ], LocationXYZ[ 2 ] )
- ColorChat( id, "You accepted to teleport to ^3%s^1", GetUserName( tempid ) )
- }
- ColorChat( tempid, "^3%s^1 accepted your ^3invite", GetUserName( id ) )
- }
- if( item == 1 )
- {
- ColorChat( id, "You decline to teleport to ^3%s^1", GetUserName( tempid ) )
- ColorChat( tempid, "^3%s^1 decline your ^3invite", GetUserName( id ) )
- }
- return 1
- }
- /************* Stocks ***************/
- stock GetUserName( id )
- {
- static szName[ 32 ]
- get_user_name( id, szName, charsmax( szName ) )
- return szName
- }
- /************* ColorChat ***************/
- stock ColorChat( const client, const string[ ], { Float, Sql, Resul, _ } :... )
- {
- new msg[ 191 ], players[ 32 ], count = 1
- static len; len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
- vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
- if( client )
- players[ 0 ] = client
- else
- get_players( players, count, "ch" )
- for( new i; i < count; i++ )
- {
- if( is_user_connected( players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ),_, players[ i ] )
- write_byte( players[ i ] )
- write_string( msg )
- message_end()
- }
- }
- return 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement