OnPlayerDiscordJoin

From Multi Theft Auto: Wiki
Revision as of 03:17, 27 March 2020 by Qaisjp (talk | contribs) (exper)
Jump to navigation Jump to search

[[{{{image}}}|link=|]] Important Note: This event is experimental and can be removed at any time.

This event is triggered when a player accepts game invites from a user in discord or click on "Join" button from that player.

Parameters

bool justConnected, string key
  • justConnected: If true, player connected to the server using game invite, otherwise he's already in the game and not joined the server using discord invite.
  • key: The key passed by setPlayerDiscordJoinParams to the player who invited this user.

Source

The source of this event is the player who is invited to the game/clicked the "Join" button.

Example

This example will announce the server that who invited that user from discord.

function discordJoin(justConnected, key)
    local myName = getPlayerName(source)
    if justConnected == true then
        outputChatBox ( myName .. " been referred here by " .. key )
    else
        outputChatBox ( myName .. " wanna play with " .. key )
    end

    local refer = getPlayerFromName(key)
    setElementData(refer, "myUsers", getElementData(refer, "myUsers") + 1)
    setPlayerDiscordJoinParams(refer, key, key, getElementData(refer, "myUsers"), 5)
end
addEventHandler("onPlayerDiscordJoin", getRootElement(), discordJoin)

function storeDiscordParams()
    local myName = getPlayerName(source)
    setPlayerDiscordJoinParams(source, myName, myName, 1, 5)
    setElementData(source, "myUsers", 1)
end

addEventHandler("onPlayerJoin", getRootElement(), storeDiscordParams)

See Also

Player events


Event functions