https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=MarioKart&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-29T10:46:10ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=GetElementsWithinColShape&diff=40975GetElementsWithinColShape2014-07-21T05:45:09Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This function is used to retrieve a list of all elements in a colshape, of the specified type. Please note that for legacy reasons, a colshape created on the client does not collide with elements already existing at that location until they first move. Please also note that before 1.0.3, this did not function correctly when moving a colshape<br />
<br />
Please note that this function doesn't verify whether elements are in the same dimension and interior, additional checks could be implemented manually if they are needed. <br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getElementsWithinColShape ( colshape shape, [ string elemType = nil ] ) <br />
</syntaxhighlight> <br />
{{OOP| |[[colshape]]:getElementsWithin||}}<br />
===Required Arguments=== <br />
*'''shape:''' The colshape you want to get the elements from.<br />
<br />
===Optional Arguments=== <br />
*'''elemType:''' The type of element you want a list of. This can be any element type, the common ones being:<br />
**'''"player":''' A player connected to the server<br />
**'''"ped":''' A ped<br />
**'''"vehicle":''' A vehicle<br />
**'''"object":''' An object<br />
**'''"pickup":''' A pickup<br />
**'''"marker":''' A marker<br />
<!--**'''"spawnpoint":''' A spawnpoint<br />
**'''"remoteclient":''' A remote client connected to the server<br />
**'''"console":''' The server Console--><br />
<br />
===Returns===<br />
Returns a ''table'' containing all the elements inside the colshape, of the specified type. Returns an empty ''table'' if there are no elements inside. Returns ''false'' if the colshape is invalid.<br />
<br />
==Example== <br />
This example retrieves a table of the players in the colshape and prints their name to the chat.<br />
<syntaxhighlight lang="lua"><br />
local newcolshape = createColSphere ( 1, 2, 3, 4 )<br />
local players = getElementsWithinColShape ( newcolshape, "player" ) -- get all the players inside the sphere<br />
for theKey,thePlayer in ipairs(players) do -- use a generic for loop to step through each player<br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is in our new sphere" ) -- print their name to the chat<br />
end<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Element_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=CreateColPolygon&diff=40974CreateColPolygon2014-07-21T05:42:47Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
{{Note_box|For this function to work correctly, get/set your bound points in an anti-clockwise fashion.}}<br />
This function creates a collision polygon. See [http://en.wikipedia.org/wiki/Polygon Wikipedia] for a definition of a polygon. The first set of X Y of this shape is not part of the colshape bounds, so can set anywhere in the game world, however for performance, place it as close to the centre of the polygon as you can. It should be noted this shape is '''2D'''. There should be at least 3 bound points set. <br />
{{VisualizeColshape}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
colshape createColPolygon ( float fX, float fY, float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, ... )<br />
</syntaxhighlight> <br />
{{OOP| |ColShape.Polygon||}}<br />
===Required Arguments=== <br />
*'''fX:''' The X position of the collision polygon's position - the position that will be returned from [[getElementPosition]].<br />
*'''fY:''' The Y position of the collision polygon's position - the position that will be returned from [[getElementPosition]].<br />
*'''fX1:''' The 1st X position of the collision polygon's bound point<br />
*'''fY1:''' The 1st Y position of the collision polygon's bound point<br />
*'''fX2:''' The 2nd X position of the collision polygon's bound point<br />
*'''fY2:''' The 2nd Y position of the collision polygon's bound point<br />
*'''fX3:''' The 3rd X position of the collision polygon's bound point<br />
*'''fY3:''' The 3rd Y position of the collision polygon's bound point<br />
*'''...''' From the 3rd position you can have as many points as you require to create the colshape.<br />
<br />
===Returns===<br />
Returns a [[colshape]] element if successful, ''false'' if invalid arguments were passed to the function.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example displays a chat message when a player enters the colshape and allows the colshape to be created using a console function ''set_zone''.<br />
<syntaxhighlight lang="lua"><br />
theZone = false<br />
<br />
function shapeHit ( thePlayer ) <br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is in the zone!" ) -- display a message in everyone's chat box<br />
end<br />
<br />
function setZone ( playerSource, commandName, fX, fY, fX1, fY1, fX2, fY2, fX3, fY3 ) --Remember that after the 3rd position you <br />
--can have as many points as you require to <br />
--create the colshape.<br />
<br />
if ( fY and fX and fX1 and fY1 and fX2 and fX3 and fY3 ) then -- check we've got the 8 args we need<br />
local tempCol = createColPolygon ( fX, fY, fX1, fY1, fX2, fY2, fX3, fY3 ) -- create a col<br />
if ( tempCol == false ) then -- did the col get created successfully?<br />
outputConsole ("Syntax is: set_zone <X> <Y> <X1> <Y1> <X2> <Y2> <X3> <Y3>")-- inform the user what the valid syntax is<br />
else<br />
if ( theZone ~= false ) then -- did we already have a zone?<br />
destroyElement ( theZone ) -- if so, destroy it<br />
else<br />
addEventHandler ( "onColShapeHit", theZone, shapeHit ) -- add a handler for the onColShapeHit event<br />
end<br />
theZone = tempCol -- and store the new zone we've made<br />
outputChatBox ( "Zone has moved!" ) -- and tell everyone<br />
end<br />
end<br />
end<br />
addCommandHandler ( "set_zone", setZone ) -- add a console function called set_zone that will trigger the function setZone<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Collision shape functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=CreateColTube&diff=40973CreateColTube2014-07-21T05:41:18Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function creates a collision tube. This is a shape that has a position and a 2D (X/Y) radius and a height. See [http://en.wikipedia.org/wiki/Cylinder_(geometry) Cylinder] for a definition of a tube. A tube is similar to a colcircle, except that it has a limited height, this means you can limit the distance above the position defined by (fX, fY, fZ) that the collision is detected.<br />
{{VisualizeColshape}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
colshape createColTube ( float fX, float fY, float fZ, float fRadius, float fHeight)<br />
</syntaxhighlight> <br />
{{OOP| |ColShape.Tube||}}<br />
===Required Arguments=== <br />
*'''fX:''' The position of the base of the tube's center on the X axis<br />
*'''fY:''' The position of the base of the tube's center on the Y axis<br />
*'''fZ:''' The position of the base of the tube's center on the Z axis<br />
*'''fRadius:''' The collision tube's radius<br />
*'''fHeight:''' The collision tube's height<br />
<br />
===Returns===<br />
Returns a [[colshape]] element if successful, ''false'' if invalid arguments were passed to the function.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example displays a chat message when a player enters the colshape and allows the colshape to be created using a console function ''set_zone''.<br />
<syntaxhighlight lang="lua"><br />
theZone = false<br />
<br />
function shapeHit ( thePlayer ) <br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is in the zone!" ) -- display a message in everyone's chat box<br />
end<br />
<br />
function setZone ( playerSource, commandName, fX, fY, fZ )<br />
if ( fZ and fY and fX ) then -- check we've got all 3 args we need<br />
local tempCol = createColTube ( fX, fY, fZ, 10.0, 10.0 ) -- create a col<br />
if ( tempCol == false ) then -- did the col get created successfully?<br />
outputConsole ( "Syntax is: set_zone <X> <Y> <Z>" ) -- inform the user what the valid syntax is<br />
else<br />
if ( theZone ~= false ) then -- did we already have a zone?<br />
destroyElement ( theZone ) -- if so, destroy it<br />
else<br />
addEventHandler ( "onColShapeHit", theZone, shapeHit ) -- add a handler for the onColShapeHit event<br />
end<br />
theZone = tempCol -- and store the new zone we've made<br />
outputChatBox ( "Zone has moved!" ) -- and tell everyone<br />
end<br />
end<br />
end<br />
addCommandHandler ( "set_zone", setZone ) -- add a console function called set_zone that will trigger the function setZone<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Collision shape functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=CreateColSphere&diff=40972CreateColSphere2014-07-21T05:40:26Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function creates a collision sphere. This is a shape that has a position and a radius. See [http://en.wikipedia.org/wiki/Sphere Wikipedia] for a definition of a sphere.<br />
{{VisualizeColshape}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
colshape createColSphere ( float fX, float fY, float fZ, float fRadius )<br />
</syntaxhighlight> <br />
{{OOP| |ColShape.Sphere||}}<br />
===Required Arguments=== <br />
*'''fX:''' The collision sphere's center point's X axis position<br />
*'''fY:''' The collision sphere's center point's Y axis position<br />
*'''fZ:''' The collision sphere's center point's Z axis position<br />
*'''fRadius:''' The collision sphere's radius<br />
<br />
===Returns===<br />
Returns a [[colshape]] element if successful, ''false'' if invalid arguments were passed to the function.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
'''Example 1:''' This example displays a chat message when a player enters the colshape and allows the colshape to be created using a console function ''set_zone''.<br />
<syntaxhighlight lang="lua"><br />
theZone = false<br />
<br />
function shapeHit ( thePlayer ) <br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is in the zone!" ) -- display a message in everyone's chat box<br />
end<br />
<br />
function setZone ( playerSource, commandName, fX, fY, fZ )<br />
if ( fZ and fY and fX ) then -- check we've got all 3 args we need<br />
local tempCol = createColSphere ( fX, fY, fZ, 10.0 ) -- create a col<br />
if ( tempCol == false ) then -- did the col get created successfully?<br />
outputConsole ( "Syntax is: set_zone <X> <Y> <Z>" ) -- inform the user what the valid syntax is<br />
else<br />
if ( theZone ~= false ) then -- did we already have a zone?<br />
destroyElement ( theZone ) -- if so, destroy it<br />
else<br />
addEventHandler ( "onColShapeHit", theZone, shapeHit ) -- add a handler for the onColShapeHit event<br />
end<br />
theZone = tempCol -- and store the new zone we've made<br />
outputChatBox ( "Zone has moved!" ) -- and tell everyone<br />
end<br />
end<br />
end<br />
addCommandHandler ( "set_zone", setZone ) -- add a console function called set_zone that will trigger the function setZone<br />
</syntaxhighlight><br />
'''Example 2:''' This example allows creation of claymores, which trigger and explode.<br />
<syntaxhighlight lang="lua">function createClaymore ( x,y,z, creator )<br />
local x,y,z = getElementPosition ( creator )<br />
local claymoreObject = createObject ( 1945, x, y, z - 1, 0, 0, 90 ) --create an object which looks like a claymore<br />
local claymoreCol = createColSphere ( x, y, z, 1 ) --create a col sphere with radius 1<br />
setElementData ( claymoreCol , "type", "claymore" ) --store the type of colshape so it can be retrieved<br />
setElementData ( claymoreCol, "object", claymoreObject ) --store the object of the claymore<br />
setElementData ( claymoreCol, "creatorPlayer", creator ) --store the person who created it<br />
end<br />
<br />
function claymoreHit ( player, matchingDimension )<br />
if getElementData ( source, "type" ) == "claymore" then --ensure its a claymore<br />
--retrieve the object associated to the claymore, and who created it<br />
local claymoreObject = getElementData ( source, "object" )<br />
local claymoreCreator = getElementData ( source, "creatorPlayer" )<br />
--get the position of the claymore<br />
local x,y,z = getElementPosition ( source )<br />
createExplosion ( x,y,z, 12, claymoreCreator ) --create an explosion, associated to the creator, of a small size at the col's position<br />
--destroy the claymore object, and the col shape so it doesnt trigger again.<br />
destroyElement ( claymoreObject )<br />
destroyElement ( source )<br />
end<br />
end<br />
addEventHandler ( "onColShapeHit", getRootElement(), claymoreHit )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Collision shape functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=CreateColRectangle&diff=40971CreateColRectangle2014-07-21T05:38:55Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function creates a collision rectangle. This is a shape that has a position and a width and a depth. See [http://en.wikipedia.org/wiki/Rectangle Rectangle] for a definition of a rectangle. XY marks on the south west corner of the colshape.<br />
{{VisualizeColshape}}<br />
{{Note|Attaching a rectangle colshape to another element may give unexpected results as the origin is not at the rectangle centre. Try using a [[createColCircle|collision circle]] for attaching instead}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
colshape createColRectangle ( float fX, float fY, float fWidth, float fHeight)<br />
</syntaxhighlight> <br />
{{OOP| |ColShape.Rectangle||}}<br />
===Required Arguments=== <br />
*'''fX:''' The X position of the collision rectangle's west side<br />
*'''fY:''' The Y position of the collision rectangle's south side<br />
*'''fWidth:''' The collision rectangle's width<br />
*'''fHeight:''' The collision rectangle's height<br />
<br />
===Returns===<br />
Returns a [[colshape]] element if successful, ''false'' if invalid arguments were passed to the function.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example displays a chat message when a player enters the colshape and allows the colshape to be created using a console function ''set_zone''.<br />
<syntaxhighlight lang="lua"><br />
theZone = false<br />
<br />
function shapeHit ( thePlayer ) <br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is in the zone!" ) -- display a message in everyone's chat box<br />
end<br />
<br />
function setZone ( playerSource, commandName, fX, fY )<br />
if ( fY and fX ) then -- check we've got the 2 args we need<br />
local tempCol = createColRectangle ( fX, fY, 10.0, 10.0 ) -- create a col<br />
if ( tempCol == false ) then -- did the col get created successfully?<br />
outputConsole ( "Syntax is: set_zone <X> <Y>" ) -- inform the user what the valid syntax is<br />
else<br />
if ( theZone ~= false ) then -- did we already have a zone?<br />
destroyElement ( theZone ) -- if so, destroy it<br />
else<br />
addEventHandler ( "onColShapeHit", theZone, shapeHit ) -- add a handler for the onColShapeHit event<br />
end<br />
theZone = tempCol -- and store the new zone we've made<br />
outputChatBox ( "Zone has moved!" ) -- and tell everyone<br />
end<br />
end<br />
end<br />
addCommandHandler ( "set_zone", setZone ) -- add a console function called set_zone that will trigger the function setZone<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Collision shape functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=CreateColCuboid&diff=40970CreateColCuboid2014-07-21T05:37:32Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function creates a collision cuboid. This is a shape that has a position, width, depth and height. See [http://en.wikipedia.org/wiki/Cuboid Wikipedia] for a definition of a cuboid. The XYZ of the col starts at the southwest bottom corner of the shape.<br />
{{VisualizeColshape}}<br />
{{Note|Attaching a cuboid colshape to another element may give unexpected results as the origin is not at the cuboid centre. Try using a [[createColSphere|collision sphere]] for attaching instead}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
colshape createColCuboid ( float fX, float fY, float fZ, float fWidth, float fDepth, float fHeight )<br />
</syntaxhighlight> <br />
{{OOP| |ColShape.Cuboid||}}<br />
===Required Arguments=== <br />
*'''fX:''' The X position of the collision cuboid's western side<br />
*'''fY:''' The Y position of the collision cuboid's southern side<br />
*'''fZ:''' The Z position of the collision cuboid's lowest side<br />
*'''fWidth:''' The collision cuboid's width<br />
*'''fDepth:''' The collision cuboid's depth<br />
*'''fHeight:''' The collision cuboid's height<br />
<br />
===Returns===<br />
Returns a [[colshape]] element if successful, ''false'' if invalid arguments were passed to the function.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example displays a chat message when a player enters the colshape and allows the colshape to be created using a console function ''set_zone''.<br />
<syntaxhighlight lang="lua"><br />
theZone = false<br />
<br />
function shapeHit ( thePlayer ) <br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is in the zone!" ) -- display a message in everyone's chat box<br />
end<br />
<br />
function setZone ( playerSource, commandName, fX, fY, fZ )<br />
if ( fZ and fY and fX ) then -- check we've got all 3 args we need<br />
local tempCol = createColCuboid ( fX, fY, fZ, 10.0, 10.0, 10.0 ) -- create a col<br />
if ( tempCol == false ) then -- did the col get created successfully?<br />
outputConsole ( "Syntax is: set_zone <X> <Y> <Z>" ) -- inform the user what the valid syntax is<br />
else<br />
if ( theZone ~= false ) then -- did we already have a zone?<br />
destroyElement ( theZone ) -- if so, destroy it<br />
else<br />
addEventHandler ( "onColShapeHit", theZone, shapeHit ) -- add a handler for the onColShapeHit event<br />
end<br />
theZone = tempCol -- store the new zone we've made<br />
outputChatBox ( "Zone has moved!" ) -- and tell everyone<br />
end<br />
end<br />
end<br />
addCommandHandler ( "set_zone", setZone ) -- add a console function called set_zone that will trigger the function setZone<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Collision shape functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=CreateColCircle&diff=40969CreateColCircle2014-07-21T05:36:00Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function creates a collision circle. This is a shape that has a position and a radius and infinite height that you can use to detect a player's presence. Events will be triggered when a player enters or leaves it.<br />
{{VisualizeColshape}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
colshape createColCircle ( float fX, float fY, float radius ) <br />
</syntaxhighlight> <br />
{{OOP| |ColShape.Circle||}}<br />
===Required Arguments=== <br />
*'''fX:''' The collision circle's center point's X axis position<br />
*'''fY:''' The collision circle's center point's Y axis position<br />
*'''radius''' The radius of the collision circle<br />
<br />
===Returns===<br />
Returns a [[colshape]] element if successful, ''false'' if invalid arguments were passed to the function.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example displays a chat message when a player enters the colshape and allows the colshape to be created using a console function ''set_zone''.<br />
<syntaxhighlight lang="lua"><br />
theZone = false<br />
<br />
function shapeHit ( thePlayer ) <br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is in the zone!" ) -- display a message in everyone's chat box<br />
end<br />
<br />
function setZone ( playerSource, commandName, fX, fY )<br />
if ( fY and fX ) then -- check we've got all 3 args we need<br />
local tempCol = createColCircle ( fX, fY, 10.0 ) -- create a col<br />
if ( tempCol == false ) then -- did the col get created successfully?<br />
outputConsole ( "Syntax is: set_zone <X> <Y>" ) -- inform the user what the valid syntax is<br />
else<br />
if ( theZone ~= false ) then -- did we already have a zone?<br />
destroyElement ( theZone ) -- if so, destroy it<br />
else<br />
addEventHandler ( "onColShapeHit", theZone, shapeHit ) -- add a handler for the onColShapeHit event<br />
end<br />
theZone = tempCol -- and store the new zone we've made<br />
outputChatBox ( "Zone has moved!" ) -- and tell everyone<br />
end<br />
end<br />
end<br />
addCommandHandler ( "set_zone", setZone ) -- add a console function called set_zone that will trigger the function setZone<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Collision shape functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetCameraTarget&diff=40808GetCameraTarget2014-07-15T05:45:16Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This function returns an [[element]] that corresponds to the current target of the specified player's camera (i.e. what it is following). <br />
==Syntax==<br />
<section class="server" name="Server" show="true"><br />
<syntaxhighlight lang="lua"><br />
element getCameraTarget ( player thePlayer )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:getCameraTarget|cameraTarget|setCameraTarget}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player whose camera you wish to receive the target of.<br />
</section><br />
<section class="client" name="Client" show="true"><br />
<syntaxhighlight lang="lua"><br />
element getCameraTarget ()<br />
</syntaxhighlight> <br />
</section><br />
<br />
===Returns===<br />
* Returns an [[element]] of the target if the function was successful, or ''false'' if bad arguments were specified<br />
{{New feature|3|1.0|<br />
* Returns ''false'' if the camera is in Fixed mode and has no target.<br />
}}<br />
<br />
==Example== <br />
This example checks whether a player's camera's target is another player, and returns true or false accordingly.<br />
<section class="server" name="Server script" show="true"><br />
<syntaxhighlight lang="lua"><br />
function isTargetPlayer( thePlayer )<br />
local target = getCameraTarget ( thePlayer )<br />
if ( getElementType ( target ) == "player" ) then -- If target is a player<br />
return true -- Return true<br />
else<br />
return false -- Otherwise, return false.<br />
end<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Camera functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetCameraMatrix&diff=40807GetCameraMatrix2014-07-15T05:44:06Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function gets the position of the camera and the position of the point it is facing.<br />
<br />
Note: The server-side version of this function returns the last camera matrix that was set by the server, and thus does not necessarily indicate the current matrix of the camera (since it may have been changed client-side).<br />
<br />
==Procedural==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
float float float float float float float float getCameraMatrix (player thePlayer)<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''thePlayer:''' The player whose camera matrix is to be returned.<br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
float float float float float float float float getCameraMatrix ()<br />
</syntaxhighlight><br />
</section><br />
<br />
This function returns 8 [[float|floats]] if the argument is valid (when applicable); the first three indicate the position of the camera, the next three indicate the position of the point it's facing, and the last two are the roll and field of view. Returns ''false'' if the argument is invalid.<br />
<br />
===Example===<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
local x, y, z, lx, ly, lz = getCameraMatrix ()<br />
x, lx = x + 1, lx + 1<br />
<br />
setCameraMatrix (x, y, z, lx, ly, lz)<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
{{New items|3.0140|1.4|<br />
==Object-oriented==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
Matrix player:getCameraMatrix()<br />
--or<br />
Matrix player.cameraMatrix -- to get the camera matrix value<br />
player.cameraMatrix = Matrix -- to set the camera matrix value<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
Matrix Camera.getMatrix ()<br />
</syntaxhighlight><br />
</section><br />
<br />
This function returns a matrix with the position of the camera (first three elements), the position of the point it's facing (next three elements) and the roll and field of view (last two elements) if the function is successful. Returns an empty matrix otherwise.<br />
<br />
===Example===<br />
This page lacks an example.<br />
}}<br />
<br />
==See Also==<br />
{{Camera functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetCameraInterior&diff=40806GetCameraInterior2014-07-15T05:39:17Z<p>MarioKart: OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Returns the interior of the local camera (independent of the interior of the local player).<br />
<br />
==Procedural==<br />
===Syntax===<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
int getCameraInterior ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
'''thePlayer''': The player whose camera interior you want to get.<br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
int getCameraInterior ( )<br />
</syntaxhighlight><br />
</section><br />
<br />
Returns an ''integer'' indicating the camera's interior, ''false'' if the argument is invalid.<br />
<br />
===Example===<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function outputCameraInterior ( player, command )<br />
local interior = getCameraInterior ( player )<br />
outputChatBox ( "The camera is in the interior " .. interior, player, 255, 255, 0 )<br />
end<br />
addCommandHandler ( "camera", outputCameraInterior )<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
{{New items|3.0140|1.4|<br />
==Object-oriented==<br />
===Syntax===<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
int player:getCameraInterior ( )<br />
-- or<br />
int player.cameraInterior -- to get the camera interior value<br />
player.cameraInterior = int someValue -- to set the camera interior value<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
int Camera.getInterior ( )<br />
</syntaxhighlight><br />
</section><br />
<br />
Returns an ''integer'' indicating the camera's interior, ''false'' if the argument is invalid.<br />
<br />
===Example===<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function outputCameraInterior ( command )<br />
local interior = Camera.getInterior ( )<br />
outputChatBox ( "The camera is in the interior " .. interior, localPlayer, 255, 255, 0 )<br />
end<br />
addCommandHandler ( "camera", outputCameraInterior )<br />
</syntaxhighlight><br />
</section><br />
}}<br />
<br />
==See Also==<br />
{{Camera functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerACInfo&diff=40805GetPlayerACInfo2014-07-15T05:30:37Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
{{New feature/item|3.0140|1.3.3|5523|<br />
This function returns anti-cheat info for a player. It can be used to script a white/blacklist of custom d3d9.dll files, or a white/blacklist of players with certain anti-cheat codes. The relevant anti-cheat code has to be disabled (or not enabled) in the server [[Mtaserver.conf#disableac|mtaserver.conf]] to be of use here.<br />
{{Note|The info returned by this function can change over time, so it should be called every few seconds rather than just when the player joins. See example.}}<br />
}}<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
table getPlayerACInfo( element thePlayer )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:getACInfo|ACInfo|}}<br />
===Required Arguments===<br />
*'''thePlayer:''' The [[player]] whose anti-cheat info you want to check.<br />
<br />
===Returns===<br />
Returns a table with the following entries:<br />
* '''DetectedAC:''' A string containing a comma separated list of [[Anti-cheat_guide|anti-cheat]] codes the player has triggered.<br />
*'''d3d9Size:''' A number representing the file size of any custom d3d9.dll the player may have installed.<br />
*'''d3d9MD5:''' A string containing the MD5 of any custom d3d9.dll the player may have installed.<br />
{{New items|4.0142|1.4|<br />
*'''d3d9SHA256:''' A string containing the SHA256 of any custom d3d9.dll the player may have installed.<br />
}}<br />
<br />
==Example== <br />
This example checks getPlayerACInfo for changes every 3 seconds<br />
<syntaxhighlight lang="lua"><br />
lastDetectedACList = {}<br />
<br />
addEventHandler( "onResourceStart", resourceRoot,<br />
function()<br />
for _,plr in ipairs( getElementsByType("player") ) do<br />
lastDetectedACList[plr] = ""<br />
end<br />
end<br />
)<br />
<br />
addEventHandler( "onPlayerJoin", root,<br />
function()<br />
lastDetectedACList[source] = ""<br />
end<br />
)<br />
<br />
addEventHandler( "onPlayerQuit", root,<br />
function()<br />
lastDetectedACList[source] = nil<br />
end<br />
)<br />
<br />
function checkPlayersACInfo()<br />
for plr,lastAC in pairs( lastDetectedACList ) do<br />
local info = getPlayerACInfo(plr)<br />
if info.DetectedAC ~= lastAC then<br />
lastDetectedACList[plr] = info.DetectedAC<br />
outputServerLog( "AC-INFO: "<br />
.. " Player:" .. tostring(getPlayerName(plr))<br />
.. " DetectedAC:" .. tostring(info.DetectedAC)<br />
.. " d3d9MD5:" .. tostring(info.d3d9MD5)<br />
.. " d3d9Size:" .. tostring(info.d3d9Size)<br />
)<br />
end<br />
end<br />
end<br />
setTimer( checkPlayersACInfo, 3000, 0 )<br />
</syntaxhighlight><br />
<br />
==Requirements==<br />
{{Requirements|1.3.3|n/a|}}<br />
<br />
==Example==<br />
<br />
==See Also==<br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerAnnounceValue&diff=40804GetPlayerAnnounceValue2014-07-15T05:29:18Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function retrieves a players ASE announce value under a certain key.<br />
{{New feature/item|3.0104|1.0.4}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">string getPlayerAnnounceValue ( element thePlayer, string key )</syntaxhighlight><br />
{{OOP||[[player]]:getAnnounceValue||}}<br />
===Required Arguments===<br />
*'''thePlayer:''' This is the [[Player]] whos value you want to retrieve.<br />
*'''key:''' The name of the key.<br />
<br />
===Returns===<br />
This function returns a ''string'' containing the requested value if a valid key was specified or ''false'' otherwise.<br />
<br />
==Example==<br />
This example adds a command named "getscore" which outputs a players "score" value to his chatbox.<br />
<syntaxhighlight lang="lua">function getScore ( playerSource, cmdName )<br />
local scoreValue = getPlayerAnnounceValue ( playerSource, "score" )<br />
if ( scoreValue ) then<br />
outputChatBox ( "Your score: "..scoreValue, playerSource )<br />
end<br />
end<br />
<br />
addCommandHandler ( "getscore", getScore )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerMoney&diff=40803GetPlayerMoney2014-07-15T05:28:46Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
Returns the amount of money a player currently has.<br />
<br />
'''Note:''' The amount may vary between the server and client, you shouldn't trust the client side value to always be accurate.<br />
<br />
==Syntax== <br />
<section show="true" name="Server" class="server"><br />
<syntaxhighlight lang="lua">int/bool getPlayerMoney ( player thePlayer )</syntaxhighlight> <br />
{{OOP||[[player]]:getMoney|money|setPlayerMoney}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player you wish the retrieve the amount of money from.<br />
<br />
===Returns===<br />
Returns an integer with the amount of money the specified player has, ''false'' if the player is invalid.<br />
</section><br />
<br />
<section show="true" name="Client" class="client"><br />
<syntaxhighlight lang="lua">int getPlayerMoney ( )</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns an integer with the amount of money the local player has.<br />
</section><br />
<br />
==Example==<br />
<section show="true" name="Server" class="server"><br />
When a player types '/checkMoney' this example retrieves the player's money and outputs a message according to the value.<br />
<syntaxhighlight lang="lua"><br />
function checkMoney(thePlayer, command)<br />
local money = getPlayerMoney(thePlayer) -- get the amount of money from the player who entered the command<br />
if (money > 1000) then -- if money is more than 1000<br />
outputChatBox("You are rich: " .. tostring(money), thePlayer) -- output this message together with the money<br />
else<br />
outputChatBox("Poor guy...", thePlayer) -- and else, output this message<br />
end<br />
end<br />
addCommandHandler("checkMoney", checkMoney) -- add the console command<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerVersion&diff=40802GetPlayerVersion2014-07-15T05:28:03Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
{{Note|You can also compare if a version is higher than another using the ''<'' or ''>'' operators.}}<br />
<br />
This function gets the client version of the specified [[player]] as a sortable string. The string is always 15 characters long and is formatted as follows:<br />
<br />
* 1 character representing the major version<br />
* 1 dot character<br />
* 1 character representing the minor version<br />
* 1 dot character<br />
* 1 character representing the maintenance version<br />
* 1 dash character<br />
* 1 character representing the build type<br />
* 1 dot character<br />
* 5 characters representing the build number<br />
* 1 dot character<br />
* 1 character representing the build revision<br />
<br />
An example of a version string would be: 1.0.4-9.01746.0<br />
<br />
Where the first three numbers represent the major/minor/maintenance version, i.e. 1.0.4<br><br />
The fourth number is 9, which means it's a release build, (Development and beta builds have lower numbers here)<br><br />
And the fifth and sixth numbers represent the build number.<br />
<br />
==Syntax== <br />
<br />
<syntaxhighlight lang="lua"><br />
string getPlayerVersion ( player thePlayer )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:getVersion|version|}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The [[player]] whose client version you wish to get.<br />
<br />
===Returns===<br />
Returns a string containing the client version, or false if the [[player]] is invalid.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example adds a command that allows players to see their own client version.<br />
<syntaxhighlight lang="lua">function showMeMyVersion( playerSource )<br />
local version = getPlayerVersion ( playerSource )<br />
outputChatBox ( "Your client version is: " .. version, playerSource )<br />
end<br />
<br />
addCommandHandler ( "myversion", showMeMyVersion )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerBlurLevel&diff=40801GetPlayerBlurLevel2014-07-15T05:26:28Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
<br />
This function allows you to check the current blur level of a specified [[player]].<br />
<br />
==Syntax==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
int getPlayerBlurLevel ( player thePlayer )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:getBlurLevel|blurLevel|setPlayerBlurLevel}}<br />
===Required Arguments===<br />
*'''thePlayer:''' The [[player]] whose blur level you want to check.<br />
<br />
===Returns===<br />
Returns the player's blur level if successful, ''false'' if an invalid player was given.<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
int getBlurLevel ()<br />
</syntaxhighlight><br />
<br />
===Returns===<br />
Returns the local blur level.<br />
</section><br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example adds a command ''blurlevel'' with which you can check your current blur level.<br />
<syntaxhighlight lang="lua"><br />
function checkBlurLevel( playerSource )<br />
local blur = getPlayerBlurLevel( playerSource )<br />
if blur then<br />
outputChatBox( "Blur level: " .. blur, playerSource )<br />
end<br />
end<br />
addCommandHandler("blurlevel", checkBlurLevel)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerIP&diff=40800GetPlayerIP2014-07-15T05:25:31Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
This function returns a [[string]] containing the IP address of the [[player]].<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
string getPlayerIP ( player thePlayer )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:getIP|ip|}}<br />
===Required Arguments===<br />
* '''thePlayer:''' The [[player]] element you want to get the IP of.<br />
<br />
===Returns===<br />
Returns a [[string]] containing the requested players's IP, or ''false'' if the player passed to the function is invalid.<br />
<br />
==Example==<br />
This example prints a player's IP to the chat.<br />
<syntaxhighlight lang="lua"><br />
function printIp ( thePlayer )<br />
outputChatBox ( "IP: " .. getPlayerIP ( thePlayer ), thePlayer )<br />
end<br />
addCommandHandler ( "ip", printIp )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}<br />
[[de:GetPlayerIP]]</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerSerial&diff=40799GetPlayerSerial2014-07-15T05:24:51Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function returns the [[serial]] for a specified [[player]].<br />
<br />
==Syntax==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
string getPlayerSerial ( player thePlayer )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:getSerial|serial|}}<br />
===Required Arguments===<br />
*'''thePlayer:''' A [[player]] object referencing the specified player.<br />
</section><br />
{{New feature|3.0110|1.1|<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
string getPlayerSerial ( )<br />
</syntaxhighlight><br />
</section><br />
}}<br />
<br />
==Returns==<br />
Returns the serial as a ''string'' if it was found, ''false'' otherwise.<br />
<br />
==Example==<br />
<section name="Example 1" class="server" show="true"><br />
This example creates a command with which player can check their own serial.<br />
<syntaxhighlight lang="lua"><br />
function checkMySerial( thePlayer, command )<br />
local theSerial = getPlayerSerial( thePlayer )<br />
if theSerial then<br />
outputChatBox( "Your serial is: " .. theSerial, thePlayer )<br />
else<br />
outputChatBox( "Sorry, you have no serial. =(", thePlayer )<br />
end<br />
end<br />
addCommandHandler( "myserial", checkMySerial )<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Example 2" class="server" show="true"><br />
This example add command to ban player serial.<br />
<syntaxhighlight lang="lua"><br />
function banSerial( source, command, noob, reason )<br />
if ( noob ) then<br />
local theNoob = getPlayerFromName( noob )<br />
local theNoobSerial = getPlayerSerial( theNoob )<br />
if ( theNoob ) then<br />
addBan( theNoobSerial, source, reason )<br />
end<br />
end<br />
end<br />
addCommandHandler( "banserial", banSerial )<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Example 3" class="client" show="true"><br />
This example add command to get client's serial.<br />
<syntaxhighlight lang="lua"><br />
function getMySerial( )<br />
local theSerial = getPlayerSerial()<br />
outputChatBox("Your serial is: "..tostring(theSerial))<br />
end<br />
end<br />
addCommandHandler( "myserial", getMySerial )<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Example 3" class="server" show="true"><br />
This example is Firewall Account Player by serial on Login<br />
<syntaxhighlight lang="lua"><br />
Firewall = <br />
{<br />
[ 'AccountName' ] = 'SerialPlayer',<br />
[ '3ash8' ] = '9C9F3B55D9D7BB7135FF274D3BF444E4',<br />
[ 'test5' ] = '1D6F76CF8D7193792D13789849498452',<br />
}<br />
<br />
addEventHandler ( 'onPlayerLogin', getRootElement ( ),<br />
function ( _, theCurrentAccount )<br />
local Serial = Firewall[getAccountName(theCurrentAccount)]<br />
if ( Serial ) then<br />
if Serial ~= getPlayerSerial ( source ) then<br />
banPlayer ( source, false, false, true, getRootElement ( ), 'reason ban' )<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Serial functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerWantedLevel&diff=40798GetPlayerWantedLevel2014-07-15T05:24:06Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function gets a player's current wanted level. The wanted level is indicated by the amount of stars a player has on the GTA HUD.<br />
<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
int getPlayerWantedLevel ( player thePlayer )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:getWantedLevel|wantedLevel|setPlayerWantedLevel}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player whose wanted level you wish to get<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
int getPlayerWantedLevel ( )<br />
</syntaxhighlight> <br />
</section><br />
<br />
===Returns===<br />
Returns an ''int'' from 0 to 6 representing the player's wanted level, ''false'' if the player does not exist.<br />
<br />
==Example==<br />
<section name="Example 1: Server" class="server" show="true"><br />
This example finds which players in the server have a wanted level:<br />
<syntaxhighlight lang="lua"><br />
local players = getElementsByType ( "player" ) -- get a table of all the players in the server<br />
for theKey,thePlayer in ipairs(players) do -- use a generic for loop to step through each player<br />
local level = getPlayerWantedLevel ( thePlayer ) -- get the wanted level of the player<br />
if ( level > 0 ) then -- if the player has any stars, announce it in the chat:<br />
outputChatBox ( getPlayerName ( thePlayer ) .. " has a wanted level of " .. level .. " stars!" )<br />
end <br />
end<br />
</syntaxhighlight><br />
</section><br />
<section name="Example 2: Client" class="client" show="true"><br />
This script output your wanted level when you type /wanted.<br />
<syntaxhighlight lang="lua"><br />
function outputWantedLevel ()<br />
local wantedLvl = getPlayerWantedLevel ( )<br />
if wantedLvl == 0 then<br />
outputChatBox ( "You clean", 0, 255, 0)<br />
else<br />
outputChatBox ( "You have "..wantedLvl.." wanted stars!", 255, 0, 0)<br />
end<br />
end<br />
addCommandHandler ( "wanted", outputWantedLevel )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerPing&diff=40797GetPlayerPing2014-07-15T05:22:03Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function returns the ping of a specified [[player]]. The ping is the number of milliseconds that data takes to travel from the player's client to the server or vice versa.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">int getPlayerPing ( player thePlayer )</syntaxhighlight><br />
{{OOP||[[player]]:getPing|ping|}}<br />
===Required Arguments===<br />
*'''thePlayer''': The [[player]] whose ping you want to determine.<br />
<br />
===Returns===<br />
Returns the ping as an [[int]], or ''false'' if the player is invalid.<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example checks every players ping every 5 seconds and if it's over 500 they get kicked.<br />
<syntaxhighlight lang="lua"><br />
function kickPing() -- Creates a function called kickPing<br />
for i, player in ipairs(getElementsByType("player")) do -- Loop every player<br />
if (getPlayerPing(player) >= 500) then -- If their ping is over 500<br />
kickPlayer(player, "Ping over 500!") -- Kick them<br />
end<br />
end<br />
end<br />
setTimer(kickPing, 5000, 0) -- Every 5 seconds, the kickPing function is called.<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
This example checks the ping of every player entering the 'ping' command and warns him if it's over 100.<br />
<syntaxhighlight lang="lua"><br />
function checkPing()<br />
local ping = getPlayerPing(getLocalPlayer()) -- get the ping from the source element (the player who joined)<br />
if (ping > 100) then -- if it's higher than 100...<br />
outputChatBox("Your ping is pretty high! Please try to lower it if possible.") -- output a message to the player<br />
end<br />
end<br />
addCommandHandler("ping", checkPing)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerIdleTime&diff=40796GetPlayerIdleTime2014-07-15T05:21:07Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function gets the amount of time in milliseconds that a players position has not changed.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
int getPlayerIdleTime ( player thePlayer )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:getIdleTime|idleTime|}}<br />
===Required Arguments===<br />
*'''thePlayer''': The [[player]] you wish to get the idle time of.<br />
<br />
===Returns===<br />
Returns the amount of '''time in milliseconds''' that a player has been idle, '''false''' otherwise.<br />
<br />
==Example==<br />
<section name="Serverside example" class="server" show="true"><br />
This example will kick a player if they don't move for 5 minutes and the resource has access to "function.kickPlayer"<br />
<syntaxhighlight lang="lua"><br />
function checkAFKPlayers()<br />
for index, thePlayer in ipairs(getElementsByType("player"))do -- Loop all online players<br />
if (getPlayerIdleTime(thePlayer) > 300000) then -- Player hasn't moved for 300,000ms (5 minutes)<br />
kickPlayer(thePlayer, "Idle for 5 minutes") -- Kick the idle player<br />
end<br />
end<br />
end<br />
setTimer(checkAFKPlayers, 30000, 0) -- Timer to execute every 30 seconds, checking for idlers<br />
</syntaxhighlight><br />
</section><br />
<br />
==Requirements==<br />
{{Requirements|1.1.1-9.03316|n/a|}}<br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerName&diff=40795GetPlayerName2014-07-15T05:20:22Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function returns a string containing the name of the specified player.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
string getPlayerName ( player thePlayer )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:getName|name|setPlayerName}}<br />
===Required Arguments===<br />
* '''thePlayer:''' the Player that you want to get his name<br />
<br />
===Returns===<br />
Returns a string containing the requested player's name, or ''false'' if the player passed to the function is invalid.<br />
<br />
===Limits===<br />
* Player name can consist of ASCII characters between 33 and 126 are allowed (basic latin): <br />
<nowiki>!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</nowiki><br />
* Minimal player name length is 1 character. <br />
* Maximum player name length is 22 characters.<br />
* Player names are case-insensitive. It is not possible to have two clients with same name but different character case.<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
addCommandHandler("myname",<br />
function(playerSource)<br />
outputChatBox("Your name: "..getPlayerName(playerSource), playerSource)<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
This example outputs the local player name to the chatbox.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler("myname",<br />
function()<br />
local localPlayerName = getPlayerName(getLocalPlayer())<br />
--and we output it to the chatbox<br />
outputChatBox(localPlayerName)<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerNametagColor&diff=40794GetPlayerNametagColor2014-07-15T05:19:25Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
This function gets the current color of a player's name tag as RGB values. These are in the range 0-255.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
int, int, int getPlayerNametagColor ( player thePlayer )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:getNametagColor||}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player whose name tag RGB color values you wish to retrieve.<br />
<br />
===Returns===<br />
Returns ''red'', ''green'' and ''blue'' values if an existent player was specified, ''false'' otherwise.<br />
<br />
==Example== <br />
This console command will tell the player what his tag color is. The color is composed of a red, a green and a blue component, each ranging from 0-255.<br />
<syntaxhighlight lang="lua"><br />
function tagInfoCommand ( thePlayer, commandName )<br />
-- store the RGB data about the player who activated the command handler into the local variables r, g, b. <br />
local r, g, b = getPlayerNametagColor ( thePlayer )<br />
-- Display the RGB values in the chatbox<br />
outputChatBox ( "Your tag color is: R:" .. r .. " G:" .. g .. " B:" .. b, thePlayer )<br />
end<br />
addCommandHandler ( "retrievetagcolor", tagInfoCommand )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GetPlayerNametagText&diff=40793GetPlayerNametagText2014-07-15T05:18:10Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
This will allow you to retrieve the name tag a player is currently using.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
string getPlayerNametagText ( player thePlayer )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:getNametagText|nametagText|setPlayerNametagText}}<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''thePlayer:''' The person whose name tag you want to retrieve<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns a ''string'' with the nametag text, ''false'' if the player is invalid.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
This will output the nametag text of the player who enters the command 'myNametag'.<br />
<syntaxhighlight lang="lua"><br />
function showNametag ( thePlayer, command )<br />
local nameTag = getPlayerNametagText ( thePlayer )<br />
outputChatBox ( "Your nametag text is: " .. nameTag, thePlayer )<br />
end<br />
addCommandHandler("myNametag", showNametag)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=IsPlayerNametagShowing&diff=40792IsPlayerNametagShowing2014-07-15T05:17:20Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
{{Deprecated feature|3|1.0|Serverside only in DP2.x}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
This function will allow you to determine if a player's name tag is currently showing.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool isPlayerNametagShowing ( player thePlayer )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:isNametagShowing|nametagShowing|setPlayerNametagShowing}}<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''thePlayer:''' The player whose current name tag condition you want to check<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns ''true'' if the player's name tag is being shown, ''false'' otherwise.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
This example toggles a player's nametag. If no playername is given, it toggles the nametag of the player who entered the command.<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function toggleNametag ( sourcePlayer, command, who )<br />
local tplayer = sourcePlayer -- by default, toggle the name tag of the player who issued the command<br />
if ( who ) then -- if there was a nick entered in the command<br />
tplayer = getPlayerFromName ( who ) -- search for the player<br />
else<br />
whoNick = getPlayerName(sourcePlayer)<br />
end<br />
if ( tplayer ~= false ) then -- if the player was found (or no playername was entered)<br />
if isPlayerNametagShowing ( tplayer ) then -- if the nametag is shown<br />
setPlayerNametagShowing ( tplayer, false ) -- hide it<br />
outputChatBox ( who .. "'s nametag is now hidden", sourcePlayer ) -- output a message to the player who entered the command<br />
else -- if the nametag is not shown<br />
setPlayerNametagShowing ( tplayer, true ) -- show it<br />
outputChatBox ( who .. "'s nametag is now showing", sourcePlayer ) -- output a message to the player who entered the command<br />
end<br />
else<br />
outputChatBox ( "Player not found.", sourcePlayer )<br />
end<br />
end<br />
addCommandHandler ( "toggleNametag", toggleNametag )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=IsPlayerMuted&diff=40791IsPlayerMuted2014-07-15T05:16:24Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
Use this function to check if a player has been muted.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool isPlayerMuted ( player thePlayer )</syntaxhighlight><br />
{{OOP||[[player]]:isMuted|muted|setPlayerMuted}}<br />
===Required Arguments===<br />
*'''thePlayer:''' The [[player]] you are checking.<br />
<br />
===Returns===<br />
Returns ''true'' if the player is muted and ''false'' otherwise.<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
someguy = getPlayerFromName ( "someGuy" )<br />
if isPlayerMuted ( someguy ) then<br />
outputChatBox ( "It seems Someguy can't speak." )<br />
end<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=IsPlayerMapForced&diff=40790IsPlayerMapForced2014-07-15T05:14:13Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function checks if the specified player's radar map has been forced on or not.<br />
<br />
==Syntax==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">bool isPlayerMapForced ( player thePlayer )</syntaxhighlight><br />
{{OOP||[[player]]:isMapForced|mapForced|forcePlayerMap}}<br />
===Required Arguments===<br />
* '''thePlayer:''' A [[player]] object referencing the specified player<br />
<br />
===Returns===<br />
Returns ''true'' if the player's radar map is forced on, ''false'' otherwise.<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua">bool isPlayerMapForced ()</syntaxhighlight><br />
<br />
===Returns===<br />
Returns ''true'' if the local player's radar map is forced on, ''false'' otherwise.<br />
</section><br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example forces a players radar map on for 10 seconds if it hasn't been already.<br />
<syntaxhighlight lang="lua"><br />
function forceMapForPlayer ( callingPlayer, command, whoNick )<br />
local who = getPlayerFromName ( whoNick ) -- Look up the specified player<br />
if ( who ) then<br />
if ( not isPlayerMapForced ( who ) ) then -- if his radar map isn't already forced on<br />
forcePlayerMap ( who, true ) -- force it on<br />
setTimer ( forcePlayerMap, 10000, 1, who, false ) -- force it off in 10secs<br />
outputChatBox ( "Forcing Map for " .. whoNick, callingPlayer ) -- output a message to the one who entered the command<br />
else<br />
outputChatBox ( "Map already forced for " .. whoNick, callingPlayer ) -- if the map is already forced, output a message<br />
end<br />
else<br />
outputChatBox ( "Couldn't find " .. whoNick, callingPlayer ) -- if the player wasn't found, output a message<br />
end<br />
end<br />
addCommandHandler ( "forcemap", forceMapForPlayer ) -- add a command handler<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetCameraTarget&diff=40789SetCameraTarget2014-07-15T05:13:11Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Note|The function already places camera behind the player. No second call or a timer is needed.<br />
{{Needs Checking|No it doesn't. A timer of no less than 112 ms was required for the rotation to be set.}}}}<br />
<br />
__NOTOC__<br />
{{Server client function}}<br />
This function allows you to set a player's camera to follow other elements instead. Currently supported element type is:<br />
*[[Player]]s<br />
<br />
==Syntax==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setCameraTarget ( player thePlayer [, player target = nil ] )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:setCameraTarget|cameraTarget|getCameraTarget}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player whose camera you wish to modify.<br />
<br />
===Optional Arguments===<br />
*'''target:''' The player who you want the camera to follow. If none is specified, the camera will target the player.<br />
'''Note:''' setCameraTarget will behave strangely if the target you want the camera to follow is inside a vehicle that has hydraulics (upgrade id: 1087) added server sided and if the target is not you.<br />
</section><br />
<br />
<section name="Client 1" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setCameraTarget ( player target )<br />
</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
*'''target:''' The player who you want the local camera to follow.<br />
</section><br />
<br />
{{New feature/item|4.0132|1.3.1|5212|<br />
<section name="Client 2" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setCameraTarget ( float targetX, float targetY, float targetZ )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''targetX, targetY, targetZ:''' The target position that you want the local camera to look at.<br />
</section>}}<br />
<br />
===Returns===<br />
Returns ''true'' if the function was successful, ''false'' otherwise.<br />
<br />
==Example==<br />
This is an example of how one could implement a spectator function. Using the left and right arrow keys you can view other players. Note that this code isn't complete as it doesn't take into account joining or quitting players.<br />
<section class="client" name="Client script" show="true"><br />
<syntaxhighlight lang="lua"><br />
g_Players = getElementsByType("player") -- get a list of all players in the server<br />
for i,aPlayer in ipairs(g_Players) do -- find out what index the local player has in the list<br />
if aPlayer == getLocalPlayer() then<br />
g_CurrentSpectated = i<br />
break<br />
end<br />
end<br />
<br />
function spectatePrevious() -- decrement the spectate index and spectate the corresponding player<br />
if g_CurrentSpectated == 1 then<br />
g_CurrentSpectated = #g_Players<br />
else<br />
g_CurrentSpectated = g_CurrentSpectated - 1<br />
end<br />
setCameraTarget(g_Players[g_CurrentSpectated])<br />
end<br />
<br />
function spectateNext() -- increment the spectate index and spectate the corresponding player<br />
if g_CurrentSpectated == #g_Players then<br />
g_CurrentSpectated = 1<br />
else<br />
g_CurrentSpectated = g_CurrentSpectated + 1<br />
end<br />
setCameraTarget(g_Players[g_CurrentSpectated])<br />
end<br />
<br />
-- Bind above functions to arrow keys<br />
bindKey("arrow_l", "down", spectatePrevious)<br />
bindKey("arrow_r", "down", spectateNext)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Camera functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetCameraInterior&diff=40788SetCameraInterior2014-07-15T05:12:13Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Sets the interior of the local camera. Only the interior of the camera is changed, the local player stays in the interior he was in.<br />
<br />
==Syntax==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setCameraInterior ( player thePlayer, int interior )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:setCameraInterior|cameraInterior|getCameraInterior}}<br />
===Required Arguments===<br />
*'''thePlayer:''' the player whose camera interior will be set.<br />
*'''interior:''' the interior to place the camera in.<br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setCameraInterior ( int interior )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''interior:''' the interior to place the camera in.<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the camera's interior was changed successfully, ''false'' otherwise.<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
<br />
<strong> This example make a command to change your cam interior to a selected one. </strong> <br />
<br />
<syntaxhighlight lang="lua"><br />
function setCamInt( thePlayer, commandName, intID )<br />
if( intID )then -- If there is an ID<br />
local seted = setCameraInterior( thePlayer, intID ) -- set the interior to the camera<br />
if( seted )then -- If it has been changed correctly<br />
outputChatBox( "Your camera's interior has been set to "..intID, thePlayer ) -- Tell to the player his new camera's interior<br />
else -- otherwise<br />
outputChatBox( "Can't change your camera's interior...", thePlayer, 255, 0, 0 ) -- Tell him the change failed<br />
end<br />
else -- otherwise <br />
outputChatBox( "Syntax: /caminterior [interiorID] ", thePlayer, 255, 0, 0 ) -- Tell him the correct syntax<br />
end<br />
end<br />
addCommandHandler( "caminterior", setCamInt )<br />
</syntaxhighlight><br />
</section><br />
<section name="Client" class="client" show="true"><br />
<strong> This example make a command to change your cam interior to a selected one. </strong><br />
<syntaxhighlight lang="lua"><br />
function setCam(command,int)<br />
if (int) then<br />
local setInt = setCameraInterior(int)<br />
if (setInt) then<br />
outputChatBox("Your camera's interior has been set to "..int,255,255,0)<br />
else<br />
outputChatBox("Can't change your camera's interior...",255,0,0)<br />
end<br />
else<br />
outputChatBox("Syntax: /camera [interiorID] ",255,0,0)<br />
end<br />
end<br />
addCommandHandler("camera",setCam)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client_camera_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetCameraMatrix&diff=40787SetCameraMatrix2014-07-15T05:11:07Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function sets the camera's position and direction. The first three arguments are the point at which the camera lies, the last three are the point the camera faces (or the point it "looks at").<br />
<br />
'''Note:''' Calling this function takes the camera's focus away from the player and sets the camera in a fixed position and rotation. The camera's focus can be brought back to the player using the [[setCameraTarget]] function.<br />
==Syntax==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setCameraMatrix ( player thePlayer, float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:setCameraMatrix|cameraMatrix|getCameraMatrix}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player whose camera is to be changed.<br />
*'''positionX:''' The x coordinate of the camera's position.<br />
*'''positionY:''' The y coordinate of the camera's position.<br />
*'''positionZ:''' The z coordinate of the camera's position.<br />
<br />
===Optional Arguments=== <br />
*'''lookAtX:''' The x coordinate of the point the camera faces.<br />
*'''lookAtY:''' The y coordinate of the point the camera faces.<br />
*'''lookAtZ:''' The z coordinate of the point the camera faces.<br />
*'''roll:''' The camera roll angle, -180 to 180. A value of 0 means the camera sits straight, positive values will turn it counter-clockwise and negative values will turn it clockwise. -180 or 180 means the camera is upside down.<br />
*'''fov:''' the field of view angle, 0 to 180. The higher this value is, the more you will be able to see what is to your sides.<br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setCameraMatrix ( float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
*'''positionX:''' The x coordinate of the camera's position.<br />
*'''positionY:''' The y coordinate of the camera's position.<br />
*'''positionZ:''' The z coordinate of the camera's position.<br />
<br />
===Optional Arguments=== <br />
*'''lookAtX:''' The x coordinate of the point the camera faces.<br />
*'''lookAtY:''' The y coordinate of the point the camera faces.<br />
*'''lookAtZ:''' The z coordinate of the point the camera faces.<br />
*'''roll:''' The camera roll angle, -180 to 180. A value of 0 means the camera sits straight, positive values will turn it counter-clockwise and negative values will turn it clockwise. -180 or 180 means the camera is upside down.<br />
*'''fov:''' the field of view angle, 0 to 180. The higher this value is, the more you will be able to see what is to your sides.<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the arguments are valid, ''false'' otherwise.<br />
<br />
==Example==<br />
This code fixates the camera onto the Vinewood sign in Los Santos for any player that joins the server:<br />
<section class="server" name="Server script" show="true"><br />
<syntaxhighlight lang="lua"><br />
function setCameraOnPlayerJoin()<br />
-- slowly fade the camera in to make the screen visible<br />
fadeCamera(source, true, 5)<br />
-- set the player's camera to a fixed position, looking at a fixed point<br />
setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)<br />
end<br />
addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin)</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Camera functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerVoiceIgnoreFrom&diff=40786SetPlayerVoiceIgnoreFrom2014-07-15T05:09:05Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__ <br />
<div style="border: 1px dotted blue; background: #00CC66;padding:4px;margin-bottom:2px;">'''Note''': This function should only be used as a low-level function for advanced users. For typical Voice scripting, please see the [[Resource:Voice|Voice Resource]]</div><br />
This function allows you to mute voices for a player.<br />
<br />
==Syntax== <br />
<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerVoiceIgnoreFrom ( element thePlayer, mixed ignoreFrom )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:setVoiceIgnoreFrom|voiceIgnoreFrom|}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The [[player]] you wish to change<br />
*'''ignoreFrom:''' Element or table of elements which the player should not hear voices from. Use ''nil'' if no one should be ignored.<br />
<br />
===Returns===<br />
Returns ''true'' if the value was set successfully, ''false'' otherwise.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerVoiceBroadcastTo&diff=40785SetPlayerVoiceBroadcastTo2014-07-15T05:08:08Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__ <br />
<div style="border: 1px dotted blue; background: #00CC66;padding:4px;margin-bottom:2px;">'''Note''': This function should only be used as a low-level function for advanced users. For typical Voice scripting, please see the [[Resource:Voice|Voice Resource]]</div><br />
This function allows you to change who can hear the voice of a player.<br />
<br />
==Syntax== <br />
<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerVoiceBroadcastTo ( element thePlayer, mixed broadcastTo )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:setVoiceBroadcastTo|voiceBroadcastTo|}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The [[player]] you wish to change<br />
*'''broadcastTo :''' Element or table of elements who should hear the voice from this player<br />
<br />
===Returns===<br />
Returns ''true'' if the value was set successfully, ''false'' otherwise.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function getPlayer( ... )<br />
if ( ... ) then<br />
<br />
local elements = {};<br />
for _, string in ipairs( { ... } ) do<br />
for _, element in ipairs( getElementsByType( 'player' ) ) do<br />
if ( string.find( string:lower(), getPlayerName(element):lower(), 1, true ) ) then<br />
table.insert( elements, element );<br />
end<br />
end<br />
end<br />
<br />
return elements;<br />
end<br />
<br />
return false<br />
end<br />
<br />
addCommandHandler( 'broadcast', <br />
function( player, command, target, target_ )<br />
if ( target and target_ ) then<br />
target, target_ = getPlayer( target, target_ );<br />
if ( target and target_ ) then<br />
setPlayerVoiceBroadcastTo( target, target_ );<br />
else<br />
outputChatBox( not target and "Target 1 not found!" or not target_ and "Target 2 not found!", root, 255, 0, 0, false );<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerAnnounceValue&diff=40784SetPlayerAnnounceValue2014-07-15T05:05:18Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__ <br />
This function allows you to change ASE announce values for any player using a specified key.<br />
As an example this can be used to change the "score" value which will be shown at [http://www.game-monitor.com game-monitor.com]'s server list.<br />
<br />
==Syntax== <br />
<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerAnnounceValue ( element thePlayer, string key, string value )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:setAnnounceValue||}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The [[player]] whos announce value you wish to change.<br />
*'''key:''' The key which the value will be stored at.<br />
*'''value:''' The value you wish to store.<br />
<br />
===Returns===<br />
Returns ''true'' if the value was set succesfully, ''false'' otherwise.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This small example adds a command that allows you to set your own "score" value.<br />
<syntaxhighlight lang="lua">function setScore ( playerSource, cmdName, scoreValue )<br />
if ( scoreValue ) then<br />
setPlayerAnnounceValue ( playerSource, "score", scoreValue )<br />
end<br />
end<br />
<br />
addCommandHandler ( "score", setScore )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerNametagColor&diff=40783SetPlayerNametagColor2014-07-15T04:55:49Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
{{Note box|If the player is using a hexcode in front of their name, it will override this function. You must first strip the name of the hexcode using [[setPlayerNametagText]]}}<br />
<br />
{{Needs_Checking|See the note. There should probably be a useful function to do this instead of everyone trying to re-invent the wheel when they need to force nick colors ie TDM/gangwars. If someone makes a useful function, link it in the note.}}<br />
<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
This allows you to change the RGB color mixture in the name tags of players.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerNametagColor ( player thePlayer, int r, int g, int b )<br />
</syntaxhighlight> <br />
<br />
{{New feature|2|DP2|<br />
'''OR'''<br />
<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerNametagColor ( player thePlayer, false )<br />
</syntaxhighlight> <br />
}}<br />
{{OOP||[[player]]:setNametagColor||}}<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''thePlayer:''' The player whose name tag text you wish to change the color of<br />
*'''r:''' The amount of red you want in the mixture of RGB (0-255 is valid)<br />
*'''g:''' The amount of green you want in the mixture of RGB (0-255 is valid)<br />
*'''b:''' The amount of blue you want in the mixture of RGB (0-255 is valid)<br />
{{New feature|2|DP2|<br />
*'''false:''' If false is specified instead of the colors, the nametag color will reset to defaulting to your team color.<br />
}}<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns ''true'' if the function was successful, ''false'' otherwise.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
This will allow a player to change the RGB color mixture of their nickname. Valid RGB is between 0-255.<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
-- The handler function for the console command<br />
function nametagColorChange ( thePlayer, commandName, r, g, b )<br />
-- Apply the new color mix of RGB to the command handler activator<br />
setPlayerNametagColor ( thePlayer, r, g, b )<br />
end<br />
-- This is a command handler that activates on text "nametagcolor" in the console. It also asks <br />
-- the player to provide values for the extra parameters r, g, b after the command name. These will <br />
-- be the new color mix of RGB to apply to the player's name tag.<br />
addCommandHandler ( "nametagcolor", nametagColorChange )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerNametagShowing&diff=40782SetPlayerNametagShowing2014-07-15T04:54:44Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
{{New feature|3|1.0|This function allows you to set whether a player's nametag visibility both clientside and serverside}}<br />
<br />
Use this to define whether the player's name tag is visible or invisible.<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerNametagShowing ( player thePlayer, bool showing )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:setNametagShowing|nametagShowing|isPlayerNametagShowing}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' Define the player whos tag visiblity status you want to change<br />
*'''showing:''' Use true or false to show/hide the tag<br />
<br />
===Returns===<br />
Returns ''true'' if successful, ''false'' otherwise<br />
<br />
==Example== <br />
This script will turn off player tags for everyone<br />
<syntaxhighlight lang="lua"><br />
function onResourceStart ( )<br />
local players = getElementsByType ( "player" ) -- Store all the players in the server into a table<br />
for key, player in ipairs ( players ) do -- for all the players in the table<br />
setPlayerNametagShowing ( player, false ) -- turn off their nametag<br />
end<br />
end<br />
addEventHandler ( "onResourceStart", root, onResourceStart )<br />
<br />
function onPlayerJoin ( )<br />
-- Whoever joins the server should also have their nametags deactivated<br />
setPlayerNametagShowing ( source, false )<br />
end<br />
addEventHandler ( "onPlayerJoin", root, onPlayerJoin )<br />
<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerNametagText&diff=40781SetPlayerNametagText2014-07-15T04:53:52Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --><br />
This will change the text of a player's nickname in the world to something besides the nickname he chose. This will not change the player's actual nickname, it only changes the visible aspect inside the world (you will see his original nickname in the scoreboard and will refer to his original name in scripts).<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerNametagText ( player thePlayer, string text )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:setNametagText|nametagText|getPlayerNametagText}}<br />
===Required Arguments=== <br />
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --><br />
*'''thePlayer:''' The player whose nickname text you wish to change<br />
*'''text:''' The new nickname text that will be displayed<br />
<br />
===Returns===<br />
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --><br />
Returns ''true'' if successful, ''false'' otherwise.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This console command lets you change the name tag of lamers.<br />
<syntaxhighlight lang="lua"><br />
function iHateLamers ( thePlayer, commandName, playername )<br />
-- This is a command handler that activates on text "lamer" followed by the playername<br />
-- in the console. The playername argument was added as an extra function argument to store the<br />
-- name of the player whose text will be changed.<br />
if not playername then<br />
-- Prevents the command from running if the player did not specify a value for playername<br />
outputChatBox ( "You MUST define a player to change his name tag!", thePlayer )<br />
else<br />
local culprit = getPlayerFromName ( playername )<br />
-- This variable stores the result of trying to find the player associated with the playername<br />
-- that the user of the command specified<br />
if culprit then<br />
-- This checks to make sure a player nick was found. If it was not then the playername argument<br />
-- specified by the command user was not equivalent to the name of any players in the server<br />
setPlayerNametagText ( culprit, "IM_LAME" )<br />
-- finally, the nickname text is changed since the command arguments were checked and are valid<br />
else<br />
outputChatBox ( "Player does not exist!", thePlayer )<br />
end<br />
end<br />
end<br />
addCommandHandler ( "lamer", iHateLamers )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --><br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerMoney&diff=40780SetPlayerMoney2014-07-15T04:52:43Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Sets a player's money to a certain value, regardless of current player money. It should be noted that setting negative values does not work and in fact gives the player large amounts of money.<br />
{{Note|Using this function client side (not recommended) will not change a players money server side.}}<br />
<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerMoney ( player thePlayer, int amount [, bool instant = false ] ) </syntaxhighlight> <br />
{{OOP||[[player]]:setMoney|money|getPlayerMoney}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' Which player to set the money of.<br />
*'''amount:''' A whole integer specifying the new amount of money the player will have.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
{{New items|4.0132|1.4|<br />
*'''instant:''' If set to ''true'' money will be set instantly without counting up/down like in singleplayer.}}<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerMoney ( int amount [, bool instant = false ] ) </syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''amount:''' A whole integer specifying the new amount of money the local player will have.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
{{New items|4.0132|1.4|<br />
*'''instant:''' If set to ''true'' money will be set instantly without counting up/down like in singleplayer.}}<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the money was added, or ''false'' if invalid parameters were passed.<br />
<br />
==Example== <br />
'''Example 1:''' This example sets the player's money to the desired amount when he types "setcash" in console.<br />
<syntaxhighlight lang="lua"><br />
function setCash(thePlayer, command, amount) -- when the setcash function is called<br />
setPlayerMoney(thePlayer, tonumber(amount)) -- change player's money to the desired amount<br />
end<br />
addCommandHandler("setcash", setCash) -- add a command handler for setcash<br />
</syntaxhighlight><br />
'''Example 2:''' This sets all players the amount of 1337 money when "leet" is typed in console.<br />
<syntaxhighlight lang="lua"><br />
function leetmoney()<br />
setPlayerMoney(root, 1337)<br />
end<br />
addCommandHandler("leet", leetmoney)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerWantedLevel&diff=40779SetPlayerWantedLevel2014-07-15T04:51:28Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function is used to set a player's wanted level. The wanted level is indicated by the amount of stars a player has on the GTA HUD.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool setPlayerWantedLevel ( player thePlayer, int stars ) <br />
</syntaxhighlight> <br />
{{OOP||[[player]]:setWantedLevel|wantedLevel|getPlayerWantedLevel}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player whose wanted level is to be set<br />
*'''stars:''' An integer from 0 to 6 representing the wanted level<br />
<br />
===Returns===<br />
Returns ''true'' if the wanted level was set successfully, ''false'' if any of the arguments were invalid.<br />
<br />
==Example==<br />
This example sets a player's wanted level to six stars if they enter a certain colshape:<br />
<syntaxhighlight lang="lua"><br />
-- assume that there exists a collision shape named 'policeStation'<br />
function policeStationHit ( thePlayer ) <br />
setPlayerWantedLevel ( thePlayer, 6 ) -- set the player's wanted level to 6 stars<br />
outputChatBox ( getPlayerName ( thePlayer ) .. " entered the police station!" )<br />
end<br />
-- call 'policeStationHit' when a player enters the collision shape:<br />
addEventHandler ( "onColShapeHit", policeStation, policeStationHit )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerBlurLevel&diff=40778SetPlayerBlurLevel2014-07-15T04:49:40Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
Sets the motion blur level on the clients screen. Accepts a value between 0 and 255.<br />
<br />
==Syntax==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerBlurLevel ( player thePlayer, int level )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:setBlurLevel|blurLevel|getPlayerBlurLevel}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The [[player]] whose blur level will be changed.<br />
*'''level:''' The level to set the blur to (default: 36)<br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setBlurLevel ( int level )<br />
</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
*'''level:''' The level to set the blur to (default: 36)<br />
</section><br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example allows the player to set their blur level via a command<br />
<syntaxhighlight lang="lua"> <br />
function changeBlurLevel ( playerSource, command, blur )<br />
blur = tonumber(blur)<br />
if not blur or blur > 255 or blur < 0 then<br />
outputChatBox ( "Enter a value between 0 - 255.", playerSource )<br />
else<br />
setPlayerBlurLevel ( playerSource, blur )<br />
outputChatBox ( "Blur level set to: " .. blur, playerSource )<br />
end<br />
end<br />
<br />
addCommandHandler("blur", changeBlurLevel)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerMuted&diff=40777SetPlayerMuted2014-07-15T04:46:56Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
Use this function to mute or unmute the player.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool setPlayerMuted ( player thePlayer, bool state )</syntaxhighlight><br />
{{OOP||[[player]]:setMuted|muted|}}<br />
===Required Arguments===<br />
*'''thePlayer:''' The [[player]] you are muting or unmuting.<br />
*'''state:''' Use '''true''' to mute and '''false''' to unmute the player.<br />
<br />
===Returns===<br />
Returns ''true'' if the player was successfully muted or unmuted, ''false'' otherwise.<br />
<br />
==Example==<br />
This adds a /mute command that can be used to mute a player.<br />
<syntaxhighlight lang="lua"><br />
-- create the function<br />
function mutePlayer(player,command,victimName)<br />
-- if the player has specified a victim name to mute<br />
if victimName then<br />
-- get the victim player element from their name<br />
local victim = getPlayerFromName(victimName)<br />
-- if the player exists<br />
if victim then<br />
-- if they arent already muted<br />
if ( not isPlayerMuted(victim) ) then<br />
-- mute them and output a message to the chat<br />
setPlayerMuted(victim, true)<br />
outputChatBox("You have been muted.",victim)<br />
end<br />
else<br />
outputChatBox("Could not find player with name: "..tostring(victimName),player)<br />
end<br />
else<br />
outputChatBox("Usage: /mute <player name>",player)<br />
end<br />
end<br />
-- add the /mute command<br />
addCommandHandler("mute",mutePlayer)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=ForcePlayerMap&diff=40776ForcePlayerMap2014-07-15T04:35:24Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
This function is used to forcefully show a player's radar map.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool forcePlayerMap ( player thePlayer, bool forceOn )</syntaxhighlight><br />
{{OOP||[[player]]:forceMap|mapForced|isPlayerMapForced}}<br />
===Required Arguments===<br />
*'''thePlayer''': A [[player]] object referencing the specified player<br />
*'''forceOn''': A boolean value representing whether or not the players radar map will be forced on<br />
<br />
===Returns===<br />
Returns ''true'' if the player's radar map was forced on, ''false'' otherwise.<br />
<br />
==Example==<br />
This example forces the radar map to show for the player named "dave" on for 10 seconds, if it hasn't been already.<br />
<syntaxhighlight lang="lua"><br />
-- Get the player named "dave"<br />
dave = getPlayerFromName ( "dave" )<br />
-- Make sure we found him<br />
if ( dave ) then<br />
if not isPlayerMapForced ( dave ) then -- if his radar map isn't already forced on<br />
forcePlayerMap ( dave, true ) -- force it on<br />
setTimer ( forcePlayerMap, 10000, 1, dave, false ) -- stop forcing in 10 seconds<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SetPlayerHudComponentVisible&diff=40775SetPlayerHudComponentVisible2014-07-15T04:14:06Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
{{Note|This function is identical to showPlayerHudComponent}}<br />
This function will show or hide a part of the player's HUD. <br />
<br />
==Syntax== <br />
<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerHudComponentVisible ( player thePlayer, string component, bool show )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:showHudComponent||}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player element for which you wish to show/hide a HUD component<br />
*'''component:''' The component you wish to show or hide. Valid values are:<br />
:*'''ammo:''' The display showing how much ammo the player has in their weapon<br />
:*'''area_name:''' The text that appears containing the name of the area a player has entered<br />
:*'''armour:''' The display showing the player's armor<br />
:*'''breath:''' The display showing the player's breath<br />
:*'''clock:''' The display showing the in-game time<br />
:*'''health:''' The display showing the player's health<br />
:*'''money:''' The display showing how much money the player has<br />
:*'''radar:''' The bottom-left corner miniradar<br />
:*'''vehicle_name:''' The text that appears containing the player's vehicle name when the player enters a vehicle<br />
:*'''weapon:''' The display showing the player's weapon<br />
{{New feature|3.0110|1.1|<br />
:*'''radio:''' The display showing the radio label<br />
:*'''wanted:''' The display showing the player's wanted level<br />
:*'''crosshair:''' The weapon crosshair and sniper scope<br />
:*'''all:''' All of the above at the same time<br />
}}<br />
*'''show:''' Specify if the component should be shown (''true'') or hidden (''false'')<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool setPlayerHudComponentVisible ( string component, bool show )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''component:''' The component you wish to show or hide. Valid values are:<br />
:*'''ammo:''' The display showing how much ammo the player has in their weapon<br />
:*'''area_name:''' The text that appears containing the name of the area a player has entered<br />
:*'''armour:''' The display showing the player's armor<br />
:*'''breath:''' The display showing the player's breath<br />
:*'''clock:''' The display showing the in-game time<br />
:*'''health:''' The display showing the player's health<br />
:*'''money:''' The display showing how much money the player has<br />
:*'''radar:''' The bottom-left corner miniradar<br />
:*'''vehicle_name:''' The text that appears containing the player's vehicle name when the player enters a vehicle<br />
:*'''weapon:''' The display showing the player's weapon<br />
{{New feature/item|3.0110|1.1||<br />
:*'''radio:''' The display showing the radio label<br />
:*'''wanted:''' The display showing the player's wanted level<br />
:*'''crosshair:''' The weapon crosshair and sniper scope<br />
:*'''all:''' All of the above at the same time<br />
}}<br />
*'''show:''' Specify if the component should be shown (''true'') or hidden (''false'')<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the component was shown or hidden succesfully, ''false'' if an invalid argument was specified.<br />
<br />
==Requirements==<br />
{{Requirements|1.3.2|1.3.2}}<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example hides the ammo and weapon displays for players when they join.<br />
<syntaxhighlight lang="lua"><br />
-- Hide some of the hud components when a player joins the server<br />
addEventHandler ( "onPlayerJoin", root, <br />
function ()<br />
setPlayerHudComponentVisible ( source, "ammo", false ) -- Hide the ammo displays for the newly joined player<br />
setPlayerHudComponentVisible ( source, "weapon", false ) -- Hide the weapon displays for the newly joined player<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=TakePlayerMoney&diff=40774TakePlayerMoney2014-07-15T04:13:03Z<p>MarioKart: /* Syntax */ add the ".money" variable</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function subtracts money from a [[player]]'s current money amount.<br />
{{Note|Using this function client side (not recommended) will not change a players money server side.}}<br />
<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool takePlayerMoney ( player thePlayer, int amount )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:takeMoney|money|}}<br />
====Required Arguments==== <br />
*'''thePlayer:''' the [[player]] you are taking the money from.<br />
*'''amount:''' an integer number specifying the amount of money to take from the player.<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool takePlayerMoney ( int amount )<br />
</syntaxhighlight><br />
<br />
====Required Arguments==== <br />
*'''amount:''' an integer number specifying the amount of money to take from the player.<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the money was taken, or ''false'' if invalid parameters were passed.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example takes money from a player when he types "takecash ''number''" in the console.<br />
<syntaxhighlight lang="lua"><br />
function takeCash ( thePlayer, command, amount ) -- when the takecash command is called<br />
takePlayerMoney ( thePlayer, tonumber(amount) ) -- take the amount of money from the player<br />
end<br />
addCommandHandler ( "takecash", takeCash ) -- add a handler function for the command "takecash"<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}<br />
[[ru:takePlayerMoney]]</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=GivePlayerMoney&diff=40773GivePlayerMoney2014-07-15T04:11:52Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function adds money to a [[player]]'s current money amount. To set absolute values, [[setPlayerMoney]] can be used.<br><br />
{{Note|Using this function client side (not recommended) will not change a players money server side.}}<br />
<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">bool givePlayerMoney ( player thePlayer, int amount )</syntaxhighlight> <br />
{{OOP||[[player]]:giveMoney|money|}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' the [[player]] you are giving the money to.<br />
*'''amount:''' a positive integer number specifying the amount of money to give to the player.<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua">bool givePlayerMoney ( int amount )</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''amount:''' a positive integer number specifying the amount of money to give to the player.<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the money was added, or ''false'' if invalid parameters were passed.<br />
<br />
==Example== <br />
<section show="true" name="Example 1 - Client and Server" class="server"><br />
This example gives a player money when using "givecash" command.<br />
<syntaxhighlight lang="lua"><br />
function consoleGiveCash ( thePlayer, command, amount ) --when the givecash command is called<br />
givePlayerMoney ( thePlayer, amount ) --give the player money according to the amount<br />
end<br />
addCommandHandler ( "givecash", consoleGiveCash ) --add a handler function for the command "givecash"<br />
</syntaxhighlight><br />
</section><br />
<br />
<section show="true" name="Example 2 - Server" class="server"><br />
This example gives a player one thousand dollars, as a reward for killing another player.<br />
<syntaxhighlight lang="lua"><br />
function rewardOnWasted ( ammo, killer, killerweapon, bodypart )<br />
--if there is a killer, and that killer is not the same person as whoever died<br />
if ( killer ) and ( killer ~= source ) then <br />
givePlayerMoney ( killer, 1000 ) --reward the killer with 1000 cash.<br />
end<br />
end<br />
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) --attach the rewardOnWasted function to the relevant event.<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}<br />
[[ru:GivePlayerMoney]]</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=TakePlayerScreenShot&diff=40772TakePlayerScreenShot2014-07-15T04:08:16Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function forces a client to capture the current screen output and send it back to the server. The image will contain the GTA HUD and the output of any dxDraw functions that are not flagged as 'post GUI'. The image specifically excludes the chat box and all GUI (including the client console). The result is received with the event [[onPlayerScreenShot]].<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool takePlayerScreenShot( player thePlayer, int width, int height [ , string tag = "", int quality = 30, int maxBandwith = 5000 ] ) <br />
</syntaxhighlight> <br />
{{OOP||[[player]]:takeScreenshot||}}<br />
===Required Arguments=== <br />
*'''thePlayer:''' the player to get the screen capture from.<br />
*'''width:''' the width of the capture image.<br />
*'''height:''' the height of the capture image.<br />
<br />
===Optional Arguments=== <br />
*'''tag :''' A string to help identify the screen capture. The string is passed to the matching [[onPlayerScreenShot]] event for your personal convenience.<br />
*'''quality :''' Quality of the final JPEG image from 0 to 100. A lower value can reduce the memory used by the image considerably which will result in faster and less intrusive uploads.<br />
*'''maxBandwith :''' The amount of client upload bandwidth to use (in bytes per second) when sending the image.<br />
<br />
===Returns===<br />
Returns ''true'' if the function was successfully, ''false'' if invalid arguments are specified.<br />
<br />
==Example== <br />
This example will initiate a capture of a Random Players screen<br />
<syntaxhighlight lang="lua"><br />
local player = getRandomPlayer()<br />
takePlayerScreenShot( player, 320, 240 )<br />
</syntaxhighlight><br />
<br />
==Requirements==<br />
{{Requirements|1.3|n/a|}}<br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=TakePlayerMoney&diff=40771TakePlayerMoney2014-07-15T04:06:28Z<p>MarioKart: OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function subtracts money from a [[player]]'s current money amount.<br />
{{Note|Using this function client side (not recommended) will not change a players money server side.}}<br />
<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool takePlayerMoney ( player thePlayer, int amount )<br />
</syntaxhighlight> <br />
{{OOP||[[player]]:takeMoney||}}<br />
====Required Arguments==== <br />
*'''thePlayer:''' the [[player]] you are taking the money from.<br />
*'''amount:''' an integer number specifying the amount of money to take from the player.<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool takePlayerMoney ( int amount )<br />
</syntaxhighlight><br />
<br />
====Required Arguments==== <br />
*'''amount:''' an integer number specifying the amount of money to take from the player.<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the money was taken, or ''false'' if invalid parameters were passed.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example takes money from a player when he types "takecash ''number''" in the console.<br />
<syntaxhighlight lang="lua"><br />
function takeCash ( thePlayer, command, amount ) -- when the takecash command is called<br />
takePlayerMoney ( thePlayer, tonumber(amount) ) -- take the amount of money from the player<br />
end<br />
addCommandHandler ( "takecash", takeCash ) -- add a handler function for the command "takecash"<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}<br />
[[ru:takePlayerMoney]]</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=SpawnPlayer&diff=40770SpawnPlayer2014-07-15T04:05:10Z<p>MarioKart: OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function spawns the player at an arbitary point on the map.<br><br />
{{Note|[[setCameraTarget]] must be used to focus on the player. Also, all players have their camera initially faded out after connect. To ensure that the camera is faded in, please do a [[fadeCamera]] after.}}<br />
<br />
{{Note|Do not use [[spawnPlayer]] within an event handler remotely called from [[onClientPlayerWasted]]. See Issue #8148 for details.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool spawnPlayer ( player thePlayer, float x, float y, float z, [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = nil ] )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:spawn||}}<br />
===Required Arguments===<br />
*'''thePlayer:''' The player you want to spawn.<br />
*'''x:''' The x co-ordinate to spawn the player at.<br />
*'''y:''' The y co-ordinate to spawn the player at.<br />
*'''z:''' The z co-ordinate to spawn the player at.<br />
<br />
===Optional Arguments===<br />
*'''rotation:''' rotation of the player on spawn.<br />
*'''skinID:''' player's skin on spawn. [[Character Skins]]<br />
*'''interior:''' interior the player will spawn into. [[Interior IDs]]<br />
*'''dimension:''' The ID of the [[dimension]] that the player should be in.<br />
*'''theTeam:''' the team the player will join.<br />
<br />
===Returns===<br />
Returns ''true'' if the player was spawned successfully, ''false'' otherwise.<br />
<br />
==Example== <br />
This example spawns all the players in the middle of the game map.<br />
<syntaxhighlight lang="lua"><br />
-- Get a table of all the players<br />
players = getElementsByType ( "player" )<br />
-- Go through every player<br />
for playerKey, playerValue in ipairs(players) do<br />
-- Spawn them at the desired coordinates<br />
spawnPlayer ( playerValue, 0.0, 0.0, 5.0, 90.0, 0 )<br />
end<br />
</syntaxhighlight><br />
<br />
This example spawns a player when he logs in.<br />
<syntaxhighlight lang="lua"><br />
spawnTeam = createTeam ("Teamname", 255, 0, 0) -- Create team to spawn.<br />
function spawnOnLogin (prevA, curA, autoLogin)<br />
outputChatBox ("Welcome to ...", source, 255, 0, 0, false)<br />
spawnPlayer (source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) -- spawns player with random skin<br />
fadeCamera (source, true)<br />
setCameraTarget (source, source)<br />
end<br />
addEventHandler("onPlayerLogin", getRootElement(), spawnOnLogin)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player_functions}}<br />
[[ru:spawnPlayer]]</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=ResendPlayerModInfo&diff=40769ResendPlayerModInfo2014-07-15T04:04:03Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
<br />
This function will force the specified player to resend their mod info, triggering the [[onPlayerModInfo]] event again.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool resendPlayerModInfo ( player thePlayer )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:resendModInfo||}}<br />
===Required Arguments===<br />
*'''thePlayer''': A [[player]] object referencing the specified player<br />
<br />
===Returns===<br />
Returns ''true'' if the mod info will be resent, ''false'' otherwise.<br />
<br />
==Example== <br />
This example shows how to resend each players mod info during [[onResourceStart]]<br />
<syntaxhighlight lang="lua"><br />
addEventHandler( "onResourceStart", resourceRoot,<br />
function()<br />
for _,player in ipairs( getElementsByType("player") ) do<br />
resendPlayerModInfo( player )<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
==Requirements==<br />
{{Requirements|1.1.1-9.03451|n/a|}}<br />
<br />
==See Also==<br />
{{Player functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=RedirectPlayer&diff=40768RedirectPlayer2014-07-15T04:02:50Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function redirects the player to a specified server.<br><br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool redirectPlayer ( player thePlayer, string serverIP, int serverPort, [ string serverPassword ] )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:redirect||}}<br />
===Required Arguments===<br />
*'''thePlayer:''' The player you want to redirect<br />
*'''serverIP:''' The IP address (or domain name that resolves to the IP address) of the server you want to redirect the player to. Use an empty string to reconnect to the same server.<br />
*'''serverPort:''' The game port of the server you want to redirect the player to, this is usually 22003. Set to zero to use the same port as the current server.<br />
<br />
===Optional Arguments===<br />
*'''serverPassword:''' The password for the server if it's protected<br />
<br />
===Returns===<br />
Returns ''true'' if the player was redirected successfully, ''false'' if bad arguments were passed.<br />
<br />
==Example== <br />
This example adds a "joinserver" command using the syntax, "/joinserver serverIP serverPort [serverPassword]".<br />
<syntaxhighlight lang="lua"><br />
function joinserverHandlerFunction (playerSource, commandName, serverIP, serverPort, serverPassword)<br />
if serverIP and serverPort then --if IP and Port were specified<br />
if serverPassword then --if also a password was specified<br />
redirectPlayer (playerSource, serverIP, tonumber(serverPort), serverPassword) --redirect the player<br />
else -- else if no password was specified<br />
redirectPlayer (playerSource, serverIP, tonumber(serverPort)) --redirect the player without using the serverPassword parameter<br />
end<br />
else -- if no IP or Port have been specified<br />
outputChatBox ("Error! Correct Syntax: /joinserver IP Port [Password]", playerSource) --output an Error message to the chatbox<br />
end<br />
end<br />
<br />
addCommandHandler ("joinserver", joinserverHandlerFunction) <br />
</syntaxhighlight><br />
<br />
{{New feature/item|3.0120|1.2|3429|<br />
This example adds a "rejoin" command like the inbuilt reconnect command.<br />
<syntaxhighlight lang="lua"><br />
function rejoinMe(thePlayer, theCommand)<br />
redirectPlayer(thePlayer,"",0)<br />
end<br />
addCommandHandler("rejoin", rejoinMe) -- Attach rejoin command to our function<br />
</syntaxhighlight><br />
}}<br />
==See Also==<br />
{{Player_functions}}</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=KickPlayer&diff=40767KickPlayer2014-07-15T04:01:51Z<p>MarioKart: /* Syntax */ OOP syntax added</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__<br />
This function will kick the specified player from the server.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool kickPlayer ( player kickedPlayer, [ player responsiblePlayer, string reason = "" ] ) <br />
</syntaxhighlight><br />
''or''<br />
<syntaxhighlight lang="lua"><br />
bool kickPlayer ( player kickedPlayer, [ string reason = "" ] )<br />
</syntaxhighlight><br />
{{OOP||[[player]]:kick||}}<br />
===Required Arguments=== <br />
*'''kickedPlayer:''' The player that will be kicked from the server<br />
<br />
===Optional Arguments=== <br />
*'''responsiblePlayer:''' The player that is responsible for the event. '''Note''': If left out as in the second syntax, responsible player for the kick will be "Console" (Maximum 30 characters if using a string).<br />
*'''reason:''' The reason for the kick. (Maximum 64 characters)<br />
<br />
===Returns===<br />
Returns ''true'' if the player was kicked succesfully, ''false'' if invalid arguments are specified.<br />
<br />
==Example== <br />
This example lets a player kick anyone who has a lower level.<br />
<syntaxhighlight lang="lua"><br />
function kickPlayerHandler ( sourcePlayer, commandname, kickedname, reason )<br />
-- Get player element from the name<br />
local kicked = getPlayerFromName ( kickedname )<br />
-- If the client who sent the command has a higher level<br />
if ( hasObjectPermissionTo ( sourcePlayer, "function.kickPlayer" ) ) then<br />
-- Kick the player<br />
kickPlayer ( kicked, sourcePlayer, reason )<br />
end<br />
end<br />
-- Add the "kick" command handler<br />
addCommandHandler ( "kick", kickPlayerHandler )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Admin_functions}}<br />
[[es:kickPlayer]]<br />
[[ru:kickPlayer]]</div>MarioKarthttps://wiki.multitheftauto.com/index.php?title=BanPlayer&diff=40766BanPlayer2014-07-15T04:00:15Z<p>MarioKart: /* Syntax */</p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
{{New feature|3|1.0|<br />
This function will ban the specified player by either IP, [[serial]] or username<br />
}}<br />
<br />
{{Deprecated_feature|3|1.0|<br />
This function will ban the specified player from the server by IP.<br />
}}<br />
<br />
==Syntax== <br />
{{New feature|3|1.0|<br />
<syntaxhighlight lang="lua"><br />
ban banPlayer ( player bannedPlayer, [ bool IP = true, bool Username = false, bool Serial = false, <br />
player responsiblePlayer = nil, string reason = nil, int seconds = 0 ] )<br />
</syntaxhighlight><br />
}}<br />
<br />
{{Deprecated_feature|3|1.0|<br />
<syntaxhighlight lang="lua"><br />
bool banPlayer ( player bannedPlayer , [ element responsibleElement, string reason ] ) <br />
</syntaxhighlight><br />
}}<br />
{{OOP||[[player]]:ban||}}<br />
===Required Arguments=== <br />
*'''bannedPlayer:''' The player that will be banned from the server.<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
{{New feature|3|1.0|<br />
*'''IP:''' Will player be banned by IP?<br />
*'''Username:''' Will player be banned by username?<br />
*'''Serial:''' Will player be banned by serial?<br />
<br />
:'''Note:''' to ban by username or serial, ''verifyserials'' must be enabled in the server configuration file.<br />
<br />
}}<br />
*'''responsibleElement:''' The element that is responsible for banning the player. This can be a player or the root ([[getRootElement]]()) (Maximum 30 characters if using a string).<br />
*'''reason:''' The reason the player will be banned from the server.<br />
*'''seconds:''' The amount of seconds the player will be banned from the server for. This can be 0 for an infinite amount of time.<br />
<br />
===Returns===<br />
{{Deprecated_feature|3|1.0|<br />
Returns ''true'' if the player was banned succesfully, ''false'' if invalid arguments are specified.<br />
}}<br />
<br />
{{New feature|3|1.0|<br />
Returns a [[ban]] object if banned successfully, or ''false'' if unsuccessful.<br />
}}<br />
<br />
==Example==<br />
This example lets a player ban anyone if he has ACL rights.<br />
<syntaxhighlight lang="lua"><br />
--Add the "ban" command handler<br />
-- Example with the player<br />
function banPlayerCommand ( theClient, commandName, bannedName, reason )<br />
<br />
-- Give the player a nice error if he doesn't have rights<br />
if ( hasObjectPermissionTo ( theClient, "function.banPlayer" ) ) then<br />
--Get player element from the name<br />
local bannedPlayer = getPlayerFromName ( bannedName )<br />
<br />
--Ban the player<br />
banPlayer ( bannedPlayer, theClient, reason )<br />
outputChatBox ( "ban: " .. bannedName .. " successfully banned", theClient )<br />
<br />
else<br />
outputChatBox ( "ban: You don't have enough permissions", theClient )<br />
end<br />
<br />
end<br />
addCommandHandler ( "ban", banPlayerCommand )<br />
<br />
-- Example function with the root element. Here you would pass a player element to the function.<br />
function banCheater(theCheater)<br />
banPlayer(theCheater, getRootElement(), "You are banned because of cheating.")<br />
end<br />
</syntaxhighlight><br />
<br />
<br />
This example is Firewall Account Player by serial on Login<br />
<syntaxhighlight lang="lua"><br />
Firewall = <br />
{<br />
[ 'AccountName' ] = 'SerialPlayer',<br />
[ '3ash8' ] = '9C9F3B55D9D7BB7135FF274D3BF444E4',<br />
[ 'test5' ] = '1D6F76CF8D7193792D13789849498452',<br />
}<br />
<br />
addEventHandler ( 'onPlayerLogin', getRootElement ( ),<br />
function ( _, theCurrentAccount )<br />
local Serial = Firewall[getAccountName(theCurrentAccount)]<br />
if ( Serial ) then<br />
if Serial ~= getPlayerSerial ( source ) then<br />
banPlayer ( source, false, false, true, getRootElement ( ), 'reason ban' )<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Admin_functions}}<br />
[[es:banPlayer]]<br />
[[ru:BanPlayer]]</div>MarioKart