Squirrel/Server/Functions/HashTables/Add
From Liberty Unleashed Wiki
(Difference between revisions)
(→Notes) |
|||
Line 3: | Line 3: | ||
== Syntax == | == Syntax == | ||
− | <code>HashTable.Add( | + | <code>HashTable.Add( key, value )</code> |
== Arguments == | == Arguments == | ||
− | * ''' | + | * ''' key ''' - How you will retrieve this information. |
+ | * ''' value ''' - The info that you wish to add to the hash table, integer/float/string. | ||
== Example == | == Example == | ||
Line 14: | Line 15: | ||
function onPlayerJoin( pPlayer ) | function onPlayerJoin( pPlayer ) | ||
{ | { | ||
− | pDataHash.Add( pPlayer.IP ); | + | pDataHash.Add( pPlayer.Name + "IP", pPlayer.IP ); |
} | } | ||
</code> | </code> | ||
− | This example will add the player's ip to the database that just joined the server. | + | This example will add the player's ip to the database that just joined the server. It can be retrieved via playernameIP. |
=== Notes === | === Notes === | ||
− | The function [[Squirrel/Server/Events/Player/onPlayerJoin|onPlayerJoin]] and [[Squirrel/Server/Functions/Players/IP|Player.IP]] were used in this example, more info about | + | The function [[Squirrel/Server/Events/Player/onPlayerJoin|onPlayerJoin]] and [[Squirrel/Server/Functions/Players/IP|Player.IP]] and [[Squirrel/Server/Functions/Players/Name|Player.Name]] were used in this example, more info about them in the corresponding page. |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/HashTables}} | {{Squirrel/Server/Functions/HashTables}} |
Revision as of 02:04, 26 May 2010
Syntax
HashTable.Add( key, value )
Arguments
- key - How you will retrieve this information.
- value - The info that you wish to add to the hash table, integer/float/string.
Example
function onPlayerJoin( pPlayer ) { pDataHash.Add( pPlayer.Name + "IP", pPlayer.IP ); }
This example will add the player's ip to the database that just joined the server. It can be retrieved via playernameIP.
Notes
The function onPlayerJoin and Player.IP and Player.Name were used in this example, more info about them in the corresponding page.