https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=MaddDogg&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-29T01:29:42ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=InterpolateBetween&diff=26457InterpolateBetween2011-08-01T13:45:52Z<p>MaddDogg: Typo</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
<br />
Interpolates a 3D Vector between a source value and a target value using either linear interpolation or any other [[Easing|easing function]].<br />
It can also be used to interpolate 2D vectors or scalars by only setting some of the x, y, z values and putting 0 to the others.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
float float float interpolateBetween ( float x1, float y1, float z1, <br />
float x2, float y2, float z2, <br />
float fProgress, string strEasingType, <br />
[ float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot ] )<br />
</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''x1, y1, z1:''' 3D coordinates of source vector/value<br />
*'''x2, y2, z2:''' 3D coordinates of target vector/value<br />
*'''fProgress:''' float between 0 and 1 indicating the interpolation progress (0 at the beginning of the interpolation, 1 at the end).<br />
*'''strEasingType:''' the [[Easing|easing function]] to use for the interpolation<br />
<br />
===Optional Arguments===<br />
*'''fEasingPeriod:''' the period of the [[Easing|easing function]] (only some easing functions use this parameter)<br />
*'''fEasingAmplitude:''' the amplitude of the [[Easing|easing function]] (only some easing functions use this parameter)<br />
*'''fEasingOvershoot:''' the overshoot of the [[Easing|easing function]] (only some easing functions use this parameter)<br />
<br />
===Returns===<br />
Returns ''x, y, z'' the interpolated 3D vector/value if successful, ''false'' otherwise (error in parameters).<br />
As mentioned before, interpolateBetween can be used on 2D vectors or scalars in which case only some (x, y or just x) of the returned values are to be used (cf. alpha interpolation in marker example or size interpolation in window example).<br />
<br />
== Examples ==<br />
The examples below are only clientside examples even though the function can be used on both sides. Indeed it makes more sense to use it with onClientRender/onClientPreRender but the freedom is given to use it in any other context.<br />
<section name="Client" class="client" show="true"><br />
This clientside example uses interpolateBetween to create position and color interpolation(with effect) on a marker.<br />
The command to test it is "/marker".<br />
The position is interpolated with "OutBounce" as strEasingType to make the marker bounce off the ground and "Linear" interpolation for the color.<br />
<syntaxhighlight lang="lua"><br />
local g_Marker = nil<br />
addCommandHandler("marker",<br />
function ()<br />
if g_Marker then return end<br />
<br />
local x, y, z = getElementPosition(getLocalPlayer())<br />
z = z - 1<br />
<br />
g_Marker = {}<br />
g_Marker.startPos = {x, y, z + 5}<br />
g_Marker.startTime = getTickCount()<br />
g_Marker.startColor = {255, 0, 0, 0}<br />
g_Marker.endPos = {x, y, z}<br />
g_Marker.endTime = g_Marker.startTime + 2000<br />
g_Marker.endColor = {0, 0, 255, 255} <br />
<br />
local x, y, z = unpack(g_Marker.startPos)<br />
local r, g, b, a = unpack(g_Marker.startColor)<br />
g_Marker.marker = createMarker(x, y, z, "cylinder", 1, 255, r, g, b, a)<br />
<br />
addEventHandler("onClientRender", getRootElement(), popMarkerUp)<br />
end)<br />
<br />
function popMarkerUp()<br />
local now = getTickCount()<br />
local elapsedTime = now - g_Marker.startTime<br />
local duration = g_Marker.endTime - g_Marker.startTime<br />
local progress = elapsedTime / duration<br />
<br />
local x1, y1, z1 = unpack(g_Marker.startPos)<br />
local x2, y2, z2 = unpack(g_Marker.endPos)<br />
local x, y, z = interpolateBetween ( <br />
x1, y1, z1,<br />
x2, y2, z2, <br />
progress, "OutBounce")<br />
<br />
setElementPosition(g_Marker.marker, x, y, z)<br />
<br />
local r1, g1, b1, a1 = unpack(g_Marker.startColor)<br />
local r2, g2, b2, a2 = unpack(g_Marker.endColor)<br />
local r, g, b = interpolateBetween ( <br />
r1, g1, b1,<br />
r2, g2, b2, <br />
progress, "Linear")<br />
local a = interpolateBetween ( <br />
a1, 0, 0,<br />
a2, 0, 0,<br />
progress, "Linear")<br />
<br />
setMarkerColor(g_Marker.marker , r, g, b, a)<br />
<br />
if now >= g_Marker.endTime then<br />
removeEventHandler("onClientRender", getRootElement(), popMarkerUp)<br />
setTimer(<br />
function ()<br />
destroyElement(g_Marker.marker)<br />
g_Marker = nil<br />
end, 3000, 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
This clientside example uses interpolateBetween to create size and position interpolation (with effect) on a gui-window.<br />
The command to test it is "/window".<br />
When the window pops up it uses "OutElastic" as the strEasingType to create the bouncing/elastic effect.<br />
When it fades away, it uses "InQuad" to have an accelerating fading.<br />
<syntaxhighlight lang="lua"><br />
local g_Window = nil<br />
addCommandHandler("window",<br />
function ()<br />
if g_Window then return end<br />
<br />
g_Window = {}<br />
<br />
local screenWidth, screenHeight = guiGetScreenSize()<br />
g_Window.windowWidth, g_Window.windowHeight = 400, 315<br />
local left = screenWidth/2 - g_Window.windowWidth/2<br />
local top = screenHeight/2 - g_Window.windowHeight/2<br />
<br />
g_Window.window = guiCreateWindow(left, top, g_Window.windowWidth, g_Window.windowHeight, "Interpolation on GUI", false)<br />
<br />
g_Window.closeBtn = guiCreateButton(320, 285, 75, 23, "Close", false, g_Window.window)<br />
<br />
guiWindowSetSizable(g_Window.window, false)<br />
guiWindowSetMovable(g_Window.window, false)<br />
guiSetEnabled(g_Window.window, false)<br />
guiSetVisible(g_Window.window, false)<br />
<br />
g_Window.startTime = getTickCount()<br />
g_Window.startSize = {0, 0}<br />
g_Window.endSize = {g_Window.windowWidth, g_Window.windowHeight}<br />
g_Window.endTime = g_Window.startTime + 1000<br />
addEventHandler("onClientRender", getRootElement(), popWindowUp)<br />
end)<br />
<br />
function on_closeBtn_clicked(button, state, absoluteX, absoluteY)<br />
if (button ~= "left") or (state ~= "up") then<br />
return<br />
end<br />
<br />
if not g_Window then return end<br />
<br />
showCursor(false)<br />
guiSetEnabled(g_Window.window, false)<br />
guiWindowSetMovable(g_Window.window, false)<br />
<br />
local screenWidth, screenHeight = guiGetScreenSize()<br />
local posX, posY = guiGetPosition(g_Window.window, false)<br />
<br />
g_Window.startTime = getTickCount()<br />
g_Window.startSize = {g_Window.windowWidth, g_Window.windowHeight}<br />
g_Window.startCenter = <br />
{<br />
posX + g_Window.windowWidth/2,<br />
posY + g_Window.windowHeight/2,<br />
}<br />
<br />
g_Window.endSize = {0, 0}<br />
g_Window.endTime = g_Window.startTime + 1000<br />
g_Window.endCenter = <br />
{<br />
screenWidth, <br />
screenHeight<br />
}<br />
<br />
addEventHandler("onClientRender", getRootElement(), popWindowDown)<br />
end<br />
<br />
function popWindowUp()<br />
local now = getTickCount()<br />
local elapsedTime = now - g_Window.startTime<br />
local duration = g_Window.endTime - g_Window.startTime<br />
local progress = elapsedTime / duration<br />
<br />
local width, height, _ = interpolateBetween ( <br />
g_Window.startSize[1], g_Window.startSize[2], 0, <br />
g_Window.endSize[1], g_Window.endSize[2], 0, <br />
progress, "OutElastic")<br />
<br />
guiSetSize(g_Window.window, width, height, false)<br />
<br />
local screenWidth, screenHeight = guiGetScreenSize()<br />
guiSetPosition(g_Window.window, screenWidth/2 - width/2, screenHeight/2 - height/2, false)<br />
<br />
if not guiGetVisible(g_Window.window) then<br />
guiSetVisible(g_Window.window, true)<br />
guiBringToFront(g_Window.window)<br />
end<br />
<br />
if now >= g_Window.endTime then<br />
guiSetEnabled(g_Window.window, true)<br />
<br />
guiBringToFront(g_Window.window)<br />
removeEventHandler("onClientRender", getRootElement(), popWindowUp)<br />
addEventHandler("onClientGUIClick", g_Window.closeBtn, on_closeBtn_clicked, false)<br />
showCursor(true)<br />
guiWindowSetMovable(g_Window.window, true)<br />
end<br />
end<br />
<br />
function popWindowDown()<br />
local now = getTickCount()<br />
local elapsedTime = now - g_Window.startTime<br />
local duration = g_Window.endTime - g_Window.startTime<br />
local progress = elapsedTime / duration<br />
<br />
local width, height, _ = interpolateBetween ( <br />
g_Window.startSize[1], g_Window.startSize[2], 0, <br />
g_Window.endSize[1], g_Window.endSize[2], 0, <br />
progress, "InQuad")<br />
<br />
guiSetSize(g_Window.window, width, height, false)<br />
<br />
local centerX, centerY, _ = interpolateBetween ( <br />
g_Window.startCenter[1], g_Window.startCenter[2], 0, <br />
g_Window.endCenter[1], g_Window.endCenter[2], 0, <br />
progress, "InQuad")<br />
<br />
guiSetPosition(g_Window.window, centerX - width/2, centerY - height/2, false)<br />
<br />
if now >= g_Window.endTime then<br />
removeEventHandler("onClientRender", getRootElement(), popWindowDown)<br />
destroyElement(g_Window.window)<br />
g_Window = nil<br />
end<br />
end<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Utility functions}}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=SetHeatHaze&diff=26374SetHeatHaze2011-07-17T07:18:09Z<p>MaddDogg: Added heat haze template</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function changes the heat haze effect.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool setHeatHaze ( int intensity, [ int randomShift = 0, int speedMin = 12, int speedMax = 18, int scanSizeX = 75, int scanSizeY = 80, int renderSizeX = 80, int renderSizeY = 85, bool bShowInside = false ] )<br />
</syntaxhighlight> <br />
<br />
===Optional Arguments=== <br />
{{OptionalArg}} <br />
{{HeatHazeValues}}<br />
<br />
===Returns===<br />
Returns ''true'' if the heat haze effect was set correctly, ''false'' if invalid values were passed.<br />
<br />
==Example== <br />
'''Example 1:''' This example turns the heat haze effect off:<br />
<syntaxhighlight lang="lua"><br />
setHeatHaze ( 0 )<br />
</syntaxhighlight><br />
<br />
'''Example 2:''' This example will have an interesting effect:<br />
<syntaxhighlight lang="lua"><br />
setHeatHaze ( 50, 20, 0, 500, 200, 100, 50, 20, true )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{World functions}}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=GetHeatHaze&diff=26373GetHeatHaze2011-07-17T07:17:17Z<p>MaddDogg: Created a template for heat haze values and added it to 'returns' section</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function will return the current heat haze effect settings.<br />
<br />
'''Note:''' The server can only return the heat haze settings if it has actually been set by script.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
int, int, int, int, int, int, int, int, bool getHeatHaze ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns 9 values, which are the same used as arguments in [[SetHeatHaze]]:<br />
{{HeatHazeValues}}<br />
<br />
==Example== <br />
<syntaxhighlight lang="lua"><br />
--TODO<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{World functions}}<br />
<br />
[[Category:Needs_Example]]</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=Template:HeatHazeValues&diff=26372Template:HeatHazeValues2011-07-17T07:16:43Z<p>MaddDogg: Created a heat haze values template for various heat haze functions</p>
<hr />
<div>*'''intensity:''' The intensity of the effect, from 0 to 255.<br />
*'''randomShift:''' Sets a random jitter, from 0 to 255.<br />
*'''speedMin:''' The slowest effect speed, from 0 to 1000.<br />
*'''speedMax:''' The fastest effect speed, from 0 to 1000.<br />
*'''scanSizeX:''' The X size in pixels of the chunk grabbed from the screen, from -1000 to 1000.<br />
*'''scanSizeY:''' The Y size in pixels of the chunk grabbed from the screen, from -1000 to 1000.<br />
*'''renderSizeX:''' The X size in pixels the chunk will be when rendered back to the screen, from 0 to 1000.<br />
*'''renderSizeY:''' The Y size in pixels the chunk will be when rendered back to the screen, from 0 to 1000.<br />
*'''bShowInside:''' Set to ''true'' to enable the heat haze effect when inside a building.</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=CreateColRectangle&diff=25335CreateColRectangle2011-02-04T11:45:35Z<p>MaddDogg: west - south mix up | renamed fDepth to fHeight</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function creates a collision rectangle. This is a shape that has a position and a width and a depth. See [http://en.wikipedia.org/wiki/Rectangle Rectangle] for a definition of a rectangle. XY marks on the south west corner of the colshape.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
colshape createColRectangle ( float fX, float fY, float fWidth, float fHeight)<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''fX:''' The X position of the collision rectangle's west side<br />
*'''fY:''' The Y position of the collision rectangle's south side<br />
*'''fWidth:''' The collision rectangle's width<br />
*'''fHeight:''' The collision rectangle's height<br />
<br />
===Returns===<br />
Returns a [[colshape]] element if successful, ''false'' if invalid arguments were passed to the function.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example displays a chat message when a player enters the colshape and allows the colshape to be created using a console function ''set_zone''.<br />
<syntaxhighlight lang="lua"><br />
theZone = false<br />
<br />
function shapeHit ( thePlayer ) <br />
outputChatBox ( getPlayerName ( thePlayer ) .. " is in the zone!" ) -- display a message in everyone's chat box<br />
end<br />
<br />
function setZone ( playerSource, commandName, fX, fY )<br />
if ( fY and fX ) then -- check we've got the 2 args we need<br />
local tempCol = createColRectangle ( fX, fY, 10.0, 10.0 ) -- create a col<br />
if ( tempCol == false ) then -- did the col get created successfully?<br />
outputConsole ( "Syntax is: set_zone <X> <Y>" ) -- inform the user what the valid syntax is<br />
else<br />
if ( theZone ~= false ) then -- did we already have a zone?<br />
destroyElement ( theZone ) -- if so, destroy it<br />
else<br />
addEventHandler ( "onColShapeHit", theZone, shapeHit ) -- add a handler for the onColShapeHit event<br />
end<br />
theZone = tempCol -- and store the new zone we've made<br />
outputChatBox ( "Zone has moved!" ) -- and tell everyone<br />
end<br />
end<br />
end<br />
addCommandHandler ( "set_zone", setZone ) -- add a console function called set_zone that will trigger the function setZone<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Collision shape functions}}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=IsMTAWindowActive&diff=25287IsMTAWindowActive2011-01-30T21:22:23Z<p>MaddDogg: typo</p>
<hr />
<div>__NOTOC__ <br />
{{Client function}}<br />
This function returns whether any system windows that take focus are active. This includes the chatbox input, console window, main menu and transferbox.<br />
To get the status of the debug view, see [[isDebugViewActive]].<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool isMTAWindowActive ()<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns ''true'' if the focus is on the MTA window, ''false'' if it isn't.<br />
<br />
==Example== <br />
<section name="Client" class="client" show="true"><br />
This function kill a player if it comes out in the standard menu MTA<br />
<syntaxhighlight lang="lua"><br />
function dontAllowAnyOpenWindow ()<br />
if isMTAWindowActive () then<br />
setElementHealth ( thePlayer, 0.0 )<br />
end <br />
end<br />
setTimer ( dontAllowAnyOpenWindow, 50, 0 )<br />
</syntaxhighlight><br />
</section><br />
==See Also==<br />
{{GUI_functions}}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=User:MaddDogg&diff=25265User:MaddDogg2011-01-23T16:22:46Z<p>MaddDogg: </p>
<hr />
<div>Hi!<br><br />
<br><br />
<br><br />
'''Los Santos Stories - Real Life and Role Play Server Project'''<br><br />
http://www.ls-stories.com</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=User:MaddDogg&diff=25264User:MaddDogg2011-01-23T16:22:28Z<p>MaddDogg: </p>
<hr />
<div>Hi!<br><br />
<br><br />
<br><br />
'''Los Santos Stories - Real Life and Role Play Server Project'''<br><br />
[http://www.ls-stories.com]</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=User:MaddDogg&diff=25263User:MaddDogg2011-01-23T16:22:11Z<p>MaddDogg: </p>
<hr />
<div>Hi!<br><br />
<br><br />
<br><br />
'''Los Santos Stories - Real Life and Role Play Server Project'''<br><br />
[www.ls-stories.com]</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=User:MaddDogg&diff=25262User:MaddDogg2011-01-23T16:21:38Z<p>MaddDogg: Created page with "Hi! Los Santos Stories - Real Life and Role Play Server Project www.ls-stories.com"</p>
<hr />
<div>Hi!<br />
<br />
Los Santos Stories - Real Life and Role Play Server Project<br />
www.ls-stories.com</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=OnClientPedWasted&diff=25261OnClientPedWasted2011-01-23T16:01:34Z<p>MaddDogg: added info about death reasons</p>
<hr />
<div>__NOTOC__<br />
{{Client event}}<br />
<br />
This event is triggered whenever a ped dies.<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
element killer, int weapon, int bodypart<br />
</syntaxhighlight> <br />
<br />
*'''killer''': A [[player]] [[element]] representing the killer.<br />
*'''weapon''': An integer representing the [[Weapons|killer weapon]] or the [[Death Reasons|death reason]].<br />
*'''bodypart''': An integer representing the bodypart the player was damaged.<br />
{{BodyParts}}<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[ped]] that died.<br />
<br />
==Example== <br />
<br />
==See Also==<br />
===Client ped events===<br />
{{Client_ped_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=OnClientPlayerWasted&diff=25260OnClientPlayerWasted2011-01-23T16:01:15Z<p>MaddDogg: added info about death reasons</p>
<hr />
<div>__NOTOC__<br />
{{Client event}}<br />
This event is triggered whenever a player, including those remote, dies.<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
element killer, int weapon, int bodypart<br />
</syntaxhighlight> <br />
<br />
*'''killer''': A [[player]] [[element]] representing the killer.<br />
*'''weapon''': An integer representing the [[Weapons|killer weapon]] or the [[Death Reasons|death reason]].<br />
*'''bodypart''': An integer representing the bodypart the player was damaged.<br />
{{BodyParts}}<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] that died.<br />
<br />
==Example== <br />
This example outputs a mocking message when the local player dies.<br />
<syntaxhighlight lang="lua"><br />
messages = { <br />
"Better luck next time",<br />
"Don't think you're so cool now, do you?",<br />
"Nice one, pal",<br />
"Your opinion is void" <br />
}<br />
<br />
function wastedMessage ( killer, weapon, bodypart )<br />
local randomID = math.random ( 1, #messages ) --get a random ID from the table<br />
local randomMessage = messages[randomID] --use that to retrieve a message<br />
outputChatBox ( randomMessage, 255, 0, 0 ) --output the message<br />
end<br />
addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), wastedMessage ) --add an event for the local player only<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===Client player events===<br />
{{Client_player_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=OnPedWasted&diff=25259OnPedWasted2011-01-23T16:00:40Z<p>MaddDogg: added info about death reasons</p>
<hr />
<div>__NOTOC__ <br />
{{Server event}}<br />
This event is triggered when a ped is killed or dies.<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua">int totalAmmo, element killer, int killerWeapon, int bodypart [, bool stealth ]<br />
</syntaxhighlight><br />
<br />
*'''totalAmmo''': an integer representing the total ammo the victim had when he died.<br />
*'''killer''': an [[element]] representing the player or vehicle who was the killer. If there was no killer this is ''false''.<br />
*'''killerWeapon''': an integer representing the [[Weapons|killer weapon]] or the [[Death Reasons|death reason]].<br />
*'''bodypart''': an integer representing the bodypart ID the victim was hit on when he died.<br />
{{BodyParts}}<br />
*'''stealth''': boolean value representing whether or not this was a stealth kill<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[ped]] that died or got killed.<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
-- TODO<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Ped_events}}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=OnPlayerWasted&diff=25258OnPlayerWasted2011-01-23T16:00:04Z<p>MaddDogg: added info about death reasons</p>
<hr />
<div>__NOTOC__ <br />
{{Server event}}<br />
This event is triggered when a player is killed or dies.<br />
<br />
==Parameters==<br />
{{New feature|3|1.0|<syntaxhighlight lang="lua"><br />
int totalAmmo, element killer, int killerWeapon, int bodypart [, bool stealth ]<br />
</syntaxhighlight>}}<br />
<br />
{{Deprecated_feature|3|1.0|<syntaxhighlight lang="lua"><br />
int totalAmmo, element killer, int killerWeapon, int bodypart<br />
</syntaxhighlight>}}<br />
<br />
*'''totalAmmo''': an integer representing the total ammo the victim had when he died.<br />
*'''killer''': an [[element]] representing the player or vehicle who was the killer. If there was no killer this is ''false''.<br />
*'''killerWeapon''': an integer representing the [[Weapons|killer weapon]] or the [[Death Reasons|death reason]].<br />
*'''bodypart''': an integer representing the bodypart ID the victim was hit on when he died.<br />
{{BodyParts}}<br />
*{{New feature|3|1.0|'''stealth''': boolean value representing whether or not this was a stealth kill}}<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] that died or got killed.<br />
<br />
==Example== <br />
This example prints the killer and bodypart to the chat when a player dies.<br />
<syntaxhighlight lang="lua"><br />
-- register player_Wasted as a handler for onPlayerWasted<br />
function player_Wasted ( ammo, attacker, weapon, bodypart )<br />
-- if there was an attacker<br />
if ( attacker ) then<br />
-- we declare our variable outside the following checks<br />
local tempString<br />
-- if the element that killed him was a player,<br />
if ( getElementType ( attacker ) == "player" ) then<br />
-- put the attacker, victim and weapon info in the string<br />
tempString = getPlayerName ( attacker ).." killed "..getPlayerName ( source ).." ("..getWeaponNameFromID ( weapon )..")"<br />
-- else, if it was a vehicle,<br />
elseif ( getElementType ( attacker ) == "vehicle" ) then<br />
-- we'll get the name from the attacker vehicle's driver<br />
local tempString = getPlayerName ( getVehicleController ( attacker ) ).." killed "..getPlayerName ( source ).." ("..getWeaponNameFromID ( weapon )..")"<br />
end<br />
-- if the victim was shot in the head, append a special message<br />
if ( bodypart == 9 ) then<br />
tempString = tempString.." (HEADSHOT!)"<br />
-- else, just append the bodypart name<br />
else<br />
tempString = tempString.." ("..getBodyPartName ( bodypart )..")"<br />
end<br />
-- display the message<br />
outputChatBox ( tempString )<br />
-- if there was no attacker,<br />
else<br />
-- output a death message without attacker info<br />
outputChatBox ( getPlayerName ( source ).." died. ("..getWeaponNameFromID ( weapon )..") ("..getBodyPartName ( bodypart )..")" )<br />
end<br />
end<br />
addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted )<br />
</syntaxhighlight><br />
<br />
<br />
And another example, this will spawn you in the middle of GTA SA world (x=0, y=0, z=3) after 2 seconds of your death<br />
<syntaxhighlight lang="lua"><br />
addEventHandler( "onPlayerWasted", getRootElement( ),<br />
function()<br />
setTimer( spawnPlayer, 2000, 1, source, 0, 0, 3 )<br />
end<br />
)<br />
</syntaxhighlight><br />
<br />
{{See also/Server event|Player events}}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=Damage_Types&diff=25256Damage Types2011-01-23T15:57:26Z<p>MaddDogg: added info about heli blades</p>
<hr />
<div>The following death reasons are used by event like onPlayerWasted for the killerWeapon argument to describe the reason, why a ped died.<br><br />
When a player was shot by a weapon, the respective weapon ID is the death reason ID. The weapon IDs can be found [[Weapons|here]].<br />
<br><br />
<br><br />
:{|border="1" cellpadding="4" cellspacing="0" align="left"<br />
|-<br />
!style="background:#afafaf;"|ID<br />
!style="background:#afafaf;"|Death reason<br />
!style="background:#afafaf;"|Additional info<br />
|-<br />
!19<br />
|Rocket<br />
|Actual death reason / weapon ID when dying from a rocket launcher<br />
|-<br />
!37<br />
|Burnt<br />
|This is used by a death by fire, even when the fire is created by a rocket explosion or a molotov<br />
|-<br />
!49<br />
|Rammed<br />
|<br />
|-<br />
!50<br />
|Ranover<br />
|This is also called when dying because of helicopter blades<br />
|-<br />
!51<br />
|Explosion<br />
|This may sometimes also be used at an indirect death through an exploding rocket<br />
|-<br />
!52<br />
|Driveby<br />
|This is NOT used for a driveby kill with e.g. the 'realdriveby' resource<br />
|-<br />
!53<br />
|Drowned<br />
|<br />
|-<br />
!54<br />
|Fall<br />
|<br />
|-<br />
!55<br />
|Unknown<br />
|No known information about this death reason<br />
|-<br />
!56<br />
|Melee<br />
|Seems to be never called (?); for an actual melee death, the fist weapon ID (0) is used (see [[Weapons|here]])<br />
|-<br />
!57<br />
|Weapon<br />
|Seems to be never called (?)<br />
|-<br />
!58<br />
|Flare<br />
|Purpose unknown<br />
|-<br />
!59<br />
|Tank Grenade<br />
|<br />
|}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=Id&diff=25255Id2011-01-23T15:56:57Z<p>MaddDogg: added death reasons page</p>
<hr />
<div>'''Note: this page needs to link functions they apply to'''<br />
<br />
ID stands for identification. It is a whole-number integer that refers to many mechanics of San Andreas.<br />
----<br />
Game elements using IDs:<br />
''Note: does not include small ID lists related to specific functions or IDs created by MTA''<br />
*[[Animations|Animations]]<br />
*[[Character Skins]]<br />
*[[CJ_Clothes|Clothing styles]]<br />
*[[Death Reasons]]<br />
*[[Garage|Garage IDs]]<br />
*[[Interior IDs]]<br />
*[[Material IDs]]<br />
*[[Projectiles]]<br />
*[[Radar Blips]]<br />
*[[Sounds]]<br />
*[[Vehicle IDs]]<br />
*[[Vehicle Colors]]<br />
*[[Vehicle Upgrades]]<br />
*[[Weapons|Weapons]]<br />
*[[Weather]] ''Note: blended weather allows for many more undocumented effects''<br />
<br />
==See Also==<br />
*[[Vending|List of San Andreas Vending machine locations]]<br />
*[[IDE_List|San Andreas IDE List]]<br />
{{IDs}}<br />
'''Credit for information contained in the pages:'''<br />
Ransom (initial creation, formatting, and all lists not credited to others) eAi (vehicle colors list) erorr404/Talidan/Brophy (sound list) Talidan (radar blip pictures/vehicle list) Hellfish (skin pictures [http://www.gtaforums.com/index.php?showtopic=205220 SOURCE]) Brophy/Ratt/Panther/Twig (lots of inital ID data) GTAForums (Allowing Ransom to find IDs for lists)</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=Damage_Types&diff=25253Damage Types2011-01-23T15:54:28Z<p>MaddDogg: Created page with "The following death reasons are used by event like onPlayerWasted for the killerWeapon argument to describe the reason, why a ped died.<br> When a player was shot by a weapon, th..."</p>
<hr />
<div>The following death reasons are used by event like onPlayerWasted for the killerWeapon argument to describe the reason, why a ped died.<br><br />
When a player was shot by a weapon, the respective weapon ID is the death reason ID. The weapon IDs can be found [[Weapons|here]].<br />
<br><br />
<br><br />
:{|border="1" cellpadding="4" cellspacing="0" align="left"<br />
|-<br />
!style="background:#afafaf;"|ID<br />
!style="background:#afafaf;"|Death reason<br />
!style="background:#afafaf;"|Additional info<br />
|-<br />
!19<br />
|Rocket<br />
|Actual death reason / weapon ID when dying from a rocket launcher<br />
|-<br />
!37<br />
|Burnt<br />
|This is used by a death by fire, even when the fire is created by a rocket explosion or a molotov<br />
|-<br />
!49<br />
|Rammed<br />
|<br />
|-<br />
!50<br />
|Ranover<br />
|<br />
|-<br />
!51<br />
|Explosion<br />
|This may sometimes also be used at an indirect death through an exploding rocket<br />
|-<br />
!52<br />
|Driveby<br />
|This is NOT used for a driveby kill with e.g. the 'realdriveby' resource<br />
|-<br />
!53<br />
|Drowned<br />
|<br />
|-<br />
!54<br />
|Fall<br />
|<br />
|-<br />
!55<br />
|Unknown<br />
|No known information about this death reason<br />
|-<br />
!56<br />
|Melee<br />
|Seems to be never called (?); for an actual melee death, the fist weapon ID (0) is used (see [[Weapons|here]])<br />
|-<br />
!57<br />
|Weapon<br />
|Seems to be never called (?)<br />
|-<br />
!58<br />
|Flare<br />
|Purpose unknown<br />
|-<br />
!59<br />
|Tank Grenade<br />
|<br />
|}</div>MaddDogghttps://wiki.multitheftauto.com/index.php?title=Weapons&diff=25252Weapons2011-01-23T15:18:25Z<p>MaddDogg: Edited info about death reasons</p>
<hr />
<div>'''Scripting functions that ask for a weapon ID need an integer that refers to the GTASA weapon ID list. They are listed below.'''<br />
<br><br />
*''NOTES:<br />
**''Clip size () denotes clip size when the weapon is dual wielded. Weapons without this specification are not dual wield weapons.''<br />
**''GTASA [[Weapon_skill_levels|weapon stats]] will affect movement, accuracy, damage, and dual wield capability. See [[SetPedStat]] to change these stats. The MTA server comes with a resource called "defaultStats" <br />
that sets GTASA weapon stats to 999. See the weapon stats link for more info.''<br />
**''For death reasons, especially in event handlers for onPlayerWasted or similar, also have a look at the [[Death_Reasons]].<br />
<br><br />
{|border="1" cellpadding="1" cellspacing="0" align="center"<br />
|-<br />
| style="background:#afafaf;"|<br />
! scope="col" style="background:#afafaf;"| Weapon<br />
! scope="col" style="background:#afafaf;"| ID<br />
! scope="col" style="background:#afafaf;"| Clip<br />
! scope="col" style="background:#afafaf;"| Model ID<br />
| style="background:#afafaf;"|<br />
! scope="col" style="background:#afafaf;"| Weapon<br />
! scope="col" style="background:#afafaf;"| ID<br />
! scope="col" style="background:#afafaf;"| Clip<br />
! scope="col" style="background:#afafaf;"| Model ID<br />
|-<br />
! scope="row" style="background:#cfcfcf;"| Slot 0: No Weapon<br />
|style="background:#cfcfcf;"|Fist<br />
|style="background:#cfcfcf;"|0<br />
|style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|<br />
! scope="row" style="background:#cfcfcf;"| Slot 6: Rifles<br />
|style="background:#cfcfcf;"|Country Rifle<br />
|style="background:#cfcfcf;"|33<br />
|style="background:#cfcfcf;"|1<br />
|style="background:#cfcfcf;"|357<br />
|-<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Brass Knuckles<br />
|style="background:#cfcfcf;"|1<br />
|style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|331<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Sniper Rifle<br />
|style="background:#cfcfcf;"|34<br />
|style="background:#cfcfcf;"|1<br />
|style="background:#cfcfcf;"|358<br />
|-<br />
! scope="row" style="background:#efefef;"| Slot 1: Melee<br />
|style="background:#efefef;"|Golf Club<br />
|style="background:#efefef;"|2<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|333<br />
! scope="row" style="background:#efefef;"| Slot 7: Heavy Weapons<br />
|style="background:#efefef;"|Rocket Launcher<br />
|style="background:#efefef;"|35<br />
|style="background:#efefef;"|1<br />
|style="background:#efefef;"|359<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Nightstick<br />
|style="background:#efefef;"|3<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|334<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Heat-Seeking RPG<br />
|style="background:#efefef;"|36<br />
|style="background:#efefef;"|1<br />
|style="background:#efefef;"|360<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Knife <br />
|style="background:#efefef;"|4<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|335<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Flamethrower<br />
|style="background:#efefef;"|37<br />
|style="background:#efefef;"|50<br />
|style="background:#efefef;"|361<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Baseball Bat<br />
|style="background:#efefef;"|5<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|336<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Minigun<br />
|style="background:#efefef;"|38<br />
|style="background:#efefef;"|500<br />
|style="background:#efefef;"|362<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Shovel <br />
|style="background:#efefef;"|6<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|337<br />
! scope="row" style="background:#cfcfcf;"| Slot 8: Projectiles<br />
|style="background:#cfcfcf;"|Grenade <br />
|style="background:#cfcfcf;"|16<br />
|style="background:#cfcfcf;"|1<br />
|style="background:#cfcfcf;"|342<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Pool Cue<br />
|style="background:#efefef;"|7<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|338<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Tear Gas<br />
|style="background:#cfcfcf;"|17<br />
|style="background:#cfcfcf;"|1<br />
|style="background:#cfcfcf;"|343<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Katana <br />
|style="background:#efefef;"|8<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|339<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Molotov Cocktails<br />
|style="background:#cfcfcf;"|18<br />
|style="background:#cfcfcf;"|1<br />
|style="background:#cfcfcf;"|344<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Chainsaw <br />
|style="background:#efefef;"|9<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|341<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Satchel Charges<br />
|style="background:#cfcfcf;"|39<br />
|style="background:#cfcfcf;"|1<br />
|style="background:#cfcfcf;"|363<br />
|-<br />
! scope="row" style="background:#cfcfcf;"| Slot 2: Handguns<br />
|style="background:#cfcfcf;"|Pistol <br />
|style="background:#cfcfcf;"|22<br />
|style="background:#cfcfcf;"|17 (34)<br />
|style="background:#cfcfcf;"|346<br />
! scope="row" style="background:#efefef;"| Slot 9: Special 1<br />
|style="background:#efefef;"|Spraycan <br />
|style="background:#efefef;"|41<br />
|style="background:#efefef;"|500<br />
|style="background:#efefef;"|365<br />
|-<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Silenced Pistol<br />
|style="background:#cfcfcf;"|23<br />
|style="background:#cfcfcf;"|17<br />
|style="background:#cfcfcf;"|347<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Fire Extinguisher<br />
|style="background:#efefef;"|42<br />
|style="background:#efefef;"|500<br />
|style="background:#efefef;"|366<br />
|-<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Desert Eagle <br />
|style="background:#cfcfcf;"|24<br />
|style="background:#cfcfcf;"|7<br />
|style="background:#cfcfcf;"|348<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Camera<br />
|style="background:#efefef;"|43<br />
|style="background:#efefef;"|36<br />
|style="background:#efefef;"|367<br />
|-<br />
! scope="row" style="background:#efefef;"| Slot 3: Shotguns<br />
|style="background:#efefef;"|Shotgun<br />
|style="background:#efefef;"|25<br />
|style="background:#efefef;"|1<br />
|style="background:#efefef;"|349<br />
! scope="row" style="background:#cfcfcf;"| Slot 10: Gifts/Other<br />
|style="background:#cfcfcf;"|Long Purple Dildo<br />
|style="background:#cfcfcf;"|10<br />
|style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|321<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Sawn-Off Shotgun <br />
|style="background:#efefef;"|26<br />
|style="background:#efefef;"|2 (4)<br />
|style="background:#efefef;"|350<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Short tan Dildo<br />
|style="background:#cfcfcf;"|11<br />
|style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|322<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|SPAZ-12 Combat Shotgun<br />
|style="background:#efefef;"|27<br />
|style="background:#efefef;"|7<br />
|style="background:#efefef;"|351<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Vibrator <br />
|style="background:#cfcfcf;"|12<br />
|style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|323<br />
|-<br />
! scope="row" style="background:#cfcfcf;"| Slot 4: Sub-Machine Guns<br />
|style="background:#cfcfcf;"|Uzi<br />
|style="background:#cfcfcf;"|28<br />
|style="background:#cfcfcf;"|50 (100)<br />
|style="background:#cfcfcf;"|352<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Flowers <br />
|style="background:#cfcfcf;"|14<br />
|style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|325<br />
|-<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|MP5<br />
|style="background:#cfcfcf;"|29<br />
|style="background:#cfcfcf;"|30<br />
|style="background:#cfcfcf;"|353<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|Cane <br />
|style="background:#cfcfcf;"|15<br />
|style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|326<br />
|-<br />
! scope="row" style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|TEC-9<br />
|style="background:#cfcfcf;"|32<br />
|style="background:#cfcfcf;"|50 (100)<br />
|style="background:#cfcfcf;"|372<br />
! scope="row" style="background:#efefef;"| Slot 11: Special 2<br />
|style="background:#efefef;"|Night-Vision Goggles<br />
|style="background:#efefef;"|44<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|368<br />
|-<br />
! scope="row" style="background:#efefef;"| Slot 5: Assault Rifles<br />
|style="background:#efefef;"|AK-47<br />
|style="background:#efefef;"|30<br />
|style="background:#efefef;"|30<br />
|style="background:#efefef;"|355<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Infrared Goggles<br />
|style="background:#efefef;"|45<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|369<br />
|-<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|M4<br />
|style="background:#efefef;"|31<br />
|style="background:#efefef;"|50<br />
|style="background:#efefef;"|356<br />
! scope="row" style="background:#efefef;"|<br />
|style="background:#efefef;"|Parachute<br />
|style="background:#efefef;"|46<br />
|style="background:#efefef;"|<br />
|style="background:#efefef;"|371<br />
|-<br />
! scope="row" colspan="5" style="background:#efefef;"|<br />
! scope="row" style="background:#cfcfcf;"| Slot 12: Satchel Detonator<br />
|style="background:#cfcfcf;"|Satchel Detonator<br />
|style="background:#cfcfcf;"|40<br />
|style="background:#cfcfcf;"|<br />
|style="background:#cfcfcf;"|364<br />
|}</div>MaddDogg