redirectPlayer | Multi Theft Auto: Wiki Skip to content

redirectPlayer

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function redirects the player to a specified server.

Note

A resource using this function needs ACL rights in order to work (function.redirectPlayer)

OOP Syntax Help! I don't understand this!

Syntax

bool redirectPlayer ( player thePlayer, [ string serverIP = "", int serverPort = 0, string serverPassword = "" ] )
Required Arguments
  • thePlayer: The player you want to redirect
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • serverIP (default: ""): The IP address (or domain name that resolves to the IP address) of the server you want to redirect the player to. Use an empty string to reconnect to the same server.
  • serverPort (default: 0): The game port of the server you want to redirect the player to, this is usually 22003. Set to zero to use the same port as the current server.
  • serverPassword (default: ""): The password for the server if it's protected

Returns

  • bool: value

Returns true if the player was redirected successfully, false if bad arguments were passed.

Code Examples

shared

This example auto-redirects all connecting players to another given servers' IP:port.

local ip_port = "123.123.1.2:1234" -- enter IP and port in format: 192.168.1.1:22003
local password = "password_placeholder" -- If the server is passworded insert password here (if no password, it wont use the value)
function onConnectRedirect()
redirectPlayer(source, gettok(ip_port,1,":"), tonumber(gettok(ip_port,2,":")), password)
end
addEventHandler ("onPlayerJoin", root, onConnectRedirect)

See Also