OnPlayerDiscordJoin: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (fix rev)
m (remove exp)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server event}}
{{Server event}}
{{New feature/item|3.0160|1.6|20463|This event is triggered when a player accepts game invites from a user in discord or click on "Join" button from that player.}}
{{New feature/item|3.0160|1.6|20463|This event is triggered when a player accepts game invites from a user in discord or click on "Join" button from that player.}}



Latest revision as of 03:17, 27 March 2020

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