Squirrel/Server/Functions/HashTables/Add

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Notes)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
__NOTOC__
+
{{Squirrel/Title|HashTable.Add}}
  
 
== Syntax ==
 
== Syntax ==
  
<code>HashTable.Add( data )</code>
+
<code>HashTable.Add( key, value )</code>
  
 
== Arguments ==
 
== Arguments ==
  
* ''' data ''' - The info that you wish to add to the hash table, integer/float/string.
+
* ''' 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 it in the corresponding page.
+
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}}

Latest revision as of 10:24, 11 October 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events


[edit] Syntax

  1. HashTable.Add( key, value )

[edit] Arguments

  • key - How you will retrieve this information.
  • value - The info that you wish to add to the hash table, integer/float/string.

[edit] Example

  1.  
  2. function onPlayerJoin( pPlayer )
  3. {
  4. pDataHash.Add( pPlayer.Name + "IP", pPlayer.IP );
  5. }
  6.  

This example will add the player's ip to the database that just joined the server. It can be retrieved via playernameIP.

[edit] Notes

The function onPlayerJoin and Player.IP and Player.Name were used in this example, more info about them in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox