OnPlayerCommand: Difference between revisions
Jump to navigation
Jump to search
This wiki is using an old backup from 2020
Some information may be old/missing
ProsuWANTED (talk | contribs) (Fixed arguments.) |
Decent 946 (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
When a player changes his weapon to newone or oldone. | |||
== Syntax == | == Syntax == | ||
<pre>function | <pre>function onPlayerWeaponChange( player, oldwep, newwep )</pre> | ||
== Parameters == | == Parameters == | ||
* [[Scripting/Squirrel/Functions#Player_Functions|''Player'']] '''player''' - The player | * [[Scripting/Squirrel/Functions#Player_Functions|''Player'']] '''player''' - The player who changes the weapon. | ||
* | * '''oldwep''' - Players old weapon | ||
* | * '''newwep''' - Players new weapon | ||
== Example == | == Example == | ||
If a player will try to change his weapon to "33" ( minigun ), this example will automatically set his weapons ammo to 0. and in result, he won't be able to use that weapon. | |||
<source lang=squirrel> | <source lang=squirrel> | ||
function | function onPlayerWeaponChange( player, oldwep, newwep ) | ||
{ | { | ||
if ( newwep == 33 ) | |||
{ | |||
PrivMessage( player, "it is a blocked weapon" ); | |||
player.SetWeapon( 33,0 ); //sets weapons ammo to 0. | |||
} | |||
return 1; //returns true for other weapons. | |||
} | } | ||
</source> | </source> | ||
Line 32: | Line 30: | ||
=== Notes === | === Notes === | ||
Function [[Scripting/Squirrel/Functions/PrivMessage|''PrivMessage'']] and function [[Scripting/Squirrel/Functions/Player.SetWeapon|''SetWeapon'']] were used in this example. | |||
== Related Events == | == Related Events == | ||
{{Scripting/Squirrel/Events/Player_Events}} | {{Scripting/Squirrel/Events/Player_Events}} |
Revision as of 16:45, 15 March 2016
When a player changes his weapon to newone or oldone.
Syntax
function onPlayerWeaponChange( player, oldwep, newwep )
Parameters
- Player player - The player who changes the weapon.
- oldwep - Players old weapon
- newwep - Players new weapon
Example
If a player will try to change his weapon to "33" ( minigun ), this example will automatically set his weapons ammo to 0. and in result, he won't be able to use that weapon.
function onPlayerWeaponChange( player, oldwep, newwep )
{
if ( newwep == 33 )
{
PrivMessage( player, "it is a blocked weapon" );
player.SetWeapon( 33,0 ); //sets weapons ammo to 0.
}
return 1; //returns true for other weapons.
}
Notes
Function PrivMessage and function SetWeapon were used in this example.
Related Events
- onPlayerJoin( player )
- onPlayerPart( player, reason )
- onPlayerRequestClass( player, classID )
- onPlayerRequestSpawn( player )
- onPlayerSpawn( player )
- onPlayerDeath( player, reason )
- onPlayerKill( killer, player, reason, bodypart )
- onPlayerTeamKill( killer, player, reason, bodypart )
- onPlayerChat( player, message )
- onPlayerCommand( player, command, arguments )
- onPlayerPM( player, playerTo, message )
- onPlayerBeginTyping( player )
- onPlayerEndTyping( player )
- onLoginAttempt( playerName, password, ipAddress )
- onNameChangeable( player ) // Currently can't work.
- onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
- onPlayerHealthChange( player, lastHP, newHP )
- onPlayerArmourChange( player, lastArmour, newArmour )
- onPlayerWeaponChange( player, oldWep, newWep )
- onKeyDown( player, bindID )
- onKeyUp( player, bindID )
- onPlayerAwayChange( player, newStatus )
- onPlayerSpectate( player, target )
- onPlayerCrashDump( player, crashReport )
- onPlayerNameChange( player, oldName, newName )
- onPlayerActionChange( player, oldAction, newAction )
- onPlayerStateChange( player, oldState, newState )
- onPlayerOnFireChange( player, isOnFireNow )
- onPlayerCrouchChange( player, isCrouchingNow )
- onPlayerGameKeysChange( player, oldKeys, newKeys )