Template:Shared function: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Useful Function}}
<pageclass class="both" subcaption="Shared function"></pageclass>
{{Adding_Pages_to_Categories_and_Templates}}
<lowercasetitle></lowercasetitle>
<lowercasetitle></lowercasetitle>
__NOTOC__
<includeonly>[[Category:Server functions]][[Category:Client functions]]</includeonly>
This function check if the player in the team.
 
==Syntax==
<syntaxhighlight lang="lua">bool isPlayerInTeam( player thePlayer, string teamName )</syntaxhighlight>
 
===Required Arguments===
* '''thePlayer''': The player whose team you want to find out.
* '''teamName''': A string determining the name of the team you wish to find..
 
==Code==
<section name="Serverside Script" class="server" show="true">
<syntaxhighlight lang="lua">
function isPlayerInTeam( thePlayer, teamName )
local pTeam = getPlayerTeam( thePlayer )
local fTeam = getTeamFromName( teamName )
if not ( pTeam ) and ( fTeam ) then
return false
end
if ( pTeam == fTeam ) then
return true
end
end
</syntaxhighlight>
</section>
 
==Example==
<section name="Server" class="server" show="true">
This example check if the cop team.
<syntaxhighlight lang="lua">
createTeam( 'Cop', 255, 0, 0 )
 
addCommandHandler( 'InTeam',
function( aPlayer )
if isPlayerInTeam( aPlayer, 'Cop' ) then
outputChatBox( 'You\'re in cop team.', aPlayer )
else
outputChatBox( 'You\'re not in cop team.', aPlayer )
end
end
)
</syntaxhighlight>
</section>
 
Author(s): -
 
==See Also==
{{Useful_Functions}}

Latest revision as of 00:47, 3 February 2020