Squirrel/Server/Functions/Players/Alpha

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example 1. Returning)
(Cleaned up the page)
 
Line 13: Line 13:
 
== Example 1. Returning ==
 
== Example 1. Returning ==
  
{{Squirrel/NeedsExample}}
+
This example will let the player know their current alpha setting when they type '/getalpha'.
What does this example do
+
  
 
<code lang="squirrel">
 
<code lang="squirrel">
 
function onPlayerCommand( pPlayer, szCommand, szText )
 
function onPlayerCommand( pPlayer, szCommand, szText )
 
{
 
{
if ( szCommand == "setalpha" )
+
    if ( szCommand == "getalpha" )
{
+
    {
MessagePlayer( "Your alpha state is currently set to " + pPlayer.Alpha, pPlayer );
+
          MessagePlayer( "Your alpha state is currently set to " + pPlayer.Alpha, pPlayer );
}
+
    }
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 28: Line 29:
 
=== Notes ===
 
=== Notes ===
  
--Todo
+
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them can be found in the corresponding pages.
Used functions/events and other notes
+
  
 
== Example 2. Setting ==
 
== Example 2. Setting ==
  
{{Squirrel/NeedsExample}}
+
This example will set the player almost completely transparent when they type '/ghost'.
What does this example do
+
  
 
<code lang="squirrel">
 
<code lang="squirrel">
 
function onPlayerCommand( pPlayer, szCommand, szText )
 
function onPlayerCommand( pPlayer, szCommand, szText )
 
{
 
{
if ( szCommand == "setalpha" )
+
    if ( szCommand == "ghost" )
{
+
    {
if ( szText ) pPlayer.Alpha = text.tointeger();
+
          pPlayer.Alpha = 10;
}
+
    }
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 48: Line 49:
 
=== Notes ===
 
=== Notes ===
  
--Todo
+
The event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in in this example. More info about this in the corresponding page.
Used functions/events and other notes
+
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Players}}
 
{{Squirrel/Server/Functions/Players}}

Latest revision as of 00:43, 17 November 2010

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

This Player class variable sets/returns the alpha of the player ped. Note that this settings does not affect weapons or special skins.

[edit] Syntax

  1. int player.Alpha
  1. player.Alpha = int alpha

[edit] Arguments

  • alpha - The alpha value you wish to set (0...255)

[edit] Example 1. Returning

This example will let the player know their current alpha setting when they type '/getalpha'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "getalpha" )
  5. {
  6. MessagePlayer( "Your alpha state is currently set to " + pPlayer.Alpha, pPlayer );
  7. }
  8. return 1;
  9. }
  10.  

[edit] Notes

The function MessagePlayer and event onPlayerCommand were used in this example. More info about them can be found in the corresponding pages.

[edit] Example 2. Setting

This example will set the player almost completely transparent when they type '/ghost'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "ghost" )
  5. {
  6. pPlayer.Alpha = 10;
  7. }
  8. return 1;
  9. }
  10.  

[edit] Notes

The event onPlayerCommand was used in in this example. More info about this in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox