OnPlayerWeaponChange: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
(Created page with "__NOTOC__ When a player changes his weapon to newone or oldone. == Syntax == <pre>function onPlayerWeaponChange( player, oldwep, newwep )</pre> == Parameters == * Script...")
 
No edit summary
 
Line 32: Line 32:
Function [[Scripting/Squirrel/Functions/PrivMessage|''PrivMessage'']] and function [[Scripting/Squirrel/Functions/Player.SetWeapon|''SetWeapon'']] were used in this example.
Function [[Scripting/Squirrel/Functions/PrivMessage|''PrivMessage'']] and function [[Scripting/Squirrel/Functions/Player.SetWeapon|''SetWeapon'']] were used in this example.


== Related Events ==
== Related Functions ==


{{Scripting/Squirrel/Events/Player_Events}}
{{Scripting/Squirrel/Events/Player_Events}}
[[Category:Scripting/Squirrel/Events/Player_Events]]

Latest revision as of 22:16, 30 January 2017

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 Functions