https://wiki.multitheftauto.com/wiki/ToHex?feed=atom&action=history
ToHex - Revision history
2024-03-29T15:42:00Z
Revision history for this page on the wiki
MediaWiki 1.39.3
https://wiki.multitheftauto.com/index.php?title=ToHex&diff=58961&oldid=prev
Myonlake at 15:39, 7 September 2018
2018-09-07T15:39:37Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 15:39, 7 September 2018</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>__NOTOC__</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>__NOTOC__</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">{{Needs Checking|The note about ''string.format( "%X", num )'' not working clientside is false, at least in MTA: SA 1.5.2. Should we keep this function then? It is still useful to let scripters see how does hexadecimal works under the hood, however.}}</del></div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Useful Function}}</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Useful Function}}</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
</table>
Myonlake
https://wiki.multitheftauto.com/index.php?title=ToHex&diff=47600&oldid=prev
AlexTMjugador: Needs checking
2016-06-11T20:20:15Z
<p>Needs checking</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 20:20, 11 June 2016</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">__NOTOC__</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">{{Needs Checking|The note about ''string.format( "%X", num )'' not working clientside is false, at least in MTA: SA 1.5.2. Should we keep this function then? It is still useful to let scripters see how does hexadecimal works under the hood, however.}}</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Useful Function}}</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Useful Function}}</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">__NOTOC__</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>This function converts a decimal number to a hexadecimal number.<br></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>This function converts a decimal number to a hexadecimal number.<br></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''NOTE:''' This is made to be used clientside! Use string.format ( "%X", num ) to convert a number to hex serverside, since this does not work properly clientside.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''NOTE:''' This is made to be used clientside! Use string.format ( "%X", num ) to convert a number to hex serverside, since this does not work properly clientside.</div></td></tr>
<!-- diff cache key wiki-wiki_dev_:diff::1.12:old-26072:rev-47600 -->
</table>
AlexTMjugador
https://wiki.multitheftauto.com/index.php?title=ToHex&diff=26072&oldid=prev
Remi-X: toHex function, to be used clientside.
2011-06-14T19:28:43Z
<p>toHex function, to be used clientside.</p>
<p><b>New page</b></p><div>{{Useful Function}}<br />
__NOTOC__<br />
This function converts a decimal number to a hexadecimal number.<br><br />
* '''NOTE:''' This is made to be used clientside! Use string.format ( "%X", num ) to convert a number to hex serverside, since this does not work properly clientside.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">string toHex( int number )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''number''': The number to be converted.<br />
<br />
===Returns===<br />
Returns a string containing the Hex value.<br />
<br />
==Code==<br />
<section name="Clientside script" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function toHex ( n )<br />
local hexnums = {"0","1","2","3","4","5","6","7",<br />
"8","9","A","B","C","D","E","F"}<br />
local str,r = "",n%16<br />
if n-r == 0 then str = hexnums[r+1]<br />
else str = toHex((n-r)/16)..hexnums[r+1] end<br />
return str<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
This example outputs the hexadecimal number in a string. ("1F5F79A0")<br />
<syntaxhighlight lang="lua">print ( toHex ( tonumber ( 0x1F5F79A0 ) ) )</syntaxhighlight><br />
<br />
<br />
Author: Remi-X<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>
Remi-X