Hi all, i need radius to teleport. With this script you can teleport from map star to map end. I need teleport with max radius, and if you try teleport more than radius, you obtained message with warning.
Code:
public ActivateTeleport(id)
{
if (hasTeleport[id])
{
// Get old and new location
new OldLocation[3], NewLocation[3];
// Get current players location
get_user_origin(id, OldLocation);
// Get location where player is aiming(where he will be teleported)
get_user_origin(id, NewLocation, 3);
// Create bubbles in a place where player teleported
// First, get user origin
new UserOrigin[3];
get_user_origin(id, UserOrigin);
// Now create bubbles
new BubbleOrigin[3];
BubbleOrigin[0] = UserOrigin[0];
BubbleOrigin[1] = UserOrigin[1];
BubbleOrigin[2] = UserOrigin[2] + 40;
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_SPRITETRAIL) // TE ID
write_coord(BubbleOrigin[0]) // Start Position X
write_coord(BubbleOrigin[1]) // Start Position Y
write_coord(BubbleOrigin[2]) // Start Position Z
write_coord(UserOrigin[0]) // End Position X
write_coord(UserOrigin[1]) // End Position Y
write_coord(UserOrigin[2]) // End Position Z
write_short(BubbleSprite) // Sprite Index
write_byte(30) // Count
write_byte(10) // Life
write_byte(1) // Scale
write_byte(50) // Velocity Along Vector
write_byte(10) // Rendomness of Velocity
message_end();
// Player cannot stuck in the wall/floor
NewLocation[0] += ((NewLocation[0] - OldLocation[0] > 0) ? -50 : 50);
NewLocation[1] += ((NewLocation[1] - OldLocation[1] > 0) ? -50 : 50);
NewLocation[2] += 40;
// Teleport player
set_user_origin(id, NewLocation);
hasTeleport[id] = false;
message_begin(MSG_ONE_UNRELIABLE, g_msgFade, .player=id);
write_short( 1<<13 );
write_short( 1<<5 );
write_short( FFADE_IN );
write_byte( 255 );
write_byte( 255 );
write_byte( 255 );
write_byte( 75 );
message_end();
}
return PLUGIN_CONTINUE;
}