ZH-CN/fadeCamera: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Server client function}} __NOTOC__ 此功能将使玩家的相机在指定的时间段内淡入某一颜色或恢复正常。这也会影响播放器的音量(50%淡入=50...")
 
No edit summary
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Server client function}}
{{Server client function}}
__NOTOC__
__NOTOC__
此功能将使玩家的相机在指定的时间段内淡入某一颜色或恢复正常。这也会影响播放器的音量(50%淡入=50%音量,完全淡入=无声音)。对于客户端脚本,您可以一行执行两个淡入淡出,但是对于服务器端脚本,您必须先使用一个,然后使用另一个。
此功能将使玩家的相机在指定的时间段内淡入某一颜色或恢复正常。这也会影响播放器的音量(50%淡入=50%音量,完全淡入=无声音)。对于客户端脚本,您可以一行执行两个淡入淡出,但是对于服务器端脚本,您必须先使用一个,然后使用另一个.
{{Note|The speed of the effect depends directly on the current gamespeed.}}
{{Note|效果的速度直接取决于当前的游戏速度.}}


==Syntax==
==语法==
<section name="Server" class="server" show="true">
<section name="Server(服务端)" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool fadeCamera ( player thePlayer, bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )
bool fadeCamera ( player thePlayer, bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[player]]:fadeCamera}}
{{OOP_ZH-CN||[[player]]:fadeCamera}}
===Required Arguments===
===必填参数===
* '''thePlayer:''' The player whose camera you wish to fade.
* '''thePlayer:''' 你想淡出相机的玩家.
* '''fadeIn:''' Should the camera be faded in or out? Pass ''true'' to fade the camera in, ''false'' to fade it out to a color.
* '''fadeIn:''' 相机应该淡入还是淡出?通过true使相机淡入,通过false使其淡出颜色.


===Optional Arguments===
===选填参数===
* '''timeToFade:''' The number of seconds it should take to fade.
* '''timeToFade:''' 淡出所需的秒数.
* '''red:''' The amount of red in the color that the camera fades out to (0 - 255). Not required for fading in.
* '''red:''' 相机淡出的颜色中红色的量(0-255).淡入不需要.
* '''green:''' The amount of green in the color that the camera fades out to (0 - 255). Not required for fading in.
* '''green:''' 相机淡出的颜色中绿色的量(0-255).淡入不需要.
* '''blue:''' The amount of blue in the color that the camera fades out to (0 - 255). Not required for fading in.
* '''blue:''' 相机淡出的颜色中蓝色的量(0-255).淡入不需要.
</section>
</section>


<section name="Client" class="client" show="true">
<section name="Client(客户端)" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool fadeCamera ( bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )
bool fadeCamera ( bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||Camera.fade}}
{{OOP_ZH-CN||Camera.fade}}
===Required Arguments===
===必填参数===
* '''fadeIn:''' Should the camera be faded in our out? Pass ''true'' to fade the camera in, ''false'' to fade it out to a color.
* '''fadeIn:''' 我们的相机应该淡入淡出吗?通过true使相机淡入,通过false使其淡出颜色.


===Optional Arguments===
===选填参数===
* '''timeToFade:''' The number of seconds it should take to fade.
* '''timeToFade:''' 淡出所需的秒数.
* '''red:''' The amount of red in the color that the camera fades out to (0 - 255). Not required for fading in.
* '''red:''' 相机淡出的颜色中红色的量(0-255).淡入不需要.
* '''green:''' The amount of green in the color that the camera fades out to (0 - 255). Not required for fading in.
* '''green:''' 相机淡出的颜色中绿色的量(0-255).淡入不需要.
* '''blue:''' The amount of blue in the color that the camera fades out to (0 - 255). Not required for fading in.
* '''blue:''' 相机淡出的颜色中蓝色的量(0-255).淡入不需要.
</section>
</section>


===Returns===
===Returns(返回)===
Returns ''true'' if the camera was faded successfully, ''false'' if invalid arguments were passed to the function.
如果相机已成功淡出,则返回“true”;如果向函数传递了无效参数,则返回“false”.


==Example==
==例子==
<section name="Server example" class="server" show="true">
<section name="服务端示例" class="server" show="true">
When a player gets damaged, place a quick fade-to-red effect on his screen.
当一个玩家受到伤害时,在他的屏幕上放置一个快速的红色渐变效果.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function addRednessOnDamage ( )
function addRednessOnDamage ( )
       fadeCamera ( source, false, 1.0, 255, 0, 0 )        -- fade the player's camera to red over a period of 1 second
       fadeCamera ( source, false, 1.0, 255, 0, 0 )        -- 在1秒内将玩家的相机淡入红色
       setTimer ( fadeCameraDelayed, 500, 1, source )  -- don't let it go to opaque red, interrupt it after half a second and fade back to normal
       setTimer ( fadeCameraDelayed, 500, 1, source )  -- 不要让它变成不透明的红色,半秒钟后中断,然后逐渐恢复正常
end
end
addEventHandler ( "onPlayerDamage", root, addRednessOnDamage )
addEventHandler ( "onPlayerDamage", root, addRednessOnDamage )


function fadeCameraDelayed(player) -- This function prevents debug warnings when the player disconnects while the timer is running.
function fadeCameraDelayed(player) -- 此功能可防止在计时器运行时播放器断开连接时出现调试警告.
       if (isElement(player)) then
       if (isElement(player)) then
             fadeCamera(player, true, 0.5)
             fadeCamera(player, true, 0.5)

Latest revision as of 14:37, 3 February 2021

此功能将使玩家的相机在指定的时间段内淡入某一颜色或恢复正常。这也会影响播放器的音量(50%淡入=50%音量,完全淡入=无声音)。对于客户端脚本,您可以一行执行两个淡入淡出,但是对于服务器端脚本,您必须先使用一个,然后使用另一个.

[[{{{image}}}|link=|]] Note: 效果的速度直接取决于当前的游戏速度.

语法

Click to collapse [-]
Server(服务端)
bool fadeCamera ( player thePlayer, bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )

OOP 语法 什么是OOP?

方法: player:fadeCamera(...)

必填参数

  • thePlayer: 你想淡出相机的玩家.
  • fadeIn: 相机应该淡入还是淡出?通过true使相机淡入,通过false使其淡出颜色.

选填参数

  • timeToFade: 淡出所需的秒数.
  • red: 相机淡出的颜色中红色的量(0-255).淡入不需要.
  • green: 相机淡出的颜色中绿色的量(0-255).淡入不需要.
  • blue: 相机淡出的颜色中蓝色的量(0-255).淡入不需要.
Click to collapse [-]
Client(客户端)
bool fadeCamera ( bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )

OOP 语法 什么是OOP?

方法: Camera.fade(...)

必填参数

  • fadeIn: 我们的相机应该淡入淡出吗?通过true使相机淡入,通过false使其淡出颜色.

选填参数

  • timeToFade: 淡出所需的秒数.
  • red: 相机淡出的颜色中红色的量(0-255).淡入不需要.
  • green: 相机淡出的颜色中绿色的量(0-255).淡入不需要.
  • blue: 相机淡出的颜色中蓝色的量(0-255).淡入不需要.

Returns(返回)

如果相机已成功淡出,则返回“true”;如果向函数传递了无效参数,则返回“false”.

例子

Click to collapse [-]
服务端示例

当一个玩家受到伤害时,在他的屏幕上放置一个快速的红色渐变效果.

function addRednessOnDamage ( )
      fadeCamera ( source, false, 1.0, 255, 0, 0 )         -- 在1秒内将玩家的相机淡入红色
      setTimer ( fadeCameraDelayed, 500, 1, source )   -- 不要让它变成不透明的红色,半秒钟后中断,然后逐渐恢复正常
end
addEventHandler ( "onPlayerDamage", root, addRednessOnDamage )

function fadeCameraDelayed(player) -- 此功能可防止在计时器运行时播放器断开连接时出现调试警告.
      if (isElement(player)) then
            fadeCamera(player, true, 0.5)
      end
end

See Also