https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=Castillo&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-28T21:44:30ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=CreatePickup&diff=43953CreatePickup2015-01-09T00:55:41Z<p>Castillo: /* Example */</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function creates a pickup element, which is placed in the GTA world and can be picked up to retrieve a health, armour or a weapon. <br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
pickup createPickup ( float x, float y, float z, int theType, int amount/weapon/model, [ int respawnTime = 30000, int ammo = 50 ] ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
* '''x''': A floating point number representing the X coordinate on the map.<br />
* '''y''': A floating point number representing the Y coordinate on the map.<br />
* '''z''': A floating point number representing the Z coordinate on the map.<br />
* '''theType''': This is an integer representing the type of pickup, representing the following types:<br />
** '''0''': Health Pickup<br />
** '''1''': Armour Pickup<br />
** '''2''': Weapon Pickup<br />
** '''3''': Custom Pickup<br />
<br />
* '''amount''': This is an integer representing the amount of Health points or Armour points a pickup has.<br />
'''OR'''<br />
* '''weapon''': If the type is a Weapon pickup, then it represents the [[Weapon|weapon ID]] of the weapon pickup. When used with the weapon pickup type set, the ammo parameter can be used.<br />
'''OR'''<br />
* '''model''': If the pickup is a custom model, this is the model id to use. Many non-pickup models can be used, though some may cause crashes. The following is a list of models designed to be used as pickups.<br />
** '''1212:''' Money (Wad of Cash)<br />
** '''1240:''' Health (heart)<br />
** '''1242:''' Armour<br />
** '''1239:''' Info icon<br />
** '''1272:''' House (blue)<br />
** '''1273:''' House (green)<br />
** '''1274:''' Money (dollar symbol)<br />
** '''1241:''' Adrenaline<br />
** '''1247:''' Bribe<br />
** '''1248:''' GTA III sign<br />
** '''1252:''' Bomb from GTA III<br />
** '''1253:''' Photo op<br />
** '''1254:''' Skull<br />
** '''1274:''' Money icon<br />
** '''1275:''' Blue t-shirt<br />
** '''1277:''' Save disk<br />
** '''1313:''' 2 Skulls<br />
** '''1276:''' Tiki statue<br />
** '''1310:''' Parachute (with leg straps)<br />
** '''1318:''' Down arrow<br />
** '''1279:''' Drug bundle<br />
'''OR'''<br />
Other ID Object<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
* '''respawnTime''': How long before the pickup respawns in milliseconds ('''This parameter is ignored on the client!''')<br />
* '''ammo''': An integer representing the amount of ammo a pickup contains. This is only valid when the pickup type is a weapon pickup.<br />
<br />
===Returns===<br />
Returns [[pickup]] [[element]] if the pickup was created succesfully, otherwise returns ''false''.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example creates a pickup after a player dies so that he drops his weapon.<br />
<syntaxhighlight lang="lua"><br />
function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies<br />
x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z<br />
currentweapon = getPlayerWeapon ( source ) --get the current weapon of the dead person<br />
createPickup ( x, y, z, 2, currentweapon, 10000, totalammo )<br />
end<br />
addEventHandler ( "onPlayerWasted", getRootElement(), createDeathPickup ) --add an event handler for onPlayerWasted<br />
</syntaxhighlight><br />
</section><br />
<section name="Server" class="server" show="false"><br />
This example creates a custom pickup(money) after a player dies and sets it's value.<br />
<syntaxhighlight lang="lua"><br />
function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies<br />
x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z<br />
local money=createPickup ( x, y, z, 3, 1212, 10000)<br />
local playermoney = getPlayerMoney(source) --get the amount of money the dead person has<br />
setElementData(money,"Amount",playermoney) --now let's set the value of the pickup<br />
takePlayerMoney(source,playermoney) --Let's take away all their money<br />
end<br />
addEventHandler ( "onPlayerWasted", getRootElement(), createDeathPickup ) --add an event handler for onPlayerWasted<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
<br />
{{Pickup functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=CreatePickup&diff=43952CreatePickup2015-01-09T00:55:11Z<p>Castillo: Fixed incorrect pickup type used for the example</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function creates a pickup element, which is placed in the GTA world and can be picked up to retrieve a health, armour or a weapon. <br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
pickup createPickup ( float x, float y, float z, int theType, int amount/weapon/model, [ int respawnTime = 30000, int ammo = 50 ] ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
* '''x''': A floating point number representing the X coordinate on the map.<br />
* '''y''': A floating point number representing the Y coordinate on the map.<br />
* '''z''': A floating point number representing the Z coordinate on the map.<br />
* '''theType''': This is an integer representing the type of pickup, representing the following types:<br />
** '''0''': Health Pickup<br />
** '''1''': Armour Pickup<br />
** '''2''': Weapon Pickup<br />
** '''3''': Custom Pickup<br />
<br />
* '''amount''': This is an integer representing the amount of Health points or Armour points a pickup has.<br />
'''OR'''<br />
* '''weapon''': If the type is a Weapon pickup, then it represents the [[Weapon|weapon ID]] of the weapon pickup. When used with the weapon pickup type set, the ammo parameter can be used.<br />
'''OR'''<br />
* '''model''': If the pickup is a custom model, this is the model id to use. Many non-pickup models can be used, though some may cause crashes. The following is a list of models designed to be used as pickups.<br />
** '''1212:''' Money (Wad of Cash)<br />
** '''1240:''' Health (heart)<br />
** '''1242:''' Armour<br />
** '''1239:''' Info icon<br />
** '''1272:''' House (blue)<br />
** '''1273:''' House (green)<br />
** '''1274:''' Money (dollar symbol)<br />
** '''1241:''' Adrenaline<br />
** '''1247:''' Bribe<br />
** '''1248:''' GTA III sign<br />
** '''1252:''' Bomb from GTA III<br />
** '''1253:''' Photo op<br />
** '''1254:''' Skull<br />
** '''1274:''' Money icon<br />
** '''1275:''' Blue t-shirt<br />
** '''1277:''' Save disk<br />
** '''1313:''' 2 Skulls<br />
** '''1276:''' Tiki statue<br />
** '''1310:''' Parachute (with leg straps)<br />
** '''1318:''' Down arrow<br />
** '''1279:''' Drug bundle<br />
'''OR'''<br />
Other ID Object<br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
* '''respawnTime''': How long before the pickup respawns in milliseconds ('''This parameter is ignored on the client!''')<br />
* '''ammo''': An integer representing the amount of ammo a pickup contains. This is only valid when the pickup type is a weapon pickup.<br />
<br />
===Returns===<br />
Returns [[pickup]] [[element]] if the pickup was created succesfully, otherwise returns ''false''.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example creates a pickup after a player dies so that he drops his weapon.<br />
<syntaxhighlight lang="lua"><br />
function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies<br />
x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z<br />
currentweapon = getPlayerWeapon ( source ) --get the current weapon of the dead person<br />
createPickup ( x, y, z, 3, currentweapon, 10000, totalammo )<br />
end<br />
addEventHandler ( "onPlayerWasted", getRootElement(), createDeathPickup ) --add an event handler for onPlayerWasted<br />
</syntaxhighlight><br />
</section><br />
<section name="Server" class="server" show="false"><br />
This example creates a custom pickup(money) after a player dies and sets it's value.<br />
<syntaxhighlight lang="lua"><br />
function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies<br />
x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z<br />
local money=createPickup ( x, y, z, 2, 1212, 10000)<br />
local playermoney = getPlayerMoney(source) --get the amount of money the dead person has<br />
setElementData(money,"Amount",playermoney) --now let's set the value of the pickup<br />
takePlayerMoney(source,playermoney) --Let's take away all their money<br />
end<br />
addEventHandler ( "onPlayerWasted", getRootElement(), createDeathPickup ) --add an event handler for onPlayerWasted<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
<br />
{{Pickup functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=IsMouseInPosition&diff=43871IsMouseInPosition2015-01-03T20:28:17Z<p>Castillo: /* Return */</p>
<hr />
<div>{{Useful Function}}<br />
{{Needs Example}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function allows you to check whether the mouse cursor/pointer is within a rectangular position<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool isMouseInPosition ( int x, int y, int width, int height )</syntaxhighlight><br />
<br />
<br />
===Required arguments===<br />
* '''x''': Left-most X position for detection (absolute)<br />
* '''y''': Top-most Y position for detection (absolute)<br />
* '''width''': Width for detection (absolute)<br />
* '''heigh''': Height for detection (absolute)<br />
<br />
===Return===<br />
Returns true/false depending on whether the mouse is within the specified position or not<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function isMouseInPosition ( x, y, width, height )<br />
if ( not isCursorShowing ( ) ) then<br />
return false<br />
end<br />
<br />
local sx, sy = guiGetScreenSize ( )<br />
local cx, cy = getCursorPosition ( )<br />
local cx, cy = ( cx * sx ), ( cy * sy )<br />
if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then<br />
return true<br />
else<br />
return false<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
==Code==<br />
Changes the image when you move your cursor over it.<br />
<syntaxhighlight lang="lua"><br />
addEventHandler ( "onClientRender", root,<br />
function ( )<br />
local imgX, imgY, imgWidth, imgHeight = 50, 50, 200, 200<br />
dxDrawImage ( imgX, imgY, imgWidth, imgHeight, ( isMouseInPosition ( imgX, imgY, imgWidth, imgHeight ) and "myImage2.png" or "myImage.png" ), tocolor ( 255, 255, 255 ) )<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
Author: Castillo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=IsMouseInPosition&diff=43870IsMouseInPosition2015-01-03T20:27:47Z<p>Castillo: </p>
<hr />
<div>{{Useful Function}}<br />
{{Needs Example}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function allows you to check whether the mouse cursor/pointer is within a rectangular position<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool isMouseInPosition ( int x, int y, int width, int height )</syntaxhighlight><br />
<br />
<br />
===Required arguments===<br />
* '''x''': Left-most X position for detection (absolute)<br />
* '''y''': Top-most Y position for detection (absolute)<br />
* '''width''': Width for detection (absolute)<br />
* '''heigh''': Height for detection (absolute)<br />
<br />
===Return===<br />
Returns true/false depending on whether the mouse was within the specified position or not<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function isMouseInPosition ( x, y, width, height )<br />
if ( not isCursorShowing ( ) ) then<br />
return false<br />
end<br />
<br />
local sx, sy = guiGetScreenSize ( )<br />
local cx, cy = getCursorPosition ( )<br />
local cx, cy = ( cx * sx ), ( cy * sy )<br />
if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then<br />
return true<br />
else<br />
return false<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
==Code==<br />
Changes the image when you move your cursor over it.<br />
<syntaxhighlight lang="lua"><br />
addEventHandler ( "onClientRender", root,<br />
function ( )<br />
local imgX, imgY, imgWidth, imgHeight = 50, 50, 200, 200<br />
dxDrawImage ( imgX, imgY, imgWidth, imgHeight, ( isMouseInPosition ( imgX, imgY, imgWidth, imgHeight ) and "myImage2.png" or "myImage.png" ), tocolor ( 255, 255, 255 ) )<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
Author: Castillo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=IsMouseInPosition&diff=43869IsMouseInPosition2015-01-03T20:26:54Z<p>Castillo: /* Example */</p>
<hr />
<div>{{Useful Function}}<br />
{{Needs Example}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function allows you to check whether the mouse cursor/pointer is within a rectangular position<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool isMouseInPosition ( int x, int y, int width, int height )</syntaxhighlight><br />
<br />
<br />
===Required arguments===<br />
* '''x''': Left-most X position for detection (absolute)<br />
* '''y''': Top-most Y position for detection (absolute)<br />
* '''width''': Width for detection (absolute)<br />
* '''heigh''': Height for detection (absolute)<br />
<br />
===Return===<br />
Returns true/false depending on whether the mouse was within the specified position or not<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function isMouseInPosition ( x, y, width, height )<br />
if ( not isCursorShowing ( ) ) then<br />
return false<br />
end<br />
<br />
local sx, sy = guiGetScreenSize ( )<br />
local cx, cy = getCursorPosition ( )<br />
local cx, cy = ( cx * sx ), ( cy * sy )<br />
if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then<br />
return true<br />
else<br />
return false<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
==Code==<br />
Changes the image when you move your cursor over it.<br />
<syntaxhighlight lang="lua"><br />
addEventHandler ( "onClientRender", root,<br />
function ( )<br />
local imgX, imgY, imgWidth, imgHeight = 50, 50, 200, 200<br />
dxDrawImage ( imgX, imgY, imgWidth, imgHeight, ( isMouseInPosition ( imgX, imgY, imgWidth, imgHeight ) and "myImage2.png" or "myImage.png" ), tocolor ( 255, 255, 255 ) )<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=IsMouseInPosition&diff=43868IsMouseInPosition2015-01-03T20:25:14Z<p>Castillo: Fixed function</p>
<hr />
<div>{{Useful Function}}<br />
{{Needs Example}}<br />
<lowercasetitle/><br />
__NOTOC__<br />
This function allows you to check whether the mouse cursor/pointer is within a rectangular position<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool isMouseInPosition ( int x, int y, int width, int height )</syntaxhighlight><br />
<br />
<br />
===Required arguments===<br />
* '''x''': Left-most X position for detection (absolute)<br />
* '''y''': Top-most Y position for detection (absolute)<br />
* '''width''': Width for detection (absolute)<br />
* '''heigh''': Height for detection (absolute)<br />
<br />
===Return===<br />
Returns true/false depending on whether the mouse was within the specified position or not<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function isMouseInPosition ( x, y, width, height )<br />
if ( not isCursorShowing ( ) ) then<br />
return false<br />
end<br />
<br />
local sx, sy = guiGetScreenSize ( )<br />
local cx, cy = getCursorPosition ( )<br />
local cx, cy = ( cx * sx ), ( cy * sy )<br />
if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then<br />
return true<br />
else<br />
return false<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==Example==<br />
Missing<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=GivePedWeapon&diff=43516GivePedWeapon2014-12-28T01:18:46Z<p>Castillo: </p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
{{New feature/item|3.0141|1.4.1|6937|<br />
This function gives the specified weapon to the specified ped. This function can't be used on players, use [[giveWeapon]] for that.<br />
<br />
This function is mainly useful for client side created peds however you can use it on a server side ped, though note that the weapon wouldn't be synced between clients unless your script gives the weapon to the ped on every client.<br />
<br />
There is an optional argument to specify ammunition and whether to set as the current weapon. If you don't specify an ammo value it will give 30 ammo by default and for a melee weapon you can specify just 1 or above.<br />
}}<br />
{{Note|<br />
*When setting ammo for [[Weapon|weapons in slot]] 0,1,10,11 or 12 the maximum ammo is 1<br />
*When setting ammo for [[Weapon|weapons in slot]] 3,4,5 the ammo is added<br />
*When setting ammo for [[Weapon|weapons in slot]] 2,6,7,8,9 and the slot weapon is changing, the ammo is replaced<br />
}}<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua">bool givePedWeapon ( ped thePed, int weapon [, int ammo=30, bool setAsCurrent=false ] )</syntaxhighlight> <br />
<br />
===Required Arguments===<br />
*'''thePed:''' A [[ped]] element.<br />
*'''weapon:''' A whole number integer that refers to a [[Weapon]] ID. Click [[Weapon|here]] for a list of possible weapon IDs.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
*'''ammo:''' A whole number integer serving as the ammo amount for the given weapon. For weapons that do not require ammo, such as melee, this should be at least 1.<br />
*'''setAsCurrent:''' A boolean value determining whether or not the weapon will be set as the peds currently selected weapon.<br />
<br />
===Returns===<br />
Returns ''true'' if weapon was successfully given to the ped, ''false'' otherwise.<br />
<br />
==Example==<br />
'''Example 1:''' This example creates a client side ped, gives them an M4 and make them shoot once you do the command '/armedped'<br />
<syntaxhighlight lang="lua"><br />
function cmdArmedPed( command )<br />
local x, y, z = getElementPosition(localPlayer) -- Get your position<br />
local thePed = createPed(0, x + 1, y, z) -- Create a CJ ped nearby<br />
givePedWeapon(thePed, 31, 5000, true) -- Give him 5000 rounds of M4<br />
setControlState(thePed, "fire", true) -- Make him shoot continuously<br />
end<br />
addCommandHandler("armedped", cmdArmedPed)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client ped functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=SetPedArmor&diff=43488SetPedArmor2014-12-26T03:52:40Z<p>Castillo: </p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function allows you to set the armor value of a [[ped]].<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPedArmor ( ped thePed, float armor )<br />
</syntaxhighlight><br />
{{OOP||[[ped]]:setArmor|armor}}<br />
<br />
===Required Arguments===<br />
*'''thePed''': the [[ped]] whose armor you want to modify.<br />
*'''armor''': the amount of armor you want to set on the ped. Valid values are from 0 to 100.<br />
<br />
===Returns===<br />
Returns ''true'' if the armor was changed succesfully. Returns ''false'' if an invalid ped was specified, or the armor value specified is out of acceptable range.<br />
<br />
==Example==<br />
This example removes the armor of a player.<br />
<syntaxhighlight lang="lua"><br />
function givePlayerArmor ( player, command )<br />
setPedArmor ( player, 100 ) -- Set player's armor to 100 when he types the command 'addarmor'<br />
end<br />
addCommandHandler ( "addarmor", givePlayerArmor )<br />
<br />
function removePlayerArmor ( player, command )<br />
setPedArmor ( player, 0 ) -- Set player's armor to 0 when he types the command 'removearmor'<br />
end<br />
addCommandHandler ( "removearmor", removePlayerArmor )<br />
</syntaxhighlight><br />
<br />
In this, adds an amount of armor that the player defined in command 'addarmor'.<br />
<syntaxhighlight lang="lua"><br />
function givePlayerArmor( player, command, amount )<br />
if getPedArmor(player) == 100 then<br />
return<br />
outputChatBox("Your armor already is complete!", player, 220, 0, 0 ) -- Inform the player if your armor already is complete.<br />
end<br />
if amount and tonumber(amount) >= 1 or tonumber(amount) <= 100 then -- If amount is between 1 and 100.<br />
setPedArmor( player, tonumber(amount) ) -- Set amount armor that player chosen on the command.<br />
else<br />
return<br />
end<br />
if not amount then<br />
outputChatBox( "sintax: /addarmor [armor-amount]", player, 220, 0, 0 ) -- Inform the player if 'amount' argument is missing.<br />
end<br />
end<br />
addCommandHandler( "addarmor", givePlayerArmor )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Ped functions}}<br />
[[ru:setPedArmor]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=SetPedArmor&diff=43487SetPedArmor2014-12-26T03:52:20Z<p>Castillo: Corrected OOP syntax error</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function allows you to set the armor value of a [[ped]].<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPedArmor ( ped thePed, float armor )<br />
</syntaxhighlight><br />
{{OOP||[[ped]]:getArmor|armor}}<br />
<br />
===Required Arguments===<br />
*'''thePed''': the [[ped]] whose armor you want to modify.<br />
*'''armor''': the amount of armor you want to set on the ped. Valid values are from 0 to 100.<br />
<br />
===Returns===<br />
Returns ''true'' if the armor was changed succesfully. Returns ''false'' if an invalid ped was specified, or the armor value specified is out of acceptable range.<br />
<br />
==Example==<br />
This example removes the armor of a player.<br />
<syntaxhighlight lang="lua"><br />
function givePlayerArmor ( player, command )<br />
setPedArmor ( player, 100 ) -- Set player's armor to 100 when he types the command 'addarmor'<br />
end<br />
addCommandHandler ( "addarmor", givePlayerArmor )<br />
<br />
function removePlayerArmor ( player, command )<br />
setPedArmor ( player, 0 ) -- Set player's armor to 0 when he types the command 'removearmor'<br />
end<br />
addCommandHandler ( "removearmor", removePlayerArmor )<br />
</syntaxhighlight><br />
<br />
In this, adds an amount of armor that the player defined in command 'addarmor'.<br />
<syntaxhighlight lang="lua"><br />
function givePlayerArmor( player, command, amount )<br />
if getPedArmor(player) == 100 then<br />
return<br />
outputChatBox("Your armor already is complete!", player, 220, 0, 0 ) -- Inform the player if your armor already is complete.<br />
end<br />
if amount and tonumber(amount) >= 1 or tonumber(amount) <= 100 then -- If amount is between 1 and 100.<br />
setPedArmor( player, tonumber(amount) ) -- Set amount armor that player chosen on the command.<br />
else<br />
return<br />
end<br />
if not amount then<br />
outputChatBox( "sintax: /addarmor [armor-amount]", player, 220, 0, 0 ) -- Inform the player if 'amount' argument is missing.<br />
end<br />
end<br />
addCommandHandler( "addarmor", givePlayerArmor )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Ped functions}}<br />
[[ru:setPedArmor]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=GetPedArmor&diff=43486GetPedArmor2014-12-26T03:51:12Z<p>Castillo: Added OOP syntax</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function returns the current armor of the specified [[ped]].<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">float getPedArmor ( ped thePed )</syntaxhighlight><br />
{{OOP||[[ped]]:getArmor||setPedArmor}}<br />
<br />
===Required Arguments===<br />
*'''thePed:''' The [[ped]] whose armor you want to check<br />
<br />
===Returns===<br />
A ''float'' with the armor, ''false'' if an invalid ped was given.<br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example defines a "showarmor" console command that shows the player that executes it how much armor he has.<br />
<syntaxhighlight lang="lua"><br />
function showArmor ( )<br />
local me = getLocalPlayer ( )<br />
local armor = getPedArmor ( me )<br />
outputChatBox( "Your armor: " .. armor )<br />
end<br />
addCommandHandler ( "showarmor", showArmor )<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Ped functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=GetPedAnimation&diff=43485GetPedAnimation2014-12-26T03:49:34Z<p>Castillo: /* Syntax */</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
<br />
Gets the animation of a player or ped that was set using [[setPedAnimation]].<br />
<br />
''Note: Use [[getPedTask]] to monitor what movements the player is currently doing.''<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
string string getPedAnimation ( ped thePed )<br />
</syntaxhighlight><br />
{{OOP||[[ped]]:getAnimation||setPedAnimation}}<br />
<br />
===Required Arguments===<br />
*'''thePed:''' the player or ped you want to get the animation of.<br />
<br />
===Returns===<br />
Returns two ''strings'': the first is the name of the block, the second is the name of the animation. Returns ''false'' if there was an error or if the ped is not doing an animation.<br />
<br />
==Example==<br />
This example adds a command that allows you to copy the animation being used by another player using /copyanim theirName<br />
<syntaxhighlight lang="lua"><br />
function CopyAnimation(theCommand, thePlayer) -- The Command Function<br />
if thePlayer then -- If a player name entered then<br />
thePlayerToCopyFrom = getPlayerFromName(thePlayer) -- get player from his name<br />
Block, Anim = getPedAnimation(thePlayerToCopyFrom) -- get the player animation<br />
if Block then -- if got the animation successfully then<br />
setPedAnimation(localPlayer, Block, Anim) -- set my animation the same<br />
outputChatBox("* Copied Successfully !") -- output chat message<br />
end<br />
else <br />
outputChatBox("* Please Enter a Player Name To Copy From !") -- if you didnt entered a player name , then output a chat box message<br />
end<br />
end<br />
addCommandHandler("copyanim", CopyAnimation) -- adding the Command Handler<br />
</syntaxhighlight><br />
<br />
==Example 2==<br />
<br />
This example shows what block and animation your player is currently performing. Note this will return "N/A" if you did not set an animation with [[setPedAnimation]]. If you want to see what the player ped is doing as you control them that is [[getPedTask]].<br />
<syntaxhighlight lang="lua"><br />
addEventHandler("onClientPreRender",root,<br />
function ()<br />
local block, animation = getPedAnimation(localPlayer)<br />
dxDrawText ( "CURRENT ANIMATION INFO...", 100, 300 )<br />
if not block then block = "N/A" end<br />
if not animation then animation = "N/A" end<br />
dxDrawText ( "Block = "..block.." Animation = "..animation, 100, 315 )<br />
end )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_ped_functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=SetPedAnimation&diff=43484SetPedAnimation2014-12-26T03:49:15Z<p>Castillo: /* Syntax */</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
<br />
Sets the current animation of a player or ped. Not specifying the type of animation will automatically cancel the current one.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPedAnimation ( ped thePed [, string block=nil, string anim=nil, int time=-1, bool loop=true, bool updatePosition=true, bool interruptable=true, bool freezeLastFrame = true] )<br />
</syntaxhighlight><br />
{{OOP||[[ped]]:setAnimation||getPedAnimation}}<br />
<br />
===Required Arguments===<br />
*'''thePed:''' the player or ped you want to apply an animation to.<br />
<br />
===Optional Arguments===<br />
{{OptionalArg}}<br />
*'''block:''' the [[Animations|animation]] block's name.<br />
*'''anim:''' the name of the [[Animations|animation]] within the block.<br />
*'''time:''' how long the animation will run for in milliseconds.<br />
*'''loop:''' indicates whether or not the animation will loop.<br />
*'''updatePosition:''' will change the actual coordinates of the ped according to the animation. Use this for e.g. walking animations.<br />
*'''interruptable:''' if set to 'false' other tasks wont be able to interupt the animation. Setting this to 'false' also gives this function more power to override other animations that are running. For example, squatting after a jump can be terminated.<br />
*'''freezeLastFrame:''' ... (From 1.1 onwards).<br />
<br />
===Returns===<br />
Returns ''true'' if succesful, ''false'' otherwise.<br />
<br />
==Example1== <br />
<br />
<section name="Server" class="server" show="true"><br />
This example creates a ped, rotates him, and makes him walk:<br />
<syntaxhighlight lang="lua"><br />
function makePed()<br />
ped1 = createPed(56, 1, 1, 4)<br />
setPedRotation(ped1, 315)<br />
setPedAnimation( ped1, "ped", "WOMAN_walknorm")<br />
end<br />
addCommandHandler("makemyped", makePed)<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
==Example2==<br />
This example makes the player dance when he uses command /dance and stop when he uses the same command:<br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
<br />
addEventHandler("onClientPreRender",root,<br />
function ()<br />
daBlock, daAnim = getPedAnimation(getLocalPlayer())<br />
setElementData(root,"blockz",daBlock)<br />
setElementData(root,"animz",daAnim)<br />
end )<br />
<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function dance (source)<br />
daBlockz = getElementData(root,"blockz")<br />
daAnimz = getElementData(root,"animz")<br />
if daBlockz == "dancing" and daAnimz == "dnce_m_b" then<br />
setPedAnimation(source,false)<br />
else<br />
setPedAnimation ( source, "DANCING", "dnce_m_b")<br />
end<br />
end<br />
addCommandHandler("dance",dance)<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Ped_functions}}<br />
[[ru:setPedAnimation]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=SetPedCanBeKnockedOffBike&diff=43483SetPedCanBeKnockedOffBike2014-12-26T03:47:01Z<p>Castillo: Added OOP syntax</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
This function controls if a ped can fall of his bike by accident - namely by banging into a wall.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool setPedCanBeKnockedOffBike ( ped thePed, bool canBeKnockedOffBike ) <br />
</syntaxhighlight> <br />
<br />
{{OOP||[[ped]]:setCanBeKnockedOffBike||canPedBeKnockedOffBike}}<br />
<br />
===Required Arguments=== <br />
*'''thePed:''' the ped whose knockoffstatus is being changed<br />
*'''canBeKnockedOffBike:''' ''true'' or ''false''<br />
<br />
==Example== <br />
This example adds a console command with which the local player can toggle if he can fall off bikes.<br />
<br />
<syntaxhighlight lang="lua"><br />
function changeCanBeKnockedOff ( command )<br />
-- The player should enter /knock<br />
if canPedBeKnockedOffBike ( getLocalPlayer() ) then<br />
setPedCanBeKnockedOffBike ( getLocalPlayer(), false )<br />
outputChatBox ( "Now you can't be knocked off your bike." )<br />
else<br />
setPedCanBeKnockedOffBike ( getLocalPlayer(), true )<br />
outputChatBox ( "Now you can be knocked off your bike." )<br />
end<br />
end<br />
addCommandHandler ( "knock", changeCanBeKnockedOff )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_ped_functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=CanPedBeKnockedOffBike&diff=43482CanPedBeKnockedOffBike2014-12-26T03:45:09Z<p>Castillo: Added OOP syntax</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
This function checks if the given ped can fall off bikes.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool canPedBeKnockedOffBike ( ped thePed ) <br />
</syntaxhighlight><br />
<br />
{{OOP||[[ped]]:canBeKnockedOffBike||setPedCanBeKnockedOffBike}}<br />
<br />
===Required Arguments=== <br />
*'''thePed:''' the ped you want to check.<br />
<br />
===Returns===<br />
Returns ''true'' if the ped can be knocked off bikes, ''false'' if he cannot or an invalid element was passed.<br />
<br />
==Example== <br />
This example adds a console command with which the local player can toggle whether he can fall off bikes.<br />
<syntaxhighlight lang="lua"><br />
function changeCanBeKnockedOff ( command )<br />
-- lets players be knocked off bikes if it was set to false, true otherwise<br />
local bCanBeKnockedOff = canPedBeKnockedOffBike(localPlayer)<br />
setPedCanBeKnockedOffBike(localPlayer, not bCanBeKnockedOff)<br />
<br />
-- outputs the respective message<br />
outputChatBox( ('Now you %s be knocked off your bike.'):format(bCanBeKnockedOff and 'can\'t' or 'can') )<br />
end<br />
addCommandHandler('knock', changeCanBeKnockedOff)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_ped_functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=TeaEncode&diff=40993TeaEncode2014-07-22T18:18:24Z<p>Castillo: </p>
<hr />
<div>__NOTOC__<br />
{{Server_client function}}<br />
<br />
{{New feature/item|9.06056|1.3.5|6056|<br />
This functions performs the [https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm Tiny Encryption Algorithm] on the given string and returns the [https://en.wikipedia.org/wiki/Base64 base64] representation of the encrypted block of data.<br />
}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">string teaEncode ( string data, string key )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''data:''' The block of data you want to encrypt<br />
*'''key:''' The key that should be used for encryption (Only first 16 characters are used)<br />
<br />
===Returns===<br />
Returns the [https://en.wikipedia.org/wiki/Base64 base64] representation of the encrypted data if the encryption process was successfully completed, ''false'' otherwise.<br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example creates a /teaencrypt command, which performs the TEA on a given string with the specified key, if any.<br />
<syntaxhighlight lang="lua"><br />
function encrypt(cmd, string, key)<br />
if string then<br />
if not key then<br />
key = string.rep(string.char(math.random(string.byte("a"), string.byte("Z"))), 10) -- Generate a random key of 10 characters<br />
end<br />
local encodedString = teaEncode(string, key) -- Encode the string with the key<br />
outputChatBox("The encoded string is: " .. encodedString .. " (used key: " .. key .. ")")<br />
else<br />
outputChatBox("Syntax: /" .. cmd .. " (string) [key].")<br />
end<br />
end<br />
addCommandHandler("teaencrypt", encrypt)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Utility functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=TeaEncode&diff=40992TeaEncode2014-07-22T18:17:42Z<p>Castillo: </p>
<hr />
<div>__NOTOC__<br />
{{Server_client function}}<br />
<br />
{{New feature/item|9.06056|1.3.5|6056|<br />
This functions performs the [https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm Tiny Encryption Algorithm] on the given string and returns the [https://en.wikipedia.org/wiki/Base64 base64] representation of the encrypted block of data.<br />
}}<br />
<br />
'''Note: The encryption key used for decode only uses 16 characters.'''<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">string teaEncode ( string data, string key )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''data:''' The block of data you want to encrypt<br />
*'''key:''' The key that should be used for encryption (Only first 16 characters are used)<br />
<br />
===Returns===<br />
Returns the [https://en.wikipedia.org/wiki/Base64 base64] representation of the encrypted data if the encryption process was successfully completed, ''false'' otherwise.<br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example creates a /teaencrypt command, which performs the TEA on a given string with the specified key, if any.<br />
<syntaxhighlight lang="lua"><br />
function encrypt(cmd, string, key)<br />
if string then<br />
if not key then<br />
key = string.rep(string.char(math.random(string.byte("a"), string.byte("Z"))), 10) -- Generate a random key of 10 characters<br />
end<br />
local encodedString = teaEncode(string, key) -- Encode the string with the key<br />
outputChatBox("The encoded string is: " .. encodedString .. " (used key: " .. key .. ")")<br />
else<br />
outputChatBox("Syntax: /" .. cmd .. " (string) [key].")<br />
end<br />
end<br />
addCommandHandler("teaencrypt", encrypt)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Utility functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Drawing_functions&diff=38967Template:Drawing functions2014-02-24T16:56:16Z<p>Castillo: </p>
<hr />
<div>*[[dxDrawImage]]<br />
*[[dxDrawImageSection]]<br />
*[[dxDrawLine]]<br />
*[[dxDrawLine3D]]<br />
*[[dxDrawRectangle]]<br />
*[[dxDrawText]]<br />
*[[dxGetFontHeight]]<br />
*[[dxGetTextWidth]]<br />
*[[dxCreateFont]]<br />
*[[dxCreateTexture]]<br />
*[[dxCreateShader]]<br />
*[[dxCreateRenderTarget]]<br />
*[[dxCreateScreenSource]]<br />
*[[dxGetMaterialSize]]<br />
*[[dxSetShaderValue]]<br />
*[[dxSetShaderTessellation]]<br />
*[[dxSetShaderTransform]]<br />
*[[dxSetRenderTarget]]<br />
*[[dxUpdateScreenSource]]<br />
*[[dxGetStatus]]<br />
*[[dxSetTestMode]]<br />
*[[dxGetTexturePixels]]<br />
*[[dxSetTexturePixels]]<br />
*[[dxGetPixelsSize]]<br />
*[[dxGetPixelsFormat]]<br />
*[[dxConvertPixels]]<br />
*[[dxGetPixelColor]]<br />
*[[dxSetPixelColor]]<br />
*[[dxSetBlendMode]]<br />
*[[dxGetBlendMode]]<br />
*[[dxDrawMaterialLine3D]]<br />
*[[dxDrawMaterialSectionLine3D]]<br />
*[[dxSetAspectRatioAdjustmentEnabled]]<br />
{{New feature/item|3.0140|1.3.5|6054|<br />
* [[dxSetTextureEdge]]<br />
}}<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_weapon_creation_events&diff=38966Template:Client weapon creation events2014-02-24T16:55:11Z<p>Castillo: </p>
<hr />
<div>*[[onClientWeaponFire]]<br />
<noinclude>[[Category:Events templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_object_events&diff=38965Template:Client object events2014-02-24T16:54:48Z<p>Castillo: </p>
<hr />
<div>*[[onClientObjectDamage]]<br />
*[[onClientObjectBreak]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_player_events&diff=38964Template:Client player events2014-02-24T16:54:20Z<p>Castillo: </p>
<hr />
<div>*[[onClientPlayerJoin]]<br />
*[[onClientPlayerQuit]]<br />
*[[onClientPlayerWeaponFire]]<br />
*[[onClientPlayerWeaponSwitch]]<br />
*[[onClientPlayerTarget]]<br />
*[[onClientPlayerDamage]]<br />
*[[onClientPlayerSpawn]]<br />
*[[onClientPlayerWasted]]<br />
*[[onClientPlayerVehicleEnter]]<br />
*[[onClientPlayerVehicleExit]]<br />
*[[onClientPlayerChangeNick]]<br />
*[[onClientPlayerStuntStart]]<br />
*[[onClientPlayerStuntFinish]]<br />
*[[onClientPlayerChoke]]<br />
*[[onClientPlayerRadioSwitch]]<br />
*[[onClientPlayerStealthKill]]<br />
*[[onClientPlayerVoiceStart]]<br />
*[[onClientPlayerVoiceStop]]<br />
*[[onClientPlayerHeliKilled]]<br />
*[[onClientPlayerHitByWaterCannon]]<br />
*[[onClientPlayerPickupHit]]<br />
*[[onClientPlayerPickupLeave]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_ped_events&diff=38963Template:Client ped events2014-02-24T16:53:02Z<p>Castillo: </p>
<hr />
<div>*[[onClientPedDamage]]<br />
*[[onClientPedWasted]]<br />
*[[onClientPedWeaponFire]]<br />
*[[onClientPedChoke]]<br />
*[[onClientPedHeliKilled]]<br />
*[[onClientPedHitByWaterCannon]]<br />
<noinclude>[[Category:Events templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_cursor_functions&diff=38962Template:Client cursor functions2014-02-24T16:51:36Z<p>Castillo: </p>
<hr />
<div>*[[getCursorPosition]]<br />
*[[setCursorPosition]]<br />
*[[isCursorShowing]]<br />
*[[showCursor]]<br />
*[[getCursorAlpha]]<br />
*[[setCursorAlpha]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Resource:Exp_system&diff=37254Resource:Exp system2013-10-03T01:09:01Z<p>Castillo: </p>
<hr />
<div>{{Resource page}}<br />
A level/experience system made from scratch by [[User:Castillo|Castillo]].<br><br />
It uses SQLite to save level and experience.<br />
<br />
=Exported Functions=<br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerLevel ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the player.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local myLevel = exports.exp_system:getPlayerLevel ( thePlayer )<br />
outputChatBox ( "Your level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerLevel ( player thePlayer, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setPlayerLevel ( thePlayer, theLevel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerEXP ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local myExp = exports.exp_system:getPlayerEXP ( thePlayer )<br />
outputChatBox ( "Your experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setPlayerEXP ( thePlayer, theExp )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to give a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool addPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you to give the experience.<br />
*'''theExperience''': The exprience you want to give.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was given successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addEvent ( "onZombieWasted", true )<br />
addEventHandler ( "onZombieWasted", root,<br />
function ( theKiller )<br />
exports.exp_system:addPlayerEXP ( theKiller, 5 )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountLevel ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the account.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountLevel ( account )<br />
outputChatBox ( "Your account level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountLevel ( account theAccount, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setAccountLevel ( account, theLevel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountEXP ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountEXP ( account )<br />
outputChatBox ( "Your account experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountEXP ( account theAccount, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setAccountEXP ( account, theExp )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to refresh the levels.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool loadLevelsFromXML( )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''None'''<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "refreshlevels",<br />
function ( )<br />
exports.exp_system:loadLevelsFromXML ( )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to obtain the name and experience required of a level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
getLevelData ( int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theLevel'''<br />
<br />
==Returns==<br />
Returns the name of the level and the experience required.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "getleveldata",<br />
function ( thePlayer )<br />
local level = exports.exp_system:getPlayerLevel ( thePlayer )<br />
local name, expreq = exports.exp_system:getLevelData ( level )<br />
outputChatBox ( name ..": ".. expreq, thePlayer )<br />
end<br />
)<br />
</section><br />
<br />
=Custom Events=<br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level changes.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerChangeLevel<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] whose level changed.<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level UP.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerLevelUP<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] who leveled UP.<br />
</section><br />
<br />
=See also=<br />
[http://community.mtasa.com/index.php?p=resources&s=details&id=1253 Download page]<br><br />
<br />
[[Category:Resource]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=DxDrawGifImage&diff=35869DxDrawGifImage2013-05-07T20:32:19Z<p>Castillo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function simulates the effect of a GIF image by using image sprites.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">element dxDrawGifImage ( float x, float y, float width, float height, string path, float startImageID, string fileExtension, float effectSpeed )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''x:''' A float of the 2D x position of the GUI button on a player's screen.<br />
*'''y:''' A float of the 2D y position of the GUI button on a player's screen.<br />
*'''width:''' A float of the width of the GUI button.<br />
*'''height:''' A float of the height of the GUI button.<br />
*'''path:''' The filepath of the image files will be loaded. A "%s" is required to denote where the "id" is placed.<br />
"%snyancat.png" would be read as "1nyancat.png" "2nyancat.png" etc<br />
"a%sbcdefghe" would read the images "a1sbcdefghe" "a2sbcdefghe" "a3sbcdefghe" etc.<br />
<br />
*'''startImageID:''' The image ID that will be loaded in the first place.<br />
*'''fileExtension:''' The image extension ( e.g: png, jpg, etc. ).<br />
*'''effectSpeed:''' The speed between the change of the images.<br />
<br />
==Code==<br />
<section name="Clientside Script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function dxDrawGifImage ( x, y, w, h, path, iStart, iType, effectSpeed )<br />
local gifElement = createElement ( "dx-gif" )<br />
if ( gifElement ) then<br />
setElementData (<br />
gifElement,<br />
"gifData",<br />
{<br />
x = x,<br />
y = y,<br />
w = w,<br />
h = h,<br />
imgPath = path,<br />
startID = iStart,<br />
imgID = iStart,<br />
imgType = iType,<br />
speed = effectSpeed,<br />
tick = getTickCount ( )<br />
},<br />
false<br />
)<br />
return gifElement<br />
else<br />
return false<br />
end<br />
end<br />
<br />
addEventHandler ( "onClientRender", root,<br />
function ( )<br />
local currentTick = getTickCount ( )<br />
for index, gif in ipairs ( getElementsByType ( "dx-gif" ) ) do<br />
local gifData = getElementData ( gif, "gifData" )<br />
if ( gifData ) then<br />
if ( currentTick - gifData.tick >= gifData.speed ) then<br />
gifData.tick = currentTick<br />
gifData.imgID = ( gifData.imgID + 1 )<br />
if ( fileExists ( gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) ) then<br />
gifData.imgID = gifData.imgID<br />
setElementData ( gif, "gifData", gifData, false )<br />
else<br />
gifData.imgID = gifData.startID<br />
setElementData ( gif, "gifData", gifData, false )<br />
end<br />
end<br />
dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType )<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example will create a "gif" image and a command to destroy it.<br />
<syntaxhighlight lang="lua"><br />
gif = dxDrawGifImage ( 769, 175, 193, 145, "images/flag_arg", 0, "png", 120 )<br />
<br />
addCommandHandler ( "destroygif",<br />
function ( )<br />
destroyElement ( gif )<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: Castillo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=GetResourceSettings&diff=35461GetResourceSettings2013-04-18T03:09:24Z<p>Castillo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function returns a table of the resource settings.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">table getResourceSettings( resource theResource )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''theResource''': The resource where you want to get the settings from.<br />
<br />
===Optional Arguments===<br />
<br />
==Code==<br />
<section name="Serverside Script" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
function getResourceSettings ( resource )<br />
if ( not resource ) then<br />
return false<br />
end<br />
<br />
local settingsTable = { }<br />
local name = getResourceName ( resource )<br />
local meta = xmlLoadFile ( ":".. name .."/meta.xml" )<br />
if ( not meta ) then<br />
return false<br />
end<br />
<br />
local settings = xmlFindChild ( meta, "settings", 0 )<br />
if ( settings ) then<br />
for _, setting in ipairs ( xmlNodeGetChildren ( settings ) ) do<br />
local oldName = xmlNodeGetAttribute ( setting, "name" )<br />
local temp = string.gsub ( oldName, '[%*%#%@](.*)','%1' )<br />
table.insert (<br />
settingsTable,<br />
{<br />
string.gsub ( temp, name ..'%.(.*)','%1' ),<br />
xmlNodeGetAttribute ( setting, "value" ),<br />
xmlNodeGetAttribute ( setting, "friendlyname" ),<br />
xmlNodeGetAttribute ( setting, "accept" ),<br />
xmlNodeGetAttribute ( setting, "desc" ),<br />
xmlNodeGetAttribute ( setting, "group" )<br />
}<br />
)<br />
end<br />
end<br />
<br />
xmlUnloadFile ( meta )<br />
return settingsTable<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example get's the settings count from a resource.<br />
<syntaxhighlight lang="lua"><br />
function getResourceSettings ( resource )<br />
if ( not resource ) then<br />
return false<br />
end<br />
<br />
local settingsTable = { }<br />
local name = getResourceName ( resource )<br />
local meta = xmlLoadFile ( ":".. name .."/meta.xml" )<br />
if ( not meta ) then<br />
return false<br />
end<br />
<br />
local settings = xmlFindChild ( meta, "settings", 0 )<br />
if ( settings ) then<br />
for _, setting in ipairs ( xmlNodeGetChildren ( settings ) ) do<br />
local oldName = xmlNodeGetAttribute ( setting, "name" )<br />
local temp = string.gsub ( oldName, '[%*%#%@](.*)','%1' )<br />
table.insert (<br />
settingsTable,<br />
{<br />
string.gsub ( temp, name ..'%.(.*)','%1' ),<br />
xmlNodeGetAttribute ( setting, "value" ),<br />
xmlNodeGetAttribute ( setting, "friendlyname" ),<br />
xmlNodeGetAttribute ( setting, "accept" ),<br />
xmlNodeGetAttribute ( setting, "desc" ),<br />
xmlNodeGetAttribute ( setting, "group" )<br />
}<br />
)<br />
end<br />
end<br />
<br />
xmlUnloadFile ( meta )<br />
return settingsTable<br />
end<br />
<br />
-- define the command handler function<br />
function countSettings ( thePlayer, commandName, resourceName )<br />
local settings = getResourceSettings ( getResourceFromName ( resourceName ) )<br />
if ( settings ) then<br />
outputChatBox ( "This resource has: ".. #settings .." settings.", thePlayer ) -- output the count to the chatbox.<br />
end<br />
end<br />
-- add the command handler<br />
addCommandHandler ( "settings", countSettings )<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: Castillo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=DxDrawImage3D&diff=34865DxDrawImage3D2013-02-10T04:33:52Z<p>Castillo: </p>
<hr />
<div>{{Useful Function}}<br />
__NOTOC__<br />
This function draws a textured 3D line between two points in the 3D world that appers to be a 3D image - rendered for one frame This should be used in conjunction with [[onClientPreRender]] in order to display continuously.<br />
<br />
The 3D line with a large width value and a texture effectively becomes a 3D image, hence the possibility to construct basic shapes such as boxes with several large width lines and the appropriate values for 'faceToward'.<br />
<br />
3D lines are drawn at a particular place in the [[Game_Processing_Order|game processing order]], so use [[onClientPreRender]] for drawing if you are attaching them to world elements.<br><br />
* '''NOTE:''' This is made to be used clientside!.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool dxDraw3DImage ( float x, float y, float z, float width, float height, element material[, int color, float rotation, float faceTowardX, float faceTowardY, float faceTowardZ]</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
* '''X/Y/Z:''' The start position of the 3D image, representing a coordinate in the GTA world.<br />
* '''width:''' The width of the image in GTA world units. (This is 1/75th of the width used in dxDrawLine3D)<br />
* '''height:''' The height of the image in GTA world units. (This is 1/75th of the width used in dxDrawLine3D)<br />
* '''material:''' A material to draw the image with.<br />
<br />
<br />
==Optional Arguments==<br />
{{OptionalArg}}<br />
* '''color:''' An integer of the hex color, produced using [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).<br />
* '''rotation:''' Rotation (end point of the image) offset<br />
* '''faceTowardX/Y/Z:''' The direction the front of the image should face towards. If this is not set, the front of the image always faces toward the camera.<br />
<br />
===Returns===<br />
Returns a ''true'' if the operation was successful, ''false'' otherwise.<br />
<br />
==Code==<br />
<section name="Clientside script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
local white = tocolor(255,255,255,255)<br />
function dxDrawImage3D(x,y,z,w,h,m,c,r,...)<br />
local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z<br />
return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c or white, ...)<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
This draws a trollface in the middle of the GTA world for no reason<br />
<syntaxhighlight lang="lua"><br />
local face = dxCreateTexture("trollface.png")<br />
addEventHandler("onClientRender", root,<br />
function()<br />
dxDrawImage3D(0,0, 20, 20, 20, face, tocolor(255,255,255,255))<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
Author: qaisjp<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=DxDrawImage3D&diff=34864DxDrawImage3D2013-02-10T03:33:50Z<p>Castillo: </p>
<hr />
<div>{{Useful Function}}<br />
__NOTOC__<br />
This function draws a textured 3D line between two points in the 3D world that appers to be a 3D image - rendered for one frame This should be used in conjunction with [[onClientPreRender]] in order to display continuously.<br />
<br />
The 3D line with a large width value and a texture effectively becomes a 3D image, hence the possibility to construct basic shapes such as boxes with several large width lines and the appropriate values for 'faceToward'.<br />
<br />
3D lines are drawn at a particular place in the [[Game_Processing_Order|game processing order]], so use [[onClientPreRender]] for drawing if you are attaching them to world elements.<br><br />
* '''NOTE:''' This is made to be used clientside!.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool dxDraw3DImage ( float x, float y, float z, float width, float height, element material[, int color, float rotation, float faceTowardX, float faceTowardY, float faceTowardZ]</syntaxhighlight><br />
<br />
===Required Arguments=== <br />
* '''X/Y/Z:''' The start position of the 3D image, representing a coordinate in the GTA world.<br />
* '''width:''' The width of the image in GTA world units. (This is 1/75th of the width used in dxDrawLine3D)<br />
* '''height:''' The height of the image in GTA world units. (This is 1/75th of the width used in dxDrawLine3D)<br />
* '''material:''' A material to draw the image with.<br />
<br />
<br />
==Optional Arguments==<br />
{{OptionalArg}}<br />
* '''color:''' An integer of the hex color, produced using [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).<br />
* '''rotation:''' Rotation (end point of the image) offset<br />
* '''faceTowardX/Y/Z:''' The direction the front of the image should face towards. If this is not set, the front of the image always faces toward the camera.<br />
<br />
===Returns===<br />
Returns a ''true'' if the operation was successful, ''false'' otherwise.<br />
<br />
==Code==<br />
<section name="Clientside script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
local white = tocolor(255,255,255,255)<br />
function dxDrawImage3D(x,y,z,w,h,m,c,r,...)<br />
local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z<br />
return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c or white, ...)<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
This draws a trollface in the middle of the GTA world for no reason<br />
<syntaxhighlight lang="lua"><br />
local face = dxCreateTexture("trollface.png")<br />
addEventHandler("onClientRender", root,<br />
function()<br />
dxDrawImage3D(0,0, 20, 20, 20, face, tocolor(255,255,255,255))<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
Author: qaisjp<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Resource:Exp_system&diff=34566Resource:Exp system2013-01-17T22:31:11Z<p>Castillo: </p>
<hr />
<div>{{Resource page}}<br />
A level/experience system made from scratch by [[User:Castillo|Castillo]].<br><br />
It uses SQLite to save level and experience.<br />
<br />
=Exported Functions=<br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerLevel ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the player.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local myExp = exports.exp_system:getPlayerLevel ( thePlayer )<br />
outputChatBox ( "Your level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerLevel ( player thePlayer, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setPlayerLevel ( thePlayer, theLEvel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerEXP ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local myExp = exports.exp_system:getPlayerEXP ( thePlayer )<br />
outputChatBox ( "Your experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setPlayerEXP ( thePlayer, theExp )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to give a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool addPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you to give the experience.<br />
*'''theExperience''': The exprience you want to give.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was given successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addEvent ( "onZombieWasted", true )<br />
addEventHandler ( "onZombieWasted", root,<br />
function ( theKiller )<br />
exports.exp_system:addPlayerEXP ( theKiller, 5 )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountLevel ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the account.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountLevel ( account )<br />
outputChatBox ( "Your account level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountLevel ( account theAccount, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setAccountLevel ( account, theLEvel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountEXP ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountEXP ( account )<br />
outputChatBox ( "Your account experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountEXP ( account theAccount, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setAccountEXP ( account, theExp )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to refresh the levels.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool loadLevelsFromXML( )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''None'''<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "refreshlevels",<br />
function ( )<br />
exports.exp_system:loadLevelsFromXML ( )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to obtain the name and experience required of a level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
getLevelData ( int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theLevel'''<br />
<br />
==Returns==<br />
Returns the name of the level and the experience required.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "getleveldata",<br />
function ( thePlayer )<br />
local level = exports.exp_system:getPlayerLevel ( thePlayer )<br />
local name, expreq = exports.exp_system:getLevelData ( level )<br />
outputChatBox ( name ..": ".. expreq, thePlayer )<br />
end<br />
)<br />
</section><br />
<br />
=Custom Events=<br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level changes.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerChangeLevel<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] whose level changed.<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level UP.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerLevelUP<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] who leveled UP.<br />
</section><br />
<br />
=See also=<br />
[http://community.mtasa.com/index.php?p=resources&s=details&id=1253 Download page]<br><br />
<br />
[[Category:Resource]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=ES/PlaySound3D&diff=34188ES/PlaySound3D2012-12-08T16:23:02Z<p>Castillo: </p>
<hr />
<div>== playSound3D ==<br />
<br />
Crea un elemento de sonido en el mundo GTA y lo reproduce inmediatamente después de la creación para el jugador local. setElementPosition se puede utilizar para mover el elemento de sonido alrededor después de que ha sido creado.<br />
<br />
''Nota'': Los formatos de audio soportados sólo son MP3, WAV, OGG, RIFF, MOD, XM, IT y S3M.<br />
<br />
<br />
== Sintaxis ==<br />
<syntaxhighlight lang="lua">elemento playSound3D ( string el archivo de audio, posX, posY, posZ, [ bool bucle = false ] )</syntaxhighlight><br />
<br />
<br />
== Argumentos Requeridos ==<br />
<br />
<br />
*'''El audio''': El archivo de audio que quieres reproducir. (agregar el tag <file> </file> en el archivo meta.xml).<br />
<br />
*'''x''': El punto flotante que representa la coordenada X en el mapa.<br />
<br />
*'''y''': El punto flotante que representa la coordenada Y en el mapa.<br />
<br />
*'''z''': El punto flotante que representa la coordenada Z en el mapa.<br />
<br />
----<br />
<br />
== Argumentos Opcionales ==<br />
<br />
*'''Bucle''': El bucle representa si el sonido se reproducirá de nuevo o No. De caso contrario usar false.<br />
<br />
----<br />
<br />
== Ejemplos ==<br />
En este ejemplo se reproduce un archivo de audio en la pizzeria , cerca de de Pier 69 en San Fierro.<br />
<syntaxhighlight lang="lua"><br />
addEventHandler( 'onClientResourceStart', resourceRoot,<br />
function( )<br />
local uSound = playSound3D( 'sonidos/audio23.mp3', 2498, -1659, 12, true ) -- Se utiliza 'true' porque el sonido se repetirá infinidad de veces<br />
setSoundMaxDistance( uSound, 100 )<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
==Mira Tambien==<br />
{{Client_audio_functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Resource:Exp_system&diff=34122Resource:Exp system2012-11-14T16:42:25Z<p>Castillo: </p>
<hr />
<div>{{Resource page}}<br />
A level/experience system made from scratch by [[User:Castillo|Castillo]].<br><br />
It uses SQLite to save level and experience.<br />
<br />
=Exported Functions=<br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerLevel ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the player.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local myExp = exports.exp_system:getPlayerLevel ( thePlayer )<br />
outputChatBox ( "Your level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerLevel ( player thePlayer, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setPlayerLevel ( thePlayer, theLEvel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerEXP ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local myExp = exports.exp_system:getPlayerEXP ( thePlayer )<br />
outputChatBox ( "Your experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setPlayerEXP ( thePlayer, theExp )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to give a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool addPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you to give the experience.<br />
*'''theExperience''': The exprience you want to give.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was given successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addEvent ( "onZombieWasted", true )<br />
addEventHandler ( "onZombieWasted", root,<br />
function ( theKiller )<br />
exports.exp_system:addPlayerEXP ( theKiller, 5 )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountLevel ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the account.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountLevel ( account )<br />
outputChatBox ( "Your account level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountLevel ( account theAccount, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setAccountLevel ( account, theLEvel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountEXP ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountEXP ( account )<br />
outputChatBox ( "Your account experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountEXP ( account theAccount, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setAccountEXP ( account, theExp )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to refresh the levels.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool loadLevelsFromXML( )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''None'''<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "refreshlevels",<br />
function ( )<br />
exports.exp_system:loadLevelsFromXML ( )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to obtain the name and experience required of a level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
getLevelData ( int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theLevel'''<br />
<br />
==Returns==<br />
Returns the name of the level and the experience required.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "getleveldata",<br />
function ( thePlayer )<br />
local level = exprots.exp_system:getPlayerLevel ( thePlayer )<br />
local name, expreq = exports.exp_system:getLevelData ( level )<br />
outputChatBox ( name ..": ".. expreq, thePlayer )<br />
end<br />
)<br />
</section><br />
<br />
=Custom Events=<br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level changes.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerChangeLevel<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] whose level changed.<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level UP.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerLevelUP<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] who leveled UP.<br />
</section><br />
<br />
=See also=<br />
[http://community.mtasa.com/index.php?p=resources&s=details&id=1253 Download page]<br><br />
<br />
[[Category:Resource]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=DxDrawGifImage&diff=33947DxDrawGifImage2012-11-03T16:34:24Z<p>Castillo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function simulates the effect of a GIF image by using image sprites.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">element dxDrawGifImage ( float x, float y, float width, float height, string path, float startImageID, string fileExtension, float effectSpeed )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''x:''' A float of the 2D x position of the GUI button on a player's screen.<br />
*'''y:''' A float of the 2D y position of the GUI button on a player's screen.<br />
*'''width:''' A float of the width of the GUI button.<br />
*'''height:''' A float of the height of the GUI button.<br />
*'''path:''' The filepath of the image files will be loaded. A "%s" is required to denote where the "id" is placed.<br />
"%snyancat.png" would be read as "1nyancat.png" "2nyancat.png" etc<br />
"a%sbcdefghe" would read the images "a1sbcdefghe" "a2sbcdefghe" "a3sbcdefghe" etc.<br />
<br />
*'''startImageID:''' The image ID that will be loaded in the first place.<br />
*'''fileExtension:''' The image extension ( e.g: png, jpg, etc. ).<br />
*'''effectSpeed:''' The speed between the change of the images.<br />
<br />
==Code==<br />
<section name="Clientside Script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function dxDrawGifImage ( x, y, w, h, path, iStart, iType, effectSpeed )<br />
local gifElement = createElement ( "dx-gif" )<br />
if ( gifElement ) then<br />
setElementData (<br />
gifElement,<br />
"gifData",<br />
{<br />
x = x,<br />
y = y,<br />
w = w,<br />
h = h,<br />
imgPath = path,<br />
startID = iStart,<br />
imgID = iStart,<br />
imgType = iType,<br />
speed = effectSpeed,<br />
tick = getTickCount ( )<br />
}<br />
)<br />
return gifElement<br />
else<br />
return false<br />
end<br />
end<br />
<br />
addEventHandler ( "onClientRender", root,<br />
function ( )<br />
local currentTick = getTickCount ( )<br />
for index, gif in ipairs ( getElementsByType ( "dx-gif" ) ) do<br />
local gifData = getElementData ( gif, "gifData" )<br />
if ( gifData ) then<br />
if ( currentTick - gifData.tick >= gifData.speed ) then<br />
gifData.tick = currentTick<br />
gifData.imgID = ( gifData.imgID + 1 )<br />
if ( fileExists ( gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) ) then<br />
gifData.imgID = gifData.imgID<br />
setElementData ( gif, "gifData", gifData )<br />
else<br />
gifData.imgID = gifData.startID<br />
setElementData ( gif, "gifData", gifData )<br />
end<br />
end<br />
dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType )<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example will create a "gif" image and a command to destroy it.<br />
<syntaxhighlight lang="lua"><br />
gif = dxDrawGifImage ( 769, 175, 193, 145, "images/flag_arg", 0, "png", 120 )<br />
<br />
addCommandHandler ( "destroygif",<br />
function ( )<br />
destroyElement ( gif )<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: Castillo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_world_functions&diff=33137Template:Client world functions2012-09-04T04:47:31Z<p>Castillo: </p>
<hr />
<div>* [[areTrafficLightsLocked]]<br />
* [[getAircraftMaxHeight]]<br />
* [[getCloudsEnabled]]<br />
* [[getGameSpeed]]<br />
* [[getGravity]]<br />
* [[getGroundPosition]]<br />
* [[getHeatHaze]]<br />
* [[getJetpackMaxHeight]]<br />
* [[getScreenFromWorldPosition]]<br />
* [[getTime]]<br />
* [[getTrafficLightState]]<br />
* [[getWeather]]<br />
* [[getWindVelocity]]<br />
* [[getWorldFromScreenPosition]]<br />
* [[getZoneName]]<br />
* [[isLineOfSightClear]]<br />
* [[processLineOfSight]]<br />
* [[resetHeatHaze]]<br />
* [[resetSkyGradient]]<br />
* [[resetWindVelocity]]<br />
* [[setAircraftMaxHeight]]<br />
* [[setCloudsEnabled]]<br />
* [[setGameSpeed]]<br />
* [[setGravity]]<br />
* [[setHeatHaze]]<br />
* [[setSkyGradient]]<br />
* [[setTime|setTime]]<br />
* [[setTrafficLightState]]<br />
* [[setTrafficLightsLocked]]<br />
* [[setWeather]]<br />
* [[setWeatherBlended]]<br />
* [[setWindVelocity]]<br />
* [[testLineAgainstWater]]<br />
* [[getGarageBoundingBox]]<br />
* [[getGaragePosition]]<br />
* [[getGarageSize]]<br />
* [[getMinuteDuration]]<br />
* [[getPlayerBlurLevel]]<br />
* [[isGarageOpen]]<br />
* [[isWorldSpecialPropertyEnabled]]<br />
* [[setCloudsEnabled]]<br />
* [[setGarageOpen]]<br />
* [[setJetpackMaxHeight]]<br />
* [[setMinuteDuration]]<br />
* [[setPlayerBlurLevel]]<br />
* [[setWorldSpecialPropertyEnabled]]<br />
* [[setAmbientSoundEnabled]]<br />
* [[isAmbientSoundEnabled]]<br />
* [[resetAmbientSounds]]<br />
* [[setWorldSoundEnabled]]<br />
* [[isWorldSoundEnabled]]<br />
* [[resetWorldSounds]]<br />
* [[setInteriorSoundsEnabled]]<br />
* [[getInteriorSoundsEnabled]]<br />
* [[setRainLevel]]<br />
* [[getRainLevel]]<br />
* [[resetRainLevel]]<br />
* [[setSunSize]]<br />
* [[getSunSize]]<br />
* [[resetSunSize]]<br />
* [[setSunColor]]<br />
* [[getSunColor]]<br />
* [[resetSunColor]]<br />
* [[setFarClipDistance]]<br />
* [[getFarClipDistance]]<br />
* [[resetFarClipDistance]]<br />
* [[setFogDistance]]<br />
* [[getFogDistance]]<br />
* [[resetFogDistance]]<br />
* [[createSWATRope]]<br />
* [[removeWorldModel]]<br />
* [[restoreWorldModel]]<br />
* [[restoreAllWorldModels]]<br />
* [[setOcclusionsEnabled]]<br />
* [[getOcclusionsEnabled]]<br />
* [[setBirdsEnabled]]<br />
* [[getBirdsEnabled]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_weapon_creation_functions&diff=33136Template:Client weapon creation functions2012-09-04T04:46:48Z<p>Castillo: </p>
<hr />
<div>*[[createWeapon]]<br />
*[[fireWeapon]]<br />
*[[getWeaponProperty]]<br />
*[[getWeaponState]]<br />
*[[getWeaponTarget]]<br />
*[[getWeaponOwner]]<br />
*[[getWeaponFlags]]<br />
*[[getWeaponFiringRate]]<br />
*[[getWeaponAmmo]]<br />
*[[getWeaponClipAmmo]]<br />
*[[resetWeaponFiringRate]]<br />
*[[setWeaponProperty]]<br />
*[[setWeaponState]]<br />
*[[setWeaponTarget]]<br />
*[[setWeaponOwner]]<br />
*[[setWeaponFlags]]<br />
*[[setWeaponFiringRate]]<br />
*[[setWeaponAmmo]]<br />
*[[setWeaponClipAmmo]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_vehicle_functions&diff=33135Template:Client vehicle functions2012-09-04T04:46:12Z<p>Castillo: </p>
<hr />
<div>*[[addVehicleUpgrade]]<br />
*[[attachTrailerToVehicle]]<br />
*[[blowVehicle]]<br />
*[[createVehicle]]<br />
*[[detachTrailerFromVehicle]]<br />
*[[fixVehicle]]<br />
*[[getVehicleAdjustableProperty]]<br />
*[[getVehicleColor]]<br />
*[[getVehicleCompatibleUpgrades]]<br />
*[[getVehicleController]]<br />
*[[getVehicleDoorState]]<br />
*[[getVehicleEngineState]]<br />
*[[getVehicleLandingGearDown]]<br />
*[[getVehicleLightState]]<br />
*[[getVehicleMaxPassengers]]<br />
*[[getVehicleName]]<br />
*[[getVehicleOccupant]]<br />
*[[getVehicleOccupants]]<br />
*[[getVehicleCurrentGear]]<br />
*[[getVehicleOverrideLights]]<br />
*[[getVehiclePaintjob]]<br />
*[[getVehiclePanelState]]<br />
*[[getVehiclePlateText]]<br />
*[[getVehicleSirensOn]]<br />
*[[getVehicleTowedByVehicle]]<br />
*[[getVehicleTowingVehicle]]<br />
*[[getVehicleTurnVelocity]]<br />
*[[getVehicleTurretPosition]]<br />
*[[getVehicleUpgradeOnSlot]]<br />
*[[getVehicleUpgrades]]<br />
*[[getVehicleUpgradeSlotName]]<br />
*[[getVehicleWheelStates]]<br />
*[[getVehicleDoorOpenRatio]]<br />
*[[getVehicleHandling]]<br />
*[[getOriginalHandling]]<br />
*[[isVehicleDamageProof]]<br />
*[[isVehicleFrozen]]<br />
*[[isVehicleFuelTankExplodable]]<br />
*[[isVehicleLocked]]<br />
*[[isVehicleOnGround]]<br />
*[[removeVehicleUpgrade]]<br />
*[[setVehicleAdjustableProperty]]<br />
*[[setVehicleColor]]<br />
*[[setVehicleDamageProof]]<br />
*[[setVehicleDirtLevel]]<br />
*[[setVehicleDoorState]]<br />
*[[setVehicleDoorsUndamageable]]<br />
*[[setVehicleEngineState]]<br />
*[[setVehicleFrozen]]<br />
*[[setVehicleFuelTankExplodable]]<br />
*[[setVehicleLandingGearDown]]<br />
*[[setVehicleLightState]]<br />
*[[setVehicleLocked]]<br />
*[[setVehicleOverrideLights]]<br />
*[[setVehiclePaintjob]]<br />
*[[setVehiclePanelState]]<br />
*[[setVehicleSirensOn]]<br />
*[[setVehicleTurretPosition]]<br />
*[[setVehicleDoorOpenRatio]]<br />
*[[setVehicleTurnVelocity]]<br />
*[[setVehicleWheelStates]]<br />
*[[getHelicopterRotorSpeed]]<br />
*[[getTrainDirection]]<br />
*[[getTrainSpeed]]<br />
*[[getVehicleGravity]]<br />
*[[getVehicleHeadLightColor]]<br />
*[[getVehicleModelFromName]]<br />
*[[getVehicleNameFromModel]]<br />
*[[getVehicleType]]<br />
*[[isTrainDerailable]]<br />
*[[isTrainDerailed]]<br />
*[[isVehicleBlown]]<br />
*[[isVehicleTaxiLightOn]]<br />
*[[setHelicopterRotorSpeed]]<br />
*[[setTrainDerailable]]<br />
*[[setTrainDerailed]]<br />
*[[setTrainDirection]]<br />
*[[setTrainSpeed]]<br />
*[[setVehicleGravity]]<br />
*[[setVehicleHeadLightColor]]<br />
*[[setVehicleTaxiLightOn]]<br />
*[[getVehicleVariant]]<br />
*[[getVehicleSirenParams]]<br />
*[[getVehicleSirens]]<br />
*[[setVehicleSirens]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_projectile_functions&diff=33134Template:Client projectile functions2012-09-04T04:45:23Z<p>Castillo: </p>
<hr />
<div>*[[createProjectile]]<br />
*[[getProjectileCreator]]<br />
*[[getProjectileForce]]<br />
*[[getProjectileTarget]]<br />
*[[getProjectileType]]<br />
*[[detonateSatchels]]<br />
*[[getProjectileCounter]]<br />
*[[setProjectileCounter]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_ped_functions&diff=33133Template:Client ped functions2012-09-04T04:44:37Z<p>Castillo: </p>
<hr />
<div>{{New items|3|1.0|<br />
*[[canPedBeKnockedOffBike]]<br />
*[[createPed]]<br />
*[[doesPedHaveJetPack]]<br />
*[[getPedAmmoInClip]]<br />
*[[getPedAnimation]]<br />
*[[getPedAnimationData]]<br />
*[[getPedArmor]]<br />
*[[getPedBonePosition]]<br />
*[[getPedClothes]]<br />
*[[getPedContactElement]]<br />
*[[getPedControlState]]<br />
{{New items|3.0110|1.1|<br />
*[[getPedMoveState]]<br />
}}<br />
*[[getPedOccupiedVehicle]]<br />
*[[getPedSimplestTask]]<br />
*[[getPedSkin]]<br />
*[[getPedStat]]<br />
*[[getPedTarget]]<br />
*[[getPedTargetCollision]]<br />
*[[getPedTargetEnd]]<br />
*[[getPedTargetStart]]<br />
*[[getPedTask]]<br />
*[[getPedTotalAmmo]]<br />
*[[getPedVoice]]<br />
*[[getPedWeapon]]<br />
*[[getPedWeaponMuzzlePosition]]<br />
*[[getPedWeaponSlot]]<br />
*[[isPedChoking]]<br />
*[[isPedDoingGangDriveby]]<br />
*[[isPedDoingTask]]<br />
*[[isPedDucked]]<br />
*[[isPedFrozen]]<br />
*[[isPedHeadless]]<br />
*[[isPedInVehicle]]<br />
*[[isPedInWater]]<br />
*[[isPedOnFire]]<br />
*[[isPedOnGround]]<br />
*[[setPedAimTarget]]<br />
*[[setPedAnalogControlState]]<br />
*[[setPedAnimation]]<br />
*[[setPedCameraRotation]]<br />
*[[setPedCanBeKnockedOffBike]]<br />
*[[setPedControlState]]<br />
*[[setPedDoingGangDriveby]]<br />
*[[setPedFrozen]]<br />
*[[setPedHeadless]]<br />
*[[setPedLookAt]]<br />
*[[setPedOnFire]]<br />
*[[setPedSkin]]<br />
*[[setPedVoice]]<br />
*[[setPedWeaponSlot]]<br />
*[[setPedFootBloodEnabled]]<br />
}}<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Drawing_functions&diff=33132Template:Drawing functions2012-09-04T04:43:49Z<p>Castillo: </p>
<hr />
<div>*[[dxDrawImage]]<br />
*[[dxDrawImageSection]]<br />
*[[dxDrawLine]]<br />
*[[dxDrawLine3D]]<br />
*[[dxDrawRectangle]]<br />
*[[dxDrawText]]<br />
*[[dxGetFontHeight]]<br />
*[[dxGetTextWidth]]<br />
*[[dxCreateFont]]<br />
*[[dxCreateTexture]]<br />
*[[dxCreateShader]]<br />
*[[dxCreateRenderTarget]]<br />
*[[dxCreateScreenSource]]<br />
*[[dxGetMaterialSize]]<br />
*[[dxSetShaderValue]]<br />
*[[dxSetShaderTessellation]]<br />
*[[dxSetShaderTransform]]<br />
*[[dxSetRenderTarget]]<br />
*[[dxUpdateScreenSource]]<br />
*[[dxGetStatus]]<br />
*[[dxSetTestMode]]<br />
{{New items|3.0130|1.3|<br />
* [[dxGetTexturePixels]]<br />
* [[dxSetTexturePixels]]<br />
* [[dxGetPixelsSize]]<br />
* [[dxGetPixelsFormat]]<br />
* [[dxConvertPixels]]<br />
* [[dxGetPixelColor]]<br />
* [[dxSetPixelColor]]<br />
}}<br />
* [[dxSetBlendMode]]<br />
* [[dxGetBlendMode]]<br />
* [[dxDrawMaterialLine3D]]<br />
* [[dxDrawMaterialSectionLine3D]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_object_functions&diff=33131Template:Client object functions2012-09-04T04:42:37Z<p>Castillo: </p>
<hr />
<div>*[[createObject]]<br />
*[[moveObject]]<br />
*[[setObjectScale]]<br />
*[[stopObject]]<br />
{{New items|3|1.0|<br />
*[[isObjectStatic]]<br />
*[[setObjectStatic]]<br />
}}<br />
*[[isObjectBreakable]]<br />
*[[setObjectBreakable]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_event_functions&diff=33130Template:Client event functions2012-09-04T04:42:08Z<p>Castillo: </p>
<hr />
<div>* [[addEvent]]<br />
* [[addEventHandler]]<br />
* [[cancelEvent]]<br />
* [[removeEventHandler]]<br />
* [[triggerEvent]]<br />
* [[triggerServerEvent]]<br />
* [[wasEventCanceled]]<br />
* [[triggerLatentServerEvent]]<br />
* [[getLatentEventHandles]]<br />
* [[getLatentEventStatus]]<br />
* [[cancelLatentEvent]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Client_audio_functions&diff=33129Template:Client audio functions2012-09-04T04:41:27Z<p>Castillo: </p>
<hr />
<div>*[[playSoundFrontEnd]]<br />
*[[getRadioChannel]]<br />
*[[getRadioChannelName]]<br />
{{New items|3.0110|1.1|<br />
*[[getSoundEffects]]<br />
}}<br />
*[[getSoundLength]]<br />
*[[getSoundMaxDistance]]<br />
{{New items|3.0110|1.1|<br />
*[[getSoundMetaTags]]<br />
}}<br />
*[[getSoundMinDistance]]<br />
*[[getSoundPosition]]<br />
*[[getSoundSpeed]]<br />
*[[getSoundVolume]]<br />
{{New items|3.0110|1.1|<br />
*[[setSoundEffectEnabled]]<br />
}}<br />
*[[isSoundPaused]]<br />
*[[playSound]]<br />
*[[playSound3D]]<br />
*[[setRadioChannel]]<br />
*[[setSoundMaxDistance]]<br />
*[[setSoundMinDistance]]<br />
*[[setSoundPaused]]<br />
*[[setSoundPosition]]<br />
*[[setSoundSpeed]]<br />
*[[setSoundVolume]]<br />
*[[stopSound]]<br />
*[[getSoundBPM]]<br />
*[[getSoundProperties]]<br />
*[[setSoundProperties]]<br />
*[[getSoundFFTData]]<br />
*[[getSoundWaveData]]<br />
*[[getSoundLevelData]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=31456Template:Useful Functions2012-06-18T05:18:50Z<p>Castillo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
<br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
<br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
<br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
<br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
<br />
*[[doForAllElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function can be used to execute a specified function for all elements of a specified type.</span><br />
<br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
<br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
<br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
<br />
*[[getAge]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
<br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
<br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
<br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
<br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
<br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
<br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
<br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the [http://en.wikipedia.org/wiki/Unix_time UNIX timestamp].</span><br />
<br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
<br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
<br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
<br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
<br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
<br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
<br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
<br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
<br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
<br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
<br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
<br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
<br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
<br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
<br />
*[[var_dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">»This function outputs information about one or more variables using outputConsole(). </span><br />
<br />
*[[multi_check]] <span style="color: gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean. </span><br />
<br />
*[[isElementInPhotograph]] <span style="color: gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture. This needs writing still. --[[User:Ransom|Ransom]] 21:45, 2 May 2012 (UTC) </span><br />
<br />
*[[getOffsetFromXYZ]] <span style="color: gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations. </span><br />
<br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites.</span><br />
[[Category:Useful Functions]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=DxDrawGifImage&diff=31455DxDrawGifImage2012-06-18T05:18:44Z<p>Castillo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function simulates the effect of a GIF image by using image sprites.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">element dxDrawGifImage ( float x, float y, float width, float height, string path, float startImageID, string imageType, float effectSpeed )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''x:''' A float of the 2D x position of the GUI button on a player's screen.<br />
*'''y:''' A float of the 2D y position of the GUI button on a player's screen.<br />
*'''width:''' A float of the width of the GUI button.<br />
*'''height:''' A float of the height of the GUI button.<br />
*'''path:''' The filepath of the image files will be loaded.<br />
*'''startID:''' The image ID that will be loaded.<br />
*'''type:''' The type of the image ( e.g: png, jpg ).<br />
*'''effectSpeed:''' The speed between the change of the images.<br />
<br />
===Optional Arguments===<br />
<br />
==Code==<br />
<section name="Clientside Script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function dxDrawGifImage ( x, y, w, h, path, iStart, iType, effectSpeed )<br />
local gifElement = createElement ( "dx-gif" )<br />
if ( gifElement ) then<br />
setElementData (<br />
gifElement,<br />
"gifData",<br />
{<br />
x = x,<br />
y = y,<br />
w = w,<br />
h = h,<br />
imgPath = path,<br />
startID = iStart,<br />
imgID = iStart,<br />
imgType = iType,<br />
speed = effectSpeed,<br />
tick = getTickCount ( )<br />
}<br />
)<br />
return gifElement<br />
else<br />
return false<br />
end<br />
end<br />
<br />
addEventHandler ( "onClientRender", root,<br />
function ( )<br />
local currentTick = getTickCount ( )<br />
for index, gif in ipairs ( getElementsByType ( "dx-gif" ) ) do<br />
local gifData = getElementData ( gif, "gifData" )<br />
if ( gifData ) then<br />
if ( currentTick - gifData.tick >= gifData.speed ) then<br />
gifData.tick = currentTick<br />
gifData.imgID = ( gifData.imgID + 1 )<br />
if ( fileExists ( gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) ) then<br />
gifData.imgID = gifData.imgID<br />
setElementData ( gif, "gifData", gifData )<br />
else<br />
gifData.imgID = gifData.startID<br />
setElementData ( gif, "gifData", gifData )<br />
end<br />
end<br />
dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType )<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example will create a "gif" image and a command to destroy it.<br />
<syntaxhighlight lang="lua"><br />
gif = dxDrawGifImage ( 769, 175, 193, 145, "images/flag_arg", 0, "png", 120 )<br />
<br />
addCommandHandler ( "destroygif",<br />
function ( )<br />
destroyElement ( gif )<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: Castillo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=31454Template:Useful Functions2012-06-18T05:18:16Z<p>Castillo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
<br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
<br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
<br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
<br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
<br />
*[[doForAllElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function can be used to execute a specified function for all elements of a specified type.</span><br />
<br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
<br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
<br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
<br />
*[[getAge]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
<br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
<br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
<br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
<br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
<br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
<br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
<br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the [http://en.wikipedia.org/wiki/Unix_time UNIX timestamp].</span><br />
<br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
<br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
<br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
<br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
<br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
<br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
<br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
<br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
<br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
<br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
<br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
<br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
<br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
<br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
<br />
*[[var_dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">»This function outputs information about one or more variables using outputConsole(). </span><br />
<br />
*[[multi_check]] <span style="color: gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean. </span><br />
<br />
*[[isElementInPhotograph]] <span style="color: gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture. This needs writing still. --[[User:Ransom|Ransom]] 21:45, 2 May 2012 (UTC) </span><br />
<br />
*[[getOffsetFromXYZ]] <span style="color: gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations. </span><br />
<br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function simulates the effect of a GIF image by using the image sprites.</span><br />
[[Category:Useful Functions]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=31451Template:Useful Functions2012-06-18T01:07:00Z<p>Castillo: </p>
<hr />
<div>*[[callClientFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any clientside function from the server's side.</span><br />
<br />
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
<br />
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span><br />
<br />
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span><br />
<br />
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span><br />
<br />
*[[doForAllElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function can be used to execute a specified function for all elements of a specified type.</span><br />
<br />
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span><br />
<br />
*[[findRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Takes two points and returns the direction from point A to point B.</span><br />
<br />
*[[FormatDate]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Formats a date on the basis of a format string and returns it.</span><br />
<br />
*[[getAge]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span><br />
<br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
<br />
*[[getCursorMoveOn]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
<br />
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span><br />
<br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span><br />
<br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span><br />
<br />
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
<br />
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the [http://en.wikipedia.org/wiki/Unix_time UNIX timestamp].</span><br />
<br />
*[[IfElse]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns one of two values based on a boolean expression.</span><br />
<br />
*[[isLeapYear]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Checks if the given year is a leap year.</span><br />
<br />
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span><br />
<br />
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
<br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span><br />
<br />
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
<br />
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span><br />
<br />
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span><br />
<br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
<br />
*[[string.explode]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
<br />
*[[table.copy]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
<br />
*[[table.map]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
<br />
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span><br />
<br />
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span><br />
<br />
*[[var_dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">»This function outputs information about one or more variables using outputConsole(). </span><br />
<br />
*[[multi_check]] <span style="color: gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks one element to many, handy and clean. </span><br />
<br />
*[[isElementInPhotograph]] <span style="color: gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if an element was in the player's camera picture. This needs writing still. --[[User:Ransom|Ransom]] 21:45, 2 May 2012 (UTC) </span><br />
<br />
*[[getOffsetFromXYZ]] <span style="color: gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations. </span><br />
<br />
*[[dxDrawGifImage]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
[[Category:Useful Functions]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=DxDrawGifImage&diff=31450DxDrawGifImage2012-06-18T01:00:12Z<p>Castillo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function simulates the effect of a GIF image by using the image sprites.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">element dxDrawGifImage ( float x, float y, float width, float height, string path, float startImageID, string imageType, float effectSpeed )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''x:''' A float of the 2D x position of the GUI button on a player's screen.<br />
*'''y:''' A float of the 2D y position of the GUI button on a player's screen.<br />
*'''width:''' A float of the width of the GUI button.<br />
*'''height:''' A float of the height of the GUI button.<br />
*'''path:''' The filepath of the image files will be loaded.<br />
*'''startID:''' The image ID that will be loaded.<br />
*'''type:''' The type of the image ( e.g: png, jpg ).<br />
*'''effectSpeed:''' The speed between the change of the images.<br />
<br />
===Optional Arguments===<br />
<br />
==Code==<br />
<section name="Clientside Script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function dxDrawGifImage ( x, y, w, h, path, iStart, iType, effectSpeed )<br />
local gifElement = createElement ( "dx-gif" )<br />
if ( gifElement ) then<br />
setElementData (<br />
gifElement,<br />
"gifData",<br />
{<br />
x = x,<br />
y = y,<br />
w = w,<br />
h = h,<br />
imgPath = path,<br />
startID = iStart,<br />
imgID = iStart,<br />
imgType = iType,<br />
speed = effectSpeed,<br />
tick = getTickCount ( )<br />
}<br />
)<br />
return gifElement<br />
else<br />
return false<br />
end<br />
end<br />
<br />
addEventHandler ( "onClientRender", root,<br />
function ( )<br />
local currentTick = getTickCount ( )<br />
for index, gif in ipairs ( getElementsByType ( "dx-gif" ) ) do<br />
local gifData = getElementData ( gif, "gifData" )<br />
if ( gifData ) then<br />
if ( currentTick - gifData.tick >= gifData.speed ) then<br />
gifData.tick = currentTick<br />
gifData.imgID = ( gifData.imgID + 1 )<br />
if ( fileExists ( gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) ) then<br />
gifData.imgID = gifData.imgID<br />
setElementData ( gif, "gifData", gifData )<br />
else<br />
gifData.imgID = gifData.startID<br />
setElementData ( gif, "gifData", gifData )<br />
end<br />
end<br />
dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType )<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example will create a "gif" image and a command to destroy it.<br />
<syntaxhighlight lang="lua"><br />
gif = dxDrawGifImage ( 769, 175, 193, 145, "images/flag_arg", 0, "png", 120 )<br />
<br />
addCommandHandler ( "destroygif",<br />
function ( )<br />
destroyElement ( gif )<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: Castillo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=DxDrawGifImage&diff=31449DxDrawGifImage2012-06-18T00:58:47Z<p>Castillo: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function simulates the effect of a GIF image by using the image sprites.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">element dxDrawGifImage ( float x, float y, float width, float height, string name, float startImageID, string imageType, float effectSpeed )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''x:''' A float of the 2D x position of the GUI button on a player's screen.<br />
*'''y:''' A float of the 2D y position of the GUI button on a player's screen.<br />
*'''width:''' A float of the width of the GUI button.<br />
*'''height:''' A float of the height of the GUI button.<br />
*'''path:''' The filepath of the image files will be loaded.<br />
*'''startID:''' The image ID that will be loaded.<br />
*'''type:''' The type of the image ( e.g: png, jpg ).<br />
*'''effectSpeed:''' The speed between the change of the images.<br />
<br />
===Optional Arguments===<br />
<br />
==Code==<br />
<section name="Clientside Script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function dxDrawGifImage ( x, y, w, h, path, iStart, iType, effectSpeed )<br />
local gifElement = createElement ( "dx-gif" )<br />
if ( gifElement ) then<br />
setElementData (<br />
gifElement,<br />
"gifData",<br />
{<br />
x = x,<br />
y = y,<br />
w = w,<br />
h = h,<br />
imgPath = path,<br />
startID = iStart,<br />
imgID = iStart,<br />
imgType = iType,<br />
speed = effectSpeed,<br />
tick = getTickCount ( )<br />
}<br />
)<br />
return gifElement<br />
else<br />
return false<br />
end<br />
end<br />
<br />
addEventHandler ( "onClientRender", root,<br />
function ( )<br />
local currentTick = getTickCount ( )<br />
for index, gif in ipairs ( getElementsByType ( "dx-gif" ) ) do<br />
local gifData = getElementData ( gif, "gifData" )<br />
if ( gifData ) then<br />
if ( currentTick - gifData.tick >= gifData.speed ) then<br />
gifData.tick = currentTick<br />
gifData.imgID = ( gifData.imgID + 1 )<br />
if ( fileExists ( gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) ) then<br />
gifData.imgID = gifData.imgID<br />
setElementData ( gif, "gifData", gifData )<br />
else<br />
gifData.imgID = gifData.startID<br />
setElementData ( gif, "gifData", gifData )<br />
end<br />
end<br />
dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType )<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example will create a "gif" image and a command to destroy it.<br />
<syntaxhighlight lang="lua"><br />
gif = dxDrawGifImage ( 769, 175, 193, 145, "images/flag_arg", 0, "png", 120 )<br />
<br />
addCommandHandler ( "destroygif",<br />
function ( )<br />
destroyElement ( gif )<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: Castillo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=DxDrawGifImage&diff=31448DxDrawGifImage2012-06-18T00:53:52Z<p>Castillo: Created page with "{{Useful Function}} <lowercasetitle></lowercasetitle> __NOTOC__ This function simulates the effect of a GIF image. ==Syntax== <syntaxhighlight lang="lua">element dxDrawGifImage ( float x, floa..."</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function simulates the effect of a GIF image.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">element dxDrawGifImage ( float x, float y, float width, float height, string name, float startImageID, string imageType, float effectSpeed )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''x:''' A float of the 2D x position of the GUI button on a player's screen.<br />
*'''y:''' A float of the 2D y position of the GUI button on a player's screen.<br />
*'''width:''' A float of the width of the GUI button.<br />
*'''height:''' A float of the height of the GUI button.<br />
*'''path:''' The filepath of the image files will be loaded.<br />
*'''startID:''' The image ID that will be loaded.<br />
*'''type:''' The type of the image ( e.g: png, jpg ).<br />
*'''effectSpeed:''' The speed between the change of the images.<br />
<br />
===Optional Arguments===<br />
<br />
==Code==<br />
<section name="Clientside Script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function dxDrawGifImage ( x, y, w, h, path, iStart, iType, effectSpeed )<br />
local gifElement = createElement ( "dx-gif" )<br />
if ( gifElement ) then<br />
setElementData (<br />
gifElement,<br />
"gifData",<br />
{<br />
x = x,<br />
y = y,<br />
w = w,<br />
h = h,<br />
imgPath = path,<br />
startID = iStart,<br />
imgID = iStart,<br />
imgType = iType,<br />
speed = effectSpeed,<br />
tick = getTickCount ( )<br />
}<br />
)<br />
return gifElement<br />
else<br />
return false<br />
end<br />
end<br />
<br />
addEventHandler ( "onClientRender", root,<br />
function ( )<br />
local currentTick = getTickCount ( )<br />
for index, gif in ipairs ( getElementsByType ( "dx-gif" ) ) do<br />
local gifData = getElementData ( gif, "gifData" )<br />
if ( gifData ) then<br />
if ( currentTick - gifData.tick >= gifData.speed ) then<br />
gifData.tick = currentTick<br />
gifData.imgID = ( gifData.imgID + 1 )<br />
if ( fileExists ( gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) ) then<br />
gifData.imgID = gifData.imgID<br />
setElementData ( gif, "gifData", gifData )<br />
else<br />
gifData.imgID = gifData.startID<br />
setElementData ( gif, "gifData", gifData )<br />
end<br />
end<br />
dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType )<br />
end<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Client" class="client" show="true"><br />
This example will create a "gif" image and a command to destroy it.<br />
<syntaxhighlight lang="lua"><br />
gif = dxDrawGifImage ( 769, 175, 193, 145, "images/flag_arg", 0, "png", 120 )<br />
<br />
addCommandHandler ( "destroygif",<br />
function ( )<br />
destroyElement ( gif )<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: Castillo<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=SetRadarAreaSize&diff=31310SetRadarAreaSize2012-06-03T03:30:01Z<p>Castillo: /* Example */</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function changes the size of an existing [[radararea|radar area]].<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool setRadarAreaSize ( radararea theRadararea, float x, float y )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''theRadararea:''' the [[radararea]] element whose size is to be changed.<br />
*'''x:''' the x length of the radar area.<br />
*'''y:''' the y length of the radar area.<br />
<br />
===Returns===<br />
Returns ''true'' if the size was set successfully, ''false'' if invalid arguments are passed.<br />
<br />
==Example== <br />
'''Example 1:''' This example decreases the size of a team's radar area whenever a player from that team dies:<br />
<syntaxhighlight lang="lua"><br />
-- assume that team elements exist and that each player belongs to one of them<br />
-- assume that radararea elements exist and that each is a child of one of the teams<br />
function playerWasted ( killer, killerweapon, bodypart )<br />
local victimteam = getPlayerTeam ( source ) -- get the team of the victim<br />
local killerteam = getPlayerTeam ( killer ) -- get the team of the killer<br />
if ( killer and killerteam ~= victimteam ) then -- if there is a killer and he is from an opposing team<br />
local victimarea = getElementChild ( victimteam, 0 ) -- get the radararea belonging to the victim's team<br />
local x, y = getRadarAreaSize ( victimarea ) -- get the size of the radar area<br />
x = x - 5<br />
y = y - 5<br />
setRadarAreaSize ( victimarea, x, y ) -- set a new (smaller) size for the victim's radar area<br />
end<br />
end<br />
addEventHandler ( "onPlayerWasted", root, playerWasted )<br />
</syntaxhighlight><br />
'''Example 2:''' This example creates a radar area and resets its size right away:<br />
<syntaxhighlight lang="lua"><br />
aRadarArea = createRadarArea ( 1024, 1024, 30, 140, 255, 255, 0, 85 )<br />
flag = setRadarAreaSize ( aRadarArea, 50, 90 )<br />
if ( flag ) then<br />
outputChatBox ( "Radar area size set successfully!" )<br />
else<br />
outputChatBox ( "Failed to set radar area size." )<br />
end<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Radar area_functions}}</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Resource:Exp_system&diff=30179Resource:Exp system2012-04-29T02:59:33Z<p>Castillo: </p>
<hr />
<div>{{Resource page}}<br />
A level/experience system made from scratch by [[User:Castillo|Castillo]].<br><br />
It uses SQLite to save level and experience.<br />
<br />
=Exported Functions=<br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerLevel ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the player.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local myExp = exports.exp_system:getPlayerLevel ( thePlayer )<br />
outputChatBox ( "Your level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerLevel ( player thePlayer, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setPlayerLevel ( thePlayer, theLEvel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerEXP ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local myExp = exports.exp_system:getPlayerEXP ( thePlayer )<br />
outputChatBox ( "Your experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setPlayerEXP ( thePlayer, theExp )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to give a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool addPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you to give the experience.<br />
*'''theExperience''': The exprience you want to give.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was given successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addEvent ( "onZombieWasted", true )<br />
addEventHandler ( "onZombieWasted", root,<br />
function ( theKiller )<br />
exports.exp_system:addPlayerEXP ( theKiller, 5 )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountLevel ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the account.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountLevel ( account )<br />
outputChatBox ( "Your account level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountLevel ( account theAccount, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setAccountLevel ( account, theLEvel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountEXP ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountEXP ( account )<br />
outputChatBox ( "Your account experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountEXP ( account theAccount, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setAccountEXP ( account, theExp )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to refresh the levels.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool loadLevelsFromXML( )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''None'''<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "refreshlevels",<br />
function ( )<br />
exports.exp_system:loadLevelsFromXML ( )<br />
end<br />
)<br />
</section><br />
<br />
=Custom Events=<br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level changes.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerChangeLevel<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] whose level changed.<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level UP.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerLevelUP<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] who leveled UP.<br />
</section><br />
<br />
=See also=<br />
[http://community.mtasa.com/index.php?p=resources&s=details&id=1253 Download page]<br><br />
<br />
[[Category:Resource]]</div>Castillohttps://wiki.multitheftauto.com/index.php?title=Resource:Exp_system&diff=29978Resource:Exp system2012-04-17T19:09:08Z<p>Castillo: </p>
<hr />
<div>{{Resource page}}<br />
A level/experience system made from scratch by [[User:Castillo|Castillo]].<br><br />
It uses SQLite to save level and experience.<br />
<br />
=Exported Functions=<br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerLevel ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the player.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local myExp = exports.exp_system:getPlayerLevel ( thePlayer )<br />
outputChatBox ( "Your level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerLevel ( player thePlayer, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setPlayerLevel ( thePlayer, theLEvel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getPlayerEXP ( player thePlayer )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local myExp = exports.exp_system:getPlayerEXP ( thePlayer )<br />
outputChatBox ( "Your experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setPlayerEXP ( thePlayer, theExp )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to give a player experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool addPlayerEXP ( player thePlayer, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''thePlayer''': The player element you wish you to give the experience.<br />
*'''theExperience''': The exprience you want to give.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was given successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addEvent ( "onZombieWasted", true )<br />
addEventHandler ( "onZombieWasted", root,<br />
function ( theKiller )<br />
exports.exp_system:addPlayerEXP ( theKiller, 5 )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountLevel ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the level.<br />
<br />
==Returns==<br />
Returns a number with with the level of the account.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "mylevel",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountLevel ( account )<br />
outputChatBox ( "Your account level is: ".. myLevel, thePlayer )<br />
end<br />
)<br />
<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account level.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountLevel ( account theAccount, int theLevel )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the level.<br />
*'''theLevel''': The level you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the level was set successfully or not.<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmylevel",<br />
function ( thePlayer, commandName, theLevel )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theLevel = tonumber ( theLevel ) or 1<br />
exports.exp_system:setAccountLevel ( account, theLEvel )<br />
end<br />
)<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This function is used to get an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool getAccountEXP ( account theAccount )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you get the experience.<br />
<br />
==Returns==<br />
Returns a number with with the experience of the player.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "myexp",<br />
function ( thePlayer )<br />
local account = getPlayerAccount ( thePlayer )<br />
local myExp = exports.exp_system:getAccountEXP ( account )<br />
outputChatBox ( "Your account experience is: ".. myExp, thePlayer )<br />
end<br />
)<br />
</section><br />
<section name="Server" class="server" show="true"><br />
This function is used to set an account experience.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setAccountEXP ( account theAccount, int theExperience )<br />
</syntaxhighlight><br />
<br />
==Required Arguments== <br />
*'''theAccount''': The player element you wish you set the experience.<br />
*'''theExperience''': The exprience you want to set.<br />
<br />
==Returns==<br />
Returns a bool, whether the experience was set successfully or not.<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
addCommandHandler ( "setmyexp",<br />
function ( thePlayer, commandName, theExp )<br />
local account = getPlayerAccount ( thePlayer )<br />
local theExp = tonumber ( theExp ) or 0<br />
exports.exp_system:setAccountEXP ( account, theExp )<br />
end<br />
)<br />
</section><br />
<br />
=Custom Events=<br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level changes.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerChangeLevel<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] whose level changed.<br />
</section><br />
<br />
<section name="Server" class="server" show="true"><br />
This event is called when a player level UP.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
event onPlayerLevelUP<br />
</syntaxhighlight><br />
<br />
==Parameters== <br />
*'''oldLevel''': The player old level.<br />
*'''newLevel''': The player new level.<br />
<br />
<!-- Add the event's source in the section below --><br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] who leveled UP.<br />
</section><br />
<br />
=See also=<br />
[http://community.mtasa.com/index.php?p=resources&s=details&id=1253 Download page]<br><br />
<br />
[[Category:Resource]]</div>Castillo