ResetMapInfo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(example)
mNo edit summary
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__
__NOTOC__
{{Needs_Checking|This also needs to reset the following:
*gravity - needs checking
*game speed - needs checking
*cursor state - needs checking
*player stats - needs checking
*wanted level - needs checking
*fighting style - needs checking
*nametag color - needs checking
*nametag text - needs checking
*nametag showing state - needs checking
*money - needs checking
*weather - needs checking
*waveheight - needs checking
*sky gradient - needs checking}}
This function is used to reset the state of a player.  It is intended to restore a player to his default state as if he had just joined the server, without any scripts affecting him.
This function is used to reset the state of a player.  It is intended to restore a player to his default state as if he had just joined the server, without any scripts affecting him.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool resetMapInfo ( [player thePlayer = getRootElement()] )
bool resetMapInfo ( [ player thePlayer = root ] )
</syntaxhighlight>
</syntaxhighlight>


===Optional Arguments===
===Optional Arguments===
'''thePlayer:''' The specific player you wish to restore the state of.  Not specifying this will result in all players map info being reset.
{{OptionalArg}}
*'''thePlayer:''' The specific player you wish to restore the state of.  Not specifying this will result in all players map info being reset.


==Returns==
==Returns==
Line 29: Line 16:


==Example==
==Example==
This page does not have an example.
This will reset all map info when the resource is stopped.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),
function onResourceStop()
-- Resource load event
resetMapInfo()
function()
end
            resetMapInfo()
addEventHandler("onResourceStop", resourceRoot, onResourceStop)
        end
)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Map_functions}}
{{Map_functions}}
[[Category:Needs_Example]]

Latest revision as of 08:01, 5 November 2023

This function is used to reset the state of a player. It is intended to restore a player to his default state as if he had just joined the server, without any scripts affecting him.

Syntax

bool resetMapInfo ( [ player thePlayer = root ] )

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • thePlayer: The specific player you wish to restore the state of. Not specifying this will result in all players map info being reset.

Returns

Returns true if the map info was reset successfully, otherwise false.

Example

This will reset all map info when the resource is stopped.

function onResourceStop()
	resetMapInfo()
end
addEventHandler("onResourceStop", resourceRoot, onResourceStop)

See Also