https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=50pence&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-29T15:51:18ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=Community_Resources&diff=16946Community Resources2008-06-02T19:43:27Z<p>50pence: </p>
<hr />
<div>==Community calls documentation==<br />
using callRemote<br />
<br />
==community.mtasa.com/mta/verify.php==<br />
<br />
'''Calls:'''<br />
<br />
User validation:<br />
<syntaxhighlight lang="lua"><br />
player thePlayer, string Username, string Serial<br />
</syntaxhighlight> <br />
'''Returns:''' an integer, 1 if user is valid, 0 otherwise<br />
<br />
<br />
==community.mtasa.com/mta/groups.php==<br />
<br />
'''Calls:'''<br />
<br />
Info:<br />
<syntaxhighlight lang="lua"><br />
string "info", int groupID<br />
</syntaxhighlight> <br />
'''Returns 5 values:'''<br /><br />
1. Group name<br /><br />
2. Owner username<br /><br />
3. Number of members<br /><br />
4. Public. Integer: 1 if the group is public, 0 otherwise<br /><br />
5. Registration time<br /><br />
<br />
<br />
Members list:<br />
<syntaxhighlight lang="lua"><br />
string "members", int groupID<br />
</syntaxhighlight> <br />
'''Returns:''' a table of usernames in the group<br />
<br />
<br />
==community.mtasa.com/mta/resources.php==<br />
<br />
'''Calls:'''<br />
<br />
Latest resource version:<br />
<syntaxhighlight lang="lua"><br />
string "version", string resourceName<br />
</syntaxhighlight> <br />
'''Returns:''' a string, resource version in format of "x.x.x". Integer 0 if an error has occured<br />
<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addEventHandler ( "onPlayerJoin", getRootElement(), function()<br />
local username = getPlayerUserName ( source )<br />
local serial = getPlayerSerial ( source )<br />
callRemote ( "http://community.mtasa.com/mta/verify.php", validatePlayer, source, username, serial )<br />
end )<br />
<br />
function validatePlayer ( player, result )<br />
local valid = "invalid"<br />
if ( result == 1 ) then valid = "valid" end<br />
outputChatBox ( getClientName ( player ).."'s username is "..valid )<br />
end<br />
</syntaxhighlight><br />
[[Category:Scripting Concepts]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=OnPlayerVehicleExit&diff=16921OnPlayerVehicleExit2008-05-29T19:27:22Z<p>50pence: /* Source */ --> "player that entered"?</p>
<hr />
<div>__NOTOC__ <br />
{{Server event}}<br />
This event is triggered when a player leaves a vehicle, for whatever reason.<br />
<br />
==Parameters== <br />
<syntaxhighlight lang="lua"><br />
vehicle theVehicle, int seat, player jacker<br />
</syntaxhighlight> <br />
<br />
*'''theVehicle''': A vehicle element representing the vehicle in which the player exited from<br />
*'''seat''': An integer representing the seat in which the player was before exiting<br />
*'''jacker''': A player element representing the player who jacked the driver<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] that left the vehicle.<br />
<br />
==Example== <br />
This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off.<br />
<syntaxhighlight lang="lua"><br />
function addHelmetOnEnter ( vehicle, seat, jacked )<br />
if ( getVehicleID ( vehicle ) == 522 ) then -- if its a nrg<br />
addPlayerClothes ( source, "moto", "moto", 16 ) -- add the helmet<br />
end<br />
end<br />
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), addHelmetOnEnter )<br />
<br />
function removeHelmetOnExit ( vehicle, seat, jacked )<br />
if ( getVehicleID ( vehicle ) == 522 ) then -- if its a nrg<br />
removePlayerClothes ( source, 16 ) -- remove the helmet<br />
end<br />
end<br />
addEventHandler ( "onPlayerVehicleExit", getRootElement(), removeHelmetOnExit )<br />
</syntaxhighlight><br />
<br />
{{See also/Server event|Player events}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GetMTAVersion&diff=16825GetMTAVersion2008-05-23T20:09:47Z<p>50pence: New page: __NOTOC__ {{Client function}} This function returns a string which tell you which MTA version player uses. ==Syntax== <syntaxhighlight lang="lua"> string getMTAVersion( ) </syntaxhighlight> ===Required Arguments=== ...</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
This function returns a string which tell you which MTA version player uses.<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
string getMTAVersion( )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
None<br />
<br />
===Returns===<br />
A ''string'' - currently: "1.0 dp2.1" <br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
function checkVersion( )<br />
if getMTAVersion( ) ~= "1.0 dp2.1" then<br />
outputChatBox( "Download the least MTA:SA DM and come back!" )<br />
end<br />
end<br />
addEventHandler( "onClientPlayerJoin", getRootElement(), checkVersion )<br />
</syntaxhighlight></div>50pencehttps://wiki.multitheftauto.com/index.php?title=GuiGridListSetSelectedItem&diff=16802GuiGridListSetSelectedItem2008-05-21T01:10:25Z<p>50pence: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function selects an item from a gridlist. If you want to deselect selected item use 0 as rowIndex and 0 as a columnIndex param.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool guiGridListSetSelectedItem ( element gridList, int rowIndex, int columnIndex )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''gridList:''' the grid list you want to select an item from<br />
*'''rowIndex:''' the row you want to select (index 0 is the first row)<br />
*'''columnIndex:''' the column you want to select (index 1 is the first column)<br />
<br />
===Returns===<br />
Returns ''true'' if the passed arguments are correct and the item has been selected, ''false'' otherwise.<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
guiGridListSetSelectedItem ( spawnScreenGridList, 0, 0) -- resets selection to zero<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{GUI functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GuiGridListSetSelectedItem&diff=16801GuiGridListSetSelectedItem2008-05-21T01:09:31Z<p>50pence: Info on deselecting Item given</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
This function selects an item from a gridlist. If you want to deselect selected item use -1 as rowIndex and 0 as a columnIndex param.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool guiGridListSetSelectedItem ( element gridList, int rowIndex, int columnIndex )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''gridList:''' the grid list you want to select an item from<br />
*'''rowIndex:''' the row you want to select (index 0 is the first row)<br />
*'''columnIndex:''' the column you want to select (index 1 is the first column)<br />
<br />
===Returns===<br />
Returns ''true'' if the passed arguments are correct and the item has been selected, ''false'' otherwise.<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
guiGridListSetSelectedItem ( spawnScreenGridList, 0, 0) -- resets selection to zero<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{GUI functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=OnClientGUIClick&diff=16798OnClientGUIClick2008-05-19T17:19:18Z<p>50pence: </p>
<hr />
<div>{{Client event}}<br />
__NOTOC__<br />
{{Needs Checking|''middle'' button does not trigger this event.--[[User:50pence|50pence]] 12:19, 19 May 2008 (CDT)}}<br />
This event is fired when the user clicks a GUI element.<br />
<br />
==Parameters== <br />
<syntaxhighlight lang="lua"><br />
string button, string state, int absoluteX, int absoluteY<br />
</syntaxhighlight><br />
*'''button:''' the name of the mouse button that the GUI element was clicked with, can be ''left'', ''right'', or ''middle''.<br />
*'''state:''' the state of the mouse button, will be ''down'' if the mouse button was pushed, or ''up'' if it was released.<br />
*'''absoluteX:''' the X position of the mouse cursor, in pixels, measured from the left side of the screen.<br />
*'''absoluteY:''' the Y position of the mouse cursor, in pixels, measured from the top of the screen.<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the GUI element that was clicked.<br />
<br />
==Example== <br />
This example creates an edit box alongside an "Output!" button. When the button is clicked with the left mouse button, it will output the message in the edit box into the Chat Box.<br />
<syntaxhighlight lang="lua"><br />
--create our button<br />
btnOutput = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true )<br />
<br />
--Create an edit box and define it as "editBox".<br />
editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true )<br />
guiEditSetMaxLength ( editBox, 128 ) --the max chatbox length is 128, so force this<br />
<br />
--setup our function to output the message to the chatbox<br />
function outputEditBox (button)<br />
if button == "left" then<br />
local text = guiGetText ( editBox )--get the text from the edit box<br />
outputChatBox ( text ) --output that text<br />
end<br />
end<br />
--and attach our button to the outputEditBox function<br />
addEventHandler ( "onClientGUIClick", btnOutput, outputEditBox )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===GUI events===<br />
{{GUI_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=OnClientGUIClick&diff=16797OnClientGUIClick2008-05-19T17:18:47Z<p>50pence: </p>
<hr />
<div>{{Client event}}<br />
__NOTOC__<br />
{{Needs Checking|''middle'' button does not trigger this event.}}<br />
This event is fired when the user clicks a GUI element.<br />
<br />
==Parameters== <br />
<syntaxhighlight lang="lua"><br />
string button, string state, int absoluteX, int absoluteY<br />
</syntaxhighlight><br />
*'''button:''' the name of the mouse button that the GUI element was clicked with, can be ''left'', ''right'', or ''middle''.<br />
*'''state:''' the state of the mouse button, will be ''down'' if the mouse button was pushed, or ''up'' if it was released.<br />
*'''absoluteX:''' the X position of the mouse cursor, in pixels, measured from the left side of the screen.<br />
*'''absoluteY:''' the Y position of the mouse cursor, in pixels, measured from the top of the screen.<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the GUI element that was clicked.<br />
<br />
==Example== <br />
This example creates an edit box alongside an "Output!" button. When the button is clicked with the left mouse button, it will output the message in the edit box into the Chat Box.<br />
<syntaxhighlight lang="lua"><br />
--create our button<br />
btnOutput = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true )<br />
<br />
--Create an edit box and define it as "editBox".<br />
editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true )<br />
guiEditSetMaxLength ( editBox, 128 ) --the max chatbox length is 128, so force this<br />
<br />
--setup our function to output the message to the chatbox<br />
function outputEditBox (button)<br />
if button == "left" then<br />
local text = guiGetText ( editBox )--get the text from the edit box<br />
outputChatBox ( text ) --output that text<br />
end<br />
end<br />
--and attach our button to the outputEditBox function<br />
addEventHandler ( "onClientGUIClick", btnOutput, outputEditBox )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===GUI events===<br />
{{GUI_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=HasObjectPermissionTo&diff=16671HasObjectPermissionTo2008-05-02T02:39:36Z<p>50pence: /* Optional Arguments */</p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
This function returns whether or not the given object has access to perform the given action. <br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theObject:''' The object to test if has permission to. This can be a client element (ie. a player), a resource or a string in the form "user.<name>" or "resource.<name>".<br />
*'''theAction:''' The action to test if the given object has access to. Ie. "function.kickPlayer".<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''defaultPermission:''' The default permission if none is specified in either of the groups the given object is a member of. If this is left to true, the given object will have permissions to perform the action unless the opposite is explicitly specified in the [[ACL]]. If false, the action will be denied by default unless explicitly approved by the [[Access Control List]].<br />
<br />
===Returns===<br />
Returns ''true'' if the given object has permission to perform the given action, ''false'' otherwise. Returns ''nil'' if the function failed because of bad arguments.<br />
<br />
==Example== <br />
This example kicks a player if the user using it has access to the kickPlayer function.<br />
<syntaxhighlight lang="lua"><br />
-- Ban command<br />
function onKickCommandHandler ( playerSource, commandName, playerToKick, stringReason )<br />
-- Does the calling user have permission to kick the player? Default<br />
-- to false for safety reasons. We do this so any user can't use us to<br />
-- kick players.<br />
if ( hasObjectPermissionTo ( playerSource, "function.kickPlayer", false ) ) then<br />
<br />
-- Do we have permission to kick the player? We do this so we can fail<br />
-- nicely if this resource doesn't have access to call that function.<br />
if ( hasObjectPermissionTo ( getThisResource (), "function.kickPlayer", true ) ) then<br />
-- Kick him<br />
kickPlayer ( playerToKick, playerSource, stringReason )<br />
else<br />
-- Resource doesn't have any permissions, sorry<br />
outputChatBox ( "kick: The admin resource is not able to kick players. Please give this resource access to 'function.kickPlayer' in the ACL to use this function.", playerSource )<br />
end<br />
else<br />
-- User doesn't have any permissions<br />
outputChatBox ( "kick: You don't have permissions to use this command.", playerSource )<br />
end<br />
end<br />
addCommandHandler ( "kick", onKickCommandHandler )<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 />
{{ACL_functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=OnClientPlayerDamage&diff=16605OnClientPlayerDamage2008-04-22T23:11:22Z<p>50pence: /* Parameters */ attacker is also vehicle that you've fallen off</p>
<hr />
<div>__NOTOC__<br />
{{Client event}}<br />
This event is triggered whenever a player is damaged.<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
player attacker, int weapon, int bodypart [, float loss ]<br />
</syntaxhighlight> <br />
<br />
*'''attacker''': A [[player]] [[element]] representing the attacker or [[vehicle]] [[element]] (when you fall of a bike).<br />
*'''weapon''': An integer representing the weapon ID the attacker used<br />
*'''bodypart''': An integer representing the bodypart the player was damaged<br />
{{BodyParts}}<br />
*'''loss''': A float representing the percentage of health the player lost. ('''from DP3''')<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] that got damaged<br />
<br />
==Cancel effect==<br />
If this event is [[Event system#Canceling|canceled]], then any damaging effects to the local player will cease.<br />
<br />
==Example== <br />
This example prevents any damage from the minigun.<br />
<syntaxhighlight lang="lua"><br />
function stopMinigunDamage ( attacker, weapon, bodypart )<br />
if ( weapon == 38 ) then --if the weapon used was the minigun<br />
cancelEvent() --cancel the event<br />
end<br />
end<br />
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopMinigunDamage )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===Client player events===<br />
{{Client_player_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GuiGridListAddRow&diff=16596GuiGridListAddRow2008-04-21T01:58:08Z<p>50pence: /* Syntax */ my bad :(</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
Adds a row to a grid list.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
int guiGridListAddRow ( element gridList )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''gridList:''' The grid list you want to add a row to<br />
<br />
===Returns===<br />
Returns the row id if it has been created, ''false'' otherwise.<br />
<br />
==Example== <br />
This example creates a player list on the right side of the screen and fills it with the names of the connected players.<br />
<syntaxhighlight lang="lua"><br />
function clientsideResourceStart ()<br />
local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list<br />
local column = guiGridListAddColumn( playerList, "Player", 0.85 ) -- Create a 'players' column in the list<br />
if ( column ) then -- If the column was successfully created<br />
for id, playeritem in ipairs(getElementsByType("player")) do <br />
--Loop through all the players, adding them to the table<br />
local row = guiGridListAddRow ( playerList )<br />
guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false )<br />
end<br />
end<br />
end<br />
addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{GUI functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GuiGridListAddRow&diff=16595GuiGridListAddRow2008-04-21T01:54:33Z<p>50pence: /* Syntax */</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
Adds a row to a grid list.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
int guiGridListAddRow ( element gridList, string rowText, float width )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''gridList:''' The grid list you want to add a row to<br />
*'''rowText:''' The text that should be displayed in the row<br />
*'''width:''' Row's width (value between 0-1)<br />
<br />
===Returns===<br />
Returns the row id if it has been created, ''false'' otherwise.<br />
<br />
==Example== <br />
This example creates a player list on the right side of the screen and fills it with the names of the connected players.<br />
<syntaxhighlight lang="lua"><br />
function clientsideResourceStart ()<br />
local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) -- Create the grid list<br />
local column = guiGridListAddColumn( playerList, "Player", 0.85 ) -- Create a 'players' column in the list<br />
if ( column ) then -- If the column was successfully created<br />
for id, playeritem in ipairs(getElementsByType("player")) do <br />
--Loop through all the players, adding them to the table<br />
local row = guiGridListAddRow ( playerList )<br />
guiGridListSetItemText ( playerList, row, column, getPlayerName ( playeritem ), false, false )<br />
end<br />
end<br />
end<br />
addEventHandler ( "onClientResourceStart", getRootElement(), clientsideResourceStart )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{GUI functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=CJ_Clothes%5CTattoos:_Lower_Back_(12)&diff=16594CJ Clothes\Tattoos: Lower Back (12)2008-04-20T23:49:11Z<p>50pence: Index' 0 name and texture was missing</p>
<hr />
<div>{| border="1"<br />
| {{Clothes|index=0|type=12|model=12angels|texture=12ANGEL}}<br />
| {{Clothes|index=1|type=12|model=12mayabird|texture=12MAYBR}}<br />
| {{Clothes|index=2|type=12|model=12dagger|texture=12DAGER}}<br />
|-<br />
| {{Clothes|index=3|type=12|model=12bandit|texture=12BNDIT}}<br />
| {{Clothes|index=4|type=12|model=12cross7|texture=12CROSS}}<br />
| {{Clothes|index=5|type=12|model=12mayafce|texture=12MYFAC}}<br />
|}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=CJ_Clothes%5CTattoos:_Left_Chest_(9)&diff=16593CJ Clothes\Tattoos: Left Chest (9)2008-04-20T22:59:22Z<p>50pence: </p>
<hr />
<div>{| border="1"<br />
| {{Clothes|index=0|type=9|model=9crown|texture=9CROWN}}<br />
| {{Clothes|index=1|type=9|model=9gun|texture=9GUN}}<br />
| {{Clothes|index=2|type=9|model=9gun2|texture=9GUN2}}<br />
|-<br />
| {{Clothes|index=3|type=9|model=9homeboy|texture=9HOMBY}}<br />
| {{Clothes|index=4|type=9|model=9bullet|texture=9BULLT}}<br />
| {{Clothes|index=5|type=9|model=9rasta|texture=9RASTA}}<br />
|}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=CJ_Clothes%5CTattoos:_Right_Upper_Arm_(6)&diff=16592CJ Clothes\Tattoos: Right Upper Arm (6)2008-04-20T22:57:49Z<p>50pence: Index' 0 name and texture was missing</p>
<hr />
<div>{| border="1"<br />
| {{Clothes|index=0|type=6|model=6aztec|texture=6AZTEC}}<br />
| {{Clothes|index=1|type=6|model=6crown|texture=6CROWN}}<br />
| {{Clothes|index=2|type=6|model=6clown|texture=6CLOWN}}<br />
| {{Clothes|index=3|type=6|model=6africa|texture=6AFRICA}}<br />
|}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=CJ_Clothes%5CTattoos:_Left_Lower_Arm_(5)&diff=16591CJ Clothes\Tattoos: Left Lower Arm (5)2008-04-20T22:56:49Z<p>50pence: Index' 0 name and texture was missing</p>
<hr />
<div>{| border="1"<br />
| {{Clothes|index=0|type=5|model=5gun|texture=5GUN}}<br />
| {{Clothes|index=1|type=5|model=5cross|texture=5CROSS}}<br />
| {{Clothes|index=2|type=5|model=5cross2|texture=5CROSS2}}<br />
| {{Clothes|index=3|type=5|model=5cross3|texture=5CROSS3}}<br />
|}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=CJ_Clothes%5CTattoos:_Left_Upper_Arm_(4)&diff=16590CJ Clothes\Tattoos: Left Upper Arm (4)2008-04-20T22:55:09Z<p>50pence: </p>
<hr />
<div>{| border="1"<br />
| {{Clothes|index=0|type=4|model=4weed|texture=4WEED}}<br />
| {{Clothes|index=1|type=4|model=4rip|texture=4RIP}}<br />
| {{Clothes|index=2|type=4|model=4spider|texture=4SPIDER}}<br />
|}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=OutputChatBox&diff=16543OutputChatBox2008-04-06T14:59:54Z<p>50pence: </p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This outputs the specified text string to the chatbox. It can be specified as a message to certain player(s) or all players.<br />
<br />
It can optionally allow you to embed color changes into the string by setting the colorCoded boolean to true. This allows: <br />
<syntaxhighlight lang="lua"><br />
outputChatBox ( "#FF0000Hello #00FF00World", getRootElement(), 255, 255, 255, true )<br />
</syntaxhighlight><br />
This will display as: '''<span style='color:red;'>Hello</span> <span style='color:green'>World</span> '''<br />
<br />
==Syntax==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">bool outputChatBox ( string text, [ element visibleTo=getRootElement(), int r=255, int g=255, int b=255, bool colorCoded=false ] )</syntaxhighlight><br />
<br />
==Required Arguments==<br />
*'''text:''' The text string that you wish to send to the chat window.<br />
<br />
==Optional Arguments==<br />
{{OptionalArg}}<br />
*'''visibleTo:''' This specifies who the chat is visible to. Any players in this element will see the chat message. See [[visibility]].<br />
*'''r:''' The amount of red in the color of the text. Default value is 255.<br />
*'''g:''' The amount of green in the color of the text. Default value is 255.<br />
*'''b:''' The amount of blue in the color of the text. Default value is 255.<br />
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.<br />
Note: '''visibleTo''' can also be a Team object, in this case, the text will be visible to all the players of that team. Also the #RRGGBB format must contain capital letters a-f is not acceptable but A-F is.<br />
</section><br />
<section name="Client" class="client" show="false"><br />
<syntaxhighlight lang="lua">bool outputChatBox ( string text, [ int r=255, int g=255, int b=255, bool colorCoded=false ] )</syntaxhighlight><br />
<br />
==Required Arguments==<br />
*'''text:''' The text string that you wish to send to the chat window.<br />
<br />
==Optional Arguments==<br />
{{OptionalArg}}<br />
*'''r:''' The amount of red in the color of the text. Default value is 255.<br />
*'''g:''' The amount of green in the color of the text. Default value is 255.<br />
*'''b:''' The amount of blue in the color of the text. Default value is 255.<br />
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.<br />
Note: '''visibleTo''' can also be a Team object, in this case, the text will be visible to all the players of that team.<br />
</section><br />
<br />
==Returns==<br />
Returns ''true'' if the message was displayed successfully. Returns ''false'' if invalid arguments are specified.<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
'''Example 1:''' This example displays a chat message to all users.<br />
<syntaxhighlight lang="lua"><br />
x = 5<br />
y = 10 <br />
-- Displays the message<br />
outputChatBox ( "I have " .. x .. " apples and " .. y .. " oranges." )<br />
</syntaxhighlight><br />
<br />
'''Example 2:''' This example outputs a simple colour coded message, "Red White", where the 'White' is in white colour, and 'Red' is in a red colour.<br />
<syntaxhighlight lang="lua"><br />
outputChatBox ( "Red #FFFFFFWhite", getRootElement(), 255, 0, 0, true )<br />
</syntaxhighlight><br />
<br />
'''Example 3:''' This example allows for coloured chat, according to a player's nametag. This makes use of colour coded outputs.<br />
<syntaxhighlight lang="lua"><br />
function colouredChat ( message, theType )<br />
if theType == 0 then --if its normal chat (not /me or teamchat) then<br />
cancelEvent() --prevent MTA from outputting chat<br />
message = string.gsub(message, "#%x%x%x%x%x%x", "") --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub<br />
local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour<br />
local chatterName = getClientName ( source ) --get his name<br />
--output a message with the name as his nametag colour, and the rest in white.<br />
outputChatBox ( chatterName..":#FFFFFF "..message, getRootElement(), r, g, b, true )<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
'''Example 4:''' This example displays a chat message to a single user called ''someguy''.<br />
<syntaxhighlight lang="lua"><br />
-- Find the player element for the player called 'someguy'<br />
myPlayer = getPlayerFromNick ( "someguy" )<br />
-- If a player was found called 'someguy' then...<br />
if ( myPlayer ~= false ) then<br />
x = 5<br />
y = 10<br />
-- Display the message<br />
outputChatBox ( "I have " .. x .. " apples and " .. y .. " oranges.", myPlayer )<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Server functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=Coreconfig.xml&diff=16415Coreconfig.xml2008-03-30T12:46:37Z<p>50pence: New page: == Coreconfig.xml == This file is used to set your UI e.g. chat box color, chat font or even bind keys. You can modify it to make your chat box look better or add favourite servers manual...</p>
<hr />
<div>== Coreconfig.xml ==<br />
<br />
This file is used to set your UI e.g. chat box color, chat font or even bind keys. You can modify it to make your chat box look better or add favourite servers manually. Coreconfig.xml is located in your GTA San Andreas\MTA\ folder (by default C:\Program files\Rockstar Games\GTA San Andreas\MTA\).<br />
<br />
<br />
== Settings ==<br />
Most of the settings are self-explained.<br />
*'''nick''' - Your nickname in-game<br />
*'''host''' - Last played server's IP<br />
*'''port''' - Last played server's port<br />
*'''password''' - Last played server's password<br />
*'''console_pos''' - X, Y co-ords of the screen where console should be shown (after pressing ` (tilde) key)<br />
*'''chat_font''' - Font ID you want to be used in chat box<br />
*'''chat_lines''' - How many lines you want to be displayed in chat box<br />
*'''chat_color''' - Chat box background color (format is: RGBA, values between 0 - 255)<br />
*'''chat_input_color''' - Background of the line shown when you type text (displayed when you press T or Y)<br />
*'''chat_scale''' - Scale of the chat box, that is size of it (format is: width height, floating values between 0 - 1)<br />
*'''chat_input_prefix_color''' - Color of the word "Say:" or "Team Say:" when you press T or Y<br />
*'''chat_input_text_color''' - Color of the text you type, when you press T or Y<br />
*'''chat_width''' - Width of the chat box, text will wrap if it reaches this end<br />
*'''chat_css_style_text''' - (needs explanation)<br />
*'''chat_css_style_background''' - (needs explanation)<br />
*'''chat_line_life''' - (needs explanation)<br />
*'''chat_line_fade_out''' - Time after which line should fade out (milliseconds)<br />
*'''chat_use_cegui''' - Should chat use CEGUI? (values 0 or 1) (needs more explanation)<br />
*'''mtu_size''' - (needs explanation)<br />
*'''menu_options''' - (needs explanation)<br />
<br />
== Bind key ==<br />
Binding key format is easy and almost everyone can bind their own keys to make the game easier to play and speed up your gaming a little bit. You can bind a command you use the most often to a key, so when you press the key that command will execute.<br />
<br />
Example binding key "h" which will execute /help command:<br />
<syntaxhighlight lang="lua"><bind key="h" command="help" /></syntaxhighlight> it's that simple.<br />
You can also use arguments in commands e.g. some servers have banking systems so you can /deposit money using keys too, eg: <syntaxhighlight lang="lua"><bind key="[" command="deposit" arguments="1000" /></syntaxhighlight><br />
This will deposit your $1000.<br />
<br />
== See Also ==<br />
[[Key names]]<br><br />
[[Control names]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=SetCameraMatrix&diff=16222SetCameraMatrix2008-03-19T04:12:18Z<p>50pence: Undo revision 16219 by 50pence (Talk)</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 )<br />
</syntaxhighlight><br />
<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 />
*'''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 />
</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 )<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 />
*'''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 />
</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 Las Venturas 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 />
<br />
==See Also==<br />
{{Camera functions}}<br />
<br />
[[Category:Incomplete]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GetCameraRotation&diff=16221GetCameraRotation2008-03-19T04:11:34Z<p>50pence: Undo revision 16220 by 50pence (Talk)</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function returns the local camera rotation.<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
float, float, float getCameraRotation ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns three [[float]]s containing the X, Y and Z rotation values.<br />
<br />
==Example== <br />
This page lacks an example.<br />
<syntaxhighlight lang="lua"><br />
--add an example here<br />
</syntaxhighlight><br />
==See Also==<br />
{{Camera functions}}<br />
[[Category:Needs_Example]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GetCameraRotation&diff=16220GetCameraRotation2008-03-19T04:10:22Z<p>50pence: /* See Also */</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function returns the local camera rotation.<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
float, float, float getCameraRotation ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns three [[float]]s containing the X, Y and Z rotation values.<br />
<br />
==Example== <br />
This page lacks an example.<br />
<syntaxhighlight lang="lua"><br />
--add an example here<br />
</syntaxhighlight><br />
==See Also==<br />
{{Client_camera_functions}}<br />
[[Category:Needs_Example]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=SetCameraMatrix&diff=16219SetCameraMatrix2008-03-19T04:09:43Z<p>50pence: /* See Also */</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 )<br />
</syntaxhighlight><br />
<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 />
*'''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 />
</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 )<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 />
*'''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 />
</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 Las Venturas 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 />
<br />
==See Also==<br />
{{Client_camera_functions}}<br />
<br />
[[Category:Incomplete]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=FileOpen&diff=16145FileOpen2008-03-08T17:39:42Z<p>50pence: /* Syntax */</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
<br />
Opens an existing file for reading and writing.<br />
<br />
'''Note:''' The file functions should not be used to implement configuration files. It is encouraged to use the XML functions for this instead.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
file fileOpen ( string filename [, bool readonly = false, resource root = getThisResource ()] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''filename''': The name of the file you wish to open.<br />
<br />
===Optional Arguments===<br />
*'''readonly:''' By default, the file is opened with reading and writing access. You can specify ''true'' for this parameter if you only need reading access.<br />
*'''root:''' The resource in whose directory the file is located. Defaults to the resource calling the function.<br />
<br />
===Returns===<br />
If successful, returns a file handle for the file. Otherwise returns ''false'' (f.e. if the file doesn't exist).<br />
<br />
==Example==<br />
This example opens the file test.txt and outputs its contents to the console.<br />
<syntaxhighlight lang="lua"><br />
local hFile = fileOpen("test.txt", true) -- attempt to open the file (read only)<br />
if hFile then -- check if it was successfully opened<br />
local buffer<br />
while not fileIsEOF(hFile) do -- as long as we're not at the end of the file...<br />
buffer = fileRead(hFile, 500) -- ... read the next 500 bytes...<br />
outputConsole(buffer) -- ... and output them to the console<br />
end<br />
fileClose(hFile) -- close the file once we're done with it<br />
else<br />
outputConsole("Unable to open test.txt")<br />
end<br />
</syntaxhighlight><br />
<br />
Notice that you can't simply do ''buffer = fileRead("test.txt", 500)''. Instead, file functions operate on a '''file handle''', which is a special object representing an open file. fileOpen gives us such a handle.<br />
<br />
It is also important to remember to close a file after you've finished all your operations on it, especially if you've been writing to the file. If you don't close a file and your resource crashes, all changes to the file may be lost.<br />
<br />
==See Also==<br />
{{File functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GetElementColShape&diff=16144GetElementColShape2008-03-08T16:30:47Z<p>50pence: New page: {{Server function}} __NOTOC__ This function is used to get element's colshape. ==Syntax== <syntaxhighlight lang="lua"> colshape getElementColShape ( element theElement ) </syntaxhighlight> ===Require...</p>
<hr />
<div>{{Server function}}<br />
__NOTOC__ <br />
This function is used to get element's colshape.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
colshape getElementColShape ( element theElement ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theElement:''' The element you want to get the colshape of<br />
<br />
===Returns===<br />
Returns ''colshape'' of the element, ''false'' if not or an invalid argument was passed to the function.<br />
<br />
==Example== <br />
<syntaxhighlight lang="lua"><br />
<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Element_functions}}<br />
[[Category:Needs_Example]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GetPlayerAccount&diff=16019GetPlayerAccount2008-03-02T18:15:40Z<p>50pence: /* Syntax */</p>
<hr />
<div>__NOTOC__ <br />
{{Server function}}<br />
Returns the accountname of the player<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua">string getPlayerAccount ( player thePlayer )</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player you wish the retrieve the name of the account from.<br />
<br />
===Returns===<br />
Returns an string with name of the account.<br />
-- TODO -- What does it return if it isnt known?<br />
<br />
==Example==<br />
When a player types '/account' this example retrieves the player's accountname, and prints it to his screen.<br />
<syntaxhighlight lang="lua"><br />
function viewAccount(thePlayer, command)<br />
-- get the name of the account from thePlayer<br />
local accountName = getPlayerAccount(thePlayer) <br />
<br />
-- output the message to the player<br />
outputChatBox("Your account name is " .. accountName, thePlayer) <br />
end<br />
<br />
-- add the console command<br />
addCommandHandler("account", viewAccount) <br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Player functions}}<br />
[[Category:Incomplete]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GetMarkerColor&diff=15963GetMarkerColor2008-02-23T23:45:49Z<p>50pence: /* Example -> there is no setPlayerHealth function, use setElementHealth */</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function returns the color and transparency for a marker element. Not all marker types support transparency.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
int, int, int, int getMarkerColor ( marker theMarker )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''theMarker''': The [[marker]] that you wish to retrieve the color of.<br />
<br />
===Returns===<br />
Returns four [[int]]s corresponding to the amount of ''red'', ''green'', ''blue'' and ''alpha'' (respectively) of the marker, ''false'' if invalid arguments were passed.<br />
<br />
==Example==<br />
<section name="Serverside example" class="server" show="true"><br />
This example script fully heals players who hit a white marker, and kills players who hit a red one.<br />
<syntaxhighlight lang="lua"><br />
-- we define the function that will determine if the player is to be healed or killed<br />
function healOrKill ( hitMarker, matchingDimension )<br />
-- if the marker was in a different dimension, stop here to ignore the event<br />
if not matchingDimension then<br />
return<br />
end<br />
-- get the marker's color<br />
local R, G, B, A = getMarkerColor( hitMarker )<br />
-- if its RGB color is 255,255,255 (white),<br />
if R == 255 and G == 255 and B == 255 then<br />
-- heal the player<br />
setElementHealth( source, 100 )<br />
-- if it isn't white, but 255,0,0 (red),<br />
elseif R == 255 and G == 0 and B == 0 then<br />
-- kill the player<br />
killPlayer( source )<br />
end<br />
end<br />
-- add our function as a handler to "onPlayerMarkerHit"<br />
addEventHandler( "onPlayerMarkerHit", getRootElement(), healOrKill )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Marker functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=AddVehicleUpgrade&diff=15952AddVehicleUpgrade2008-02-22T22:54:37Z<p>50pence: /* Required Arguments */</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function adds an upgrade to an existing vehicle, eg: nos, hyrdraulics. These upgrades are listed in San Andreas\data\maps\veh_mods\veh_mods.ide.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool addVehicleUpgrade ( vehicle theVehicle, int upgrade )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''theVehicle''': The [[element]] representing the [[vehicle]] you wish to add the upgrade to.<br />
*'''upgrade''': The id of the upgrade you wish to add. (1000 to 1193), ''see [[Vehicle Upgrades]]''<br />
<br />
==Returns==<br />
Returns ''true'' if the upgrade was successfully added to the vehicle, otherwise ''false''.<br />
<br />
==Example==<br />
<section name="Example 1" class="server" show="true"><br />
This serverside function allows the user to get an upgrade by typing a command:<br />
<syntaxhighlight lang="lua"><br />
-- define the handler function for our command<br />
function consoleAddUpgrade ( thePlayer, commandName, id )<br />
-- make sure the player is in a vehicle<br />
if ( isPlayerInVehicle ( thePlayer ) ) then<br />
-- convert the given ID from a string to a number<br />
local id = tonumber ( id )<br />
-- get the player's vehicle<br />
local theVehicle = getPlayerOccupiedVehicle ( thePlayer )<br />
-- add the requested upgrade to the vehicle<br />
local success = addVehicleUpgrade ( theVehicle, id )<br />
-- inform the player of whether the upgrade was added successfully<br />
if ( success ) then<br />
outputConsole ( getVehicleUpgradeSlotName ( id ) .. " upgrade added.", thePlayer )<br />
else<br />
outputConsole ( "Failed to add upgrade.", thePlayer )<br />
end<br />
else<br />
outputConsole ( "You must be in a vehicle!", thePlayer )<br />
end<br />
end<br />
-- add the function as a handler for the "addupgrade" command<br />
addCommandHandler ( "addupgrade", consoleAddUpgrade )<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Example 2" class="client" show="true"><br />
This client-side script gives vehicles a nitro upgrade whenever they pass through a certain collision shape:<br />
<syntaxhighlight lang="lua"><br />
-- create a collision shape<br />
local nitroColShape = createColSphere ( 1337, 100, 12, 2 )<br />
<br />
-- attach the collision shape to an 'onClientColShapeHit' event<br />
function onNitroColShapeHit ( hitElement, matchingDimension )<br />
if ( getElementType ( hitElement ) == "vehicle" ) then<br />
-- add a nitro upgrade if the element that hit the colshape is a vehicle<br />
addVehicleUpgrade ( hitElement, 1010 )<br />
end<br />
end<br />
addEventHandler ( "onClientColShapeHit", nitroColShape, onNitroColShapeHit )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Vehicle functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=Resource:Realdriveby&diff=15919Resource:Realdriveby2008-02-21T21:58:46Z<p>50pence: /* GTA Driveby Compatible weapons -> "fixed" table's look */</p>
<hr />
<div>{{Resource page}}<br />
== Introduction ==<br />
RealDriveby is a fully customisable resource which allows a flexible driveby system for your server.<br />
<br />
All of GTA's driveby compatible weapons, including the shotguns,pistols,M4 and AK-47 are supported by this resource. Shot delays for weapons such as pistols are fixed to their normal rate.<br />
<br />
Users can switch weapons by default using the &quot;Vehicle Look Left&quot; and &quot;Vehicle Look Right&quot; keys while in driveby mode.<br />
<br />
However, it is completely up to the admin how he or she wants drivebys to be: Using MTA's settings system, shot delays for weapons can be modified; the weapons which a driver can driveby with are customisable; the weapons a passenger can driveby with are customisable.<br />
<br />
There are also options available to disable steering whilst in driveby mode, or disable drivebys altogether for certain vehicles.<br />
<br />
On top of this, RealDriveby provides clientside scripting functions so that users can modify these attributes on a player-basis, allowing different players the ability to driveby different weapons and different delays.<br />
<br />
== Settings ==<br />
All settings can be modified using MTA's set() functions, modifying the meta.xml of the resource, or modifying the settings.xml.<br />
<br />
===Driver weapons===<br />
* '''Setting name:''' ''driveby_driver''<br />
* '''Description:''' Sets the weapons that a driver can driveby with. To disable driver drivebys, just pass an empty table. See [[Resource:Realdriveby#GTA_Driveby_Compatible_weapons|here]] for compatible weapons.<br />
* '''XML Example:''' <syntaxhighlight lang="xml"><setting name="driveby_driver" value="[[ 22,23,24,26,28,29,32 ]]"/></syntaxhighlight><br />
<br />
===Passenger weapons===<br />
* '''Setting name:''' ''driveby_passenger''<br />
* '''Description:''' Sets the weapons that a passenger can driveby with. To disable passenger drivebys, just pass an empty table. See [[Resource:Realdriveby#GTA_Driveby_Compatible_weapons|here]] for compatible weapons.<br />
* '''XML Example:''' <syntaxhighlight lang="xml"><setting name="driveby_passenger" value="[[ 22,23,24,25,26,28,29,32,30,31,33 ]]"/></syntaxhighlight><br />
<br />
===Shot delay===<br />
* '''Setting name:''' ''driveby_shot_delay''<br />
* '''Description:''' Sets the delay between each individual shot for the specified weapons. Unspecified weapons have GTA's default driveby fire rate. The setting is in the format of a table where the key is a '''string''' of the weapon ID, and the value is the delay in milliseconds.<br />
* '''XML Example:''' <syntaxhighlight lang="xml"><setting name="driveby_shot_delay" value="[{ '22':300,'23':300,'24':800,'26':700 }]"/></syntaxhighlight><br />
<br />
===Blocked vehicles===<br />
* '''Setting name:''' ''driveby_blocked_vehicles''<br />
* '''Description:''' Sets the vehicles which driveby mode cannot be accessed in. Useful to block strange effects such as drivebys in tanks. In the format of an array of vehicle IDs.<br />
* '''XML Example:''' <syntaxhighlight lang="xml"><setting name="driveby_blocked_vehicles" value="[[ 432,601,437,431,592,553,577,488,497,548,563,512,476,447,425,519,520,460,417,469,487,513,441,464,501,465,564,538,449,537,539,570472,473,493,595,484,430,453,452,446,454,606,591,607,611,610,590,569,611,435,608,584,450 ]]"/></syntaxhighlight><br />
<br />
===Steer Cars while in driveby mode===<br />
* '''Setting name:''' ''driveby_steer_cars''<br />
* '''Description:''' Sets whether drivers can steer left or right while in driveby mode for vehicles besides bikes. The setting is in the format of a bool, where ''true'' allows steering.<br />
* '''XML Example:''' <syntaxhighlight lang="xml"><setting name="driveby_steer_cars" value="[true]"/></syntaxhighlight> <br />
<br />
===Steer Bikes while in driveby mode===<br />
* '''Setting name:''' ''driveby_steer_bikes''<br />
* '''Description:''' Sets whether drivers can steer left or right while in driveby mode for bikes/bicycles. If set to false, it allows extra realism. The setting is in the format of a bool, where ''true'' allows steering.<br />
* '''XML Example:''' <syntaxhighlight lang="xml"><setting name="driveby_steer_bikes" value="[true]"/></syntaxhighlight> <br />
<br />
===Toggle driveby mode key===<br />
* '''Setting name:''' ''driveby_toggle_mode''<br />
* '''Description:''' Sets the [[Key names|key]] which will be used to toggle driveby mode.<br />
* '''XML Example:''' <syntaxhighlight lang="xml"><setting name="driveby_toggle_mode" value="mouse2"/></syntaxhighlight> <br />
<br />
===Next driveby weapon key===<br />
* '''Setting name:''' ''driveby_next_weapon''<br />
* '''Description:''' Sets the [[Key names|key]] which will be used to change to the next driveby weapon (if there is one).<br />
* '''XML Example:''' <syntaxhighlight lang="xml"><setting name="driveby_next_weapon" value="vehicle_look_right"/></syntaxhighlight> <br />
<br />
===Previous driveby weapon key===<br />
* '''Setting name:''' ''driveby_prev_weapon''<br />
* '''Description:''' Sets the [[Key names|key]] which will be used to change to the previous driveby weapon (if there is one).<br />
* '''XML Example:''' <syntaxhighlight lang="xml"><setting name="driveby_prev_weapon" value="vehicle_look_left"/></syntaxhighlight> <br />
<br />
==Scripting functions==<br />
All scripting functions are '''clientside''' and therefore only affect the '''local player'''. All functions must be called using the [[call]] function, e.g.<br />
<syntaxhighlight lang="lua">call(getResourceFromName"realdriveby","setWeaponShotDelay",22,300)</syntaxhighlight><br />
<br />
===setDriverDrivebyAbility===<br />
This function allows you to set what weapons the local player can use while a driver of a vehicle.<br />
<syntaxhighlight lang="lua"><br />
bool setDriverDrivebyAbility ( table weapons )<br />
</syntaxhighlight><br />
* '''weapons:''' An an array/table containing weapon IDs that the driver may use. See [[Resource:Realdriveby#GTA_Driveby_Compatible_weapons|here]] for compatible weapons.<br />
<br />
<br />
===getDriverDrivebyAbility===<br />
This function allows you to retrive what weapons the local player can use while a driver of a vehicle.<br />
<syntaxhighlight lang="lua"><br />
table getDriverDrivebyAbility ()<br />
</syntaxhighlight><br />
Returns a table of the weapons that can be used as a driver.<br />
<br />
===setPassengerDrivebyAbility===<br />
This function allows you to set what weapons the local player can use while a passenger of a vehicle.<br />
<syntaxhighlight lang="lua"><br />
bool setPassengerDrivebyAbility ( table weapons )<br />
</syntaxhighlight><br />
* '''weapons:''' An an array/table containing weapon IDs that the passenger may use. See [[Resource:Realdriveby#GTA_Driveby_Compatible_weapons|here]] for compatible weapons.<br />
<br />
<br />
===getPassengerDrivebyAbility===<br />
This function allows you to retrive what weapons the local player can use while a passenger of a vehicle.<br />
<syntaxhighlight lang="lua"><br />
table getPassengerDrivebyAbility ()<br />
</syntaxhighlight><br />
Returns a table of the weapons that can be used as a passenger.<br />
<br />
<br />
===setWeaponShotDelay===<br />
This function allows setting of a certain weapon's shot delay for the local player<br />
<syntaxhighlight lang="lua"><br />
bool setWeaponShotDelay(int weaponID, int delay)<br />
</syntaxhighlight><br />
* '''weaponID:''' An integer representing the [[Weapons|weapon ID]] of the delay that you wish to set.<br />
* '''delay:''' An integer representing the delay in between each shot, in '''milliseconds'''.<br />
<br />
<br />
===getWeaponShotDelay===<br />
This function allows retrieving of a certain weapon's shot delay for the local player<br />
<syntaxhighlight lang="lua"><br />
int getWeaponShotDelay(int weaponID)<br />
</syntaxhighlight><br />
* '''weaponID:''' An integer representing the [[Weapons|weapon ID]] of the delay that you wish to retrieve.<br />
Returns an integer representing the weapon delay in between each shot.<br />
<br />
<br />
===setDrivebySteeringAbility===<br />
This function allows setting of whether the local player can steer while in driveby mode.<br />
<syntaxhighlight lang="lua"><br />
bool setDrivebySteeringAbility( bool otherVehicles, bool bikes )<br />
</syntaxhighlight><br />
* '''otherVehicles:''' A bool representing whether steering is enabled while in any vehicle besides a bike/bicycle, where ''true'' represents enabled steering and ''false'' represents disabled steering.<br />
* '''bikes :''' A bool representing whether steering is enabled while in a bike/bicycle, where ''true'' represents enabled steering and ''false'' represents disabled steering.<br />
<br />
<br />
===getDrivebySteeringAbility===<br />
This function allows retrieving of whether the local player can steer while in driveby mode.<br />
<syntaxhighlight lang="lua"><br />
bool getDrivebySteeringAbility( string drivebyType )<br />
</syntaxhighlight><br />
* '''drivebyType :''' A string which can either be "'''bike'''", representing bikes/bicycles, or "'''car'''" representing all other vehicles.<br />
Returns a bool of the ability of the specified type of driveby, where ''true'' is enabled and ''false'' is disabled.<br />
<br />
==GTA Driveby Compatible weapons==<br />
These are weapons that are compatible with GTA/MTA's driveby mode, and can be used by this script.<br />
<br />
<table border="1" class="unnamed1"><br />
<tr><th>Name</th><th>ID</th><td></td><th>Name</th><th>ID</th></tr><br />
<tr><td>Pistol</td><td>22</td> <td> </td><td>Desert Eagle</td><td>24</td></tr><br />
<tr><td>Silenced Pistol</td><td>23</td> <br />
<tr><td>Chrome Shotgun</td><td>25</td><td> </td><td>Sawn-Off Shotgun</td><td>26</td></tr><br />
<tr><td>Combat Shotgun</td><td>27</td><td> </td><td>Uzi</td><td>28</td></tr><br />
<tr><td>MP5</td><td>29</td><td> </td><td>Tec-9</td><td>32</td></tr><br />
<tr><td>AK-47</td><td>30</td><td> </td><td>M4</td><td>31</td></tr><br />
<tr><td>Country Rifle</td><td>33</td><td> </td><td>Minigun</td><td>38</td></tr></table></div>50pencehttps://wiki.multitheftauto.com/index.php?title=OnPlayerJoin&diff=15863OnPlayerJoin2008-02-20T19:16:07Z<p>50pence: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Server event}}<br />
This event is triggered when a player joins the server.<br />
<br />
==Parameters==<br />
No parameters.<br />
<br />
==Source==<br />
The source of this event is the [[player]] who joined.<br />
<br />
==Example==<br />
This example gets the joined client's name and sends him a welcome message including his name.<br />
<br />
<syntaxhighlight lang="lua"><br />
-- we register greetPlayer as a handler for the event<br />
function greetPlayer ( )<br />
-- we store the player's name<br />
local joinedPlayerName = getClientName ( source )<br />
local serverName = getServerName( )<br />
-- and send him a greeting<br />
outputChatBox ( "Welcome " .. joinedPlayerName .. " to ".. serverName .."!" , source, 255, 255, 255 )<br />
end<br />
addEventHandler ( "onPlayerJoin", getRootElement(), greetPlayer )<br />
</syntaxhighlight><br />
<br />
{{See also/Server event|Player events}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GetVehicleRotation&diff=15746GetVehicleRotation2008-02-10T04:13:51Z<p>50pence: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
==Description==<br />
This function gets the rotation of a vehicle along the X, Y, and Z axes in degrees.<br />
<br />
''Note: rotation Z returns value in CCW (counter-clock wise). So 3 o'clock is not 90 degrees, it's actually 270 degrees and 9 o'clock is not 270 degrees, it's 90 degrees. '''To fix this use: (180-rotZ)+180'''''<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">float float float getVehicleRotation ( vehicle theVehicle )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''theVehicle''': The [[vehicle]] whose rotation you want to retrieve.<br />
<br />
===Returns===<br />
Returns three ''floats'' indicating the X, Y, and Z rotations of the vehicle in degrees, or ''false'' if the specified vehicle does not exist.<br />
<br />
==Example==<br />
This example creates a vehicle and gets its rotation:<br />
<syntaxhighlight lang="lua">local newHydra = createVehicle ( 520, 1024, 1024, 1024 ) -- create a Hydra<br />
local rx, ry, rz = getVehicleRotation ( newHydra ) -- get the vehicle's x, y and z rotations and store them in rx, ry, and rz<br />
outputChatBox ( "Current rotation: " .. rx .. " " .. ry .. " " .. rz ) -- output the rotations<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Vehicle functions}}</div>50pencehttps://wiki.multitheftauto.com/index.php?title=File:Blipid2.png&diff=15490File:Blipid2.png2008-01-27T02:42:37Z<p>50pence: </p>
<hr />
<div></div>50pencehttps://wiki.multitheftauto.com/index.php?title=File:Blipid48.png&diff=15488File:Blipid48.png2008-01-27T02:40:47Z<p>50pence: </p>
<hr />
<div></div>50pencehttps://wiki.multitheftauto.com/index.php?title=File:Blipid4.png&diff=15486File:Blipid4.png2008-01-27T02:39:24Z<p>50pence: </p>
<hr />
<div></div>50pencehttps://wiki.multitheftauto.com/index.php?title=File:Blipid3.png&diff=15484File:Blipid3.png2008-01-27T02:37:57Z<p>50pence: </p>
<hr />
<div></div>50pencehttps://wiki.multitheftauto.com/index.php?title=File:Blipid41.png&diff=15482File:Blipid41.png2008-01-27T02:36:14Z<p>50pence: </p>
<hr />
<div></div>50pencehttps://wiki.multitheftauto.com/index.php?title=OnClientPlayerQuit&diff=15465OnClientPlayerQuit2008-01-26T22:39:09Z<p>50pence: </p>
<hr />
<div>__NOTOC__<br />
{{Client event}}<br />
This event is triggered when a remote player quits the game<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
string reason<br />
</syntaxhighlight> <br />
<br />
*'''reason''': A string representing the reason why the player quit.<br />
<br />
Quit reason string can be:<br />
- "Unknown"<br />
- "Quit"<br />
- "Kicked"<br />
- "Banned"<br />
- "Bad Connection"<br />
- "Timed out"<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] that quit the game.<br />
<br />
==Example== <br />
This example prints a message in server window when player leaves the server.<br />
<syntaxhighlight lang="lua"><br />
function onQuitGame( reason )<br />
print( getPlayerName( getLocalPlayer() ).." has left the server ("..reason..")" )<br />
end<br />
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===Client player events===<br />
{{Client_player_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}<br />
<br />
[[Category:Incomplete]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=OnClientPlayerQuit&diff=15464OnClientPlayerQuit2008-01-26T22:38:26Z<p>50pence: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Client event}}<br />
This event is triggered when a remote player quits the game<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
string reason<br />
</syntaxhighlight> <br />
<br />
*'''reason''': A string representing the reason why the player quit.<br />
<br />
Quit reason string can be:<br />
- "Unknown"<br />
- "Quit"<br />
- "Kicked"<br />
- "Banned"<br />
- "Bad Connection"<br />
- "Timed out"<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] that quit the game.<br />
<br />
==Example== <br />
This example prints a message in server window when player leaves the server.<br />
<syntaxhighlight lang="lua"><br />
function onQuitGame( reason )<br />
print( getPlayerName( getLocalPlayer() ).." has left the server ("..reason..")" )<br />
end<br />
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===Client player events===<br />
{{Client_player_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}<br />
<br />
[[Category:Incomplete]]<br />
[[Category:Needs Example]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=OnClientPlayerQuit&diff=15463OnClientPlayerQuit2008-01-26T22:36:45Z<p>50pence: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Client event}}<br />
This event is triggered when a remote player quits the game<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
string reason<br />
</syntaxhighlight> <br />
<br />
*'''reason''': A string representing the reason why the player quit.<br />
<br />
Quit reason string can be:<br />
- "Unknown"<br />
- "Quit"<br />
- "Kicked"<br />
- "Banned"<br />
- "Bad Connection"<br />
- "Timed out"<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] that quit the game.<br />
<br />
==Example== <br />
This page lacks an example<br />
<syntaxhighlight lang="lua"><br />
function onQuitGame( reason )<br />
print( getPlayerName( getLocalPlayer() ).." has left the server ("..reason..")" )<br />
end<br />
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===Client player events===<br />
{{Client_player_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}<br />
<br />
[[Category:Incomplete]]<br />
[[Category:Needs Example]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GuiCreateStaticImage&diff=14938GuiCreateStaticImage2008-01-13T20:05:29Z<p>50pence: /* Returns */</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function creates a static image.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
element guiCreateStaticImage ( float x, float y, float width, float height, string filename, bool relative, parent element, [resource sourceResource = getThisResource()] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''argumentName:''' description<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''sourceResource:''' The resource to load the image from. Defaults to the resource that the script is running from.<br />
<br />
===Returns===<br />
Returns [[element]] if image was created successfully, ''false'' otherwise.<br />
<br />
==Example==<br />
This example will display an image (imagename.png) on the client's (player's) screen.<br />
<section name="Client-side script (example.lua)" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
[lua]<br />
function showClientImage()<br />
guiCreateStaticImage( 20, 200, 100, 100, "imagename.png", false )<br />
end<br />
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), showClientImage )<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="meta.xml" class="server" show="true"><br />
In this example meta.xml is used to tell the server which files it will be using.<br />
<syntaxhighlight lang="lua"><br />
<info author="Yourname" version="1.0" /><br />
<script src="example.lua" type="client" /><br />
<file src="imagename.png" /><br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{GUI_functions}}<br />
[[Category:Incomplete]]</div>50pencehttps://wiki.multitheftauto.com/index.php?title=GuiCreateStaticImage&diff=14889GuiCreateStaticImage2008-01-13T17:12:09Z<p>50pence: /* Example */</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function creates a static image.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
element guiCreateStaticImage ( float x, float y, float width, float height, string filename, bool relative, parent element, [resource sourceResource = getThisResource()] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''argumentName:''' description<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
*'''sourceResource:''' The resource to load the image from. Defaults to the resource that the script is running from.<br />
<br />
===Returns===<br />
Returns ''true'' if blah, ''false'' otherwise.<br />
<br />
==Example==<br />
This example will display an image (imagename.png) on the client's (player's) screen.<br />
<section name="Client-side script (example.lua)" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
[lua]<br />
function showClientImage()<br />
guiCreateStaticImage( 20, 200, 100, 100, "imagename.png", false )<br />
end<br />
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), showClientImage )<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="meta.xml" class="server" show="true"><br />
In this example meta.xml is used to tell the server which files it will be using.<br />
<syntaxhighlight lang="lua"><br />
<info author="Yourname" version="1.0" /><br />
<script src="example.lua" type="client" /><br />
<file src="imagename.png" /><br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{GUI_functions}}<br />
[[Category:Incomplete]]</div>50pence