Counter Strike Online Wiki
Advertisement

Game rule object


Fields[]

Game.Rule.name[]

Gets or changes the rule name. Used as a comment.


Game.Rule.desc[]

Gets or changes the rule description. Used as a comment.


Game.Rule.user[]

A table that can store arbitrary data.


Game.Rule.respawnable[]

Gets or changes whether the player is respawning.
Full browser world settings are ignored.
  • respawnable: (bool) (default: true)


Game.Rule.respawnTime[]

Gets or changes the player respawn time in seconds.
Full browser world settings are ignored.
You can change from 0 to 60 seconds.
  • respawnTime: (number) (default: 5)


Game.Rule.enemyfire[]

Gets or changes whether another team is attacking.
Full browser world settings are ignored.
  • enemyfire: (bool) (default: true)


Game.Rule.friendlyfire[]

Gets or changes whether an attack is friendly.
Full browser world settings are ignored.
  • friendlyfire: (bool) (default: false)


Game.Rule.breakable[]

Gets or changes the player's map destruction function.
Full browser world settings are ignored.
  • breakable: (bool) (default: false)


Methods[]

Game.Rule: Win (team, exit)[]

The specific team wins.
Without the exit argument, the game ends after winning.
Parameters:
  • team: (Game.TEAM)
  • exit: (Optional bool) Whether to end the game after winning


Game.Rule: Respawn ()[]

All players are forced to respawn.


Game.Rule: CanSave ()[]

Check if the current map can be saved.
Returns true if the group is specified.
See Help for more information
Returns:
(bool) Whether to enable storage


Game.Rule: SetGameSave (name, value)[]

Add values ​​to be stored in the group.
This data is shared among the same groups regardless of the player.
See Help for more information
Parameters:


Game.Rule: GetGameSave (name)[]

Get the values ​​stored in the group.
This data is shared among the same groups regardless of the player.
If name does not exist, returns nil.
See Help for more information
Parameters:
Returns:
(number , string, bool or nil) stored value


Event Callback[]

Game.Rule: OnPlayerConnect (player)[]

Event callback that is called when the player connects.
Parameters:
  • player: (Game.Player)


Game.Rule: OnPlayerDisconnect (player)[]

Event callback that is called when the player closes the connection.
Parameters:
  • player: (Game.Player)


Game.Rule: OnRoundStart ()[]

Event callback that is called when the round starts.


Game.Rule: OnRoundStartFinished ()[]

This event callback is called after the round start process is over. Write tasks such as initialization of the map to this function.


Game.Rule: OnPlayerSpawn (player)[]

Event callback that is called when the player spawns.
Parameters:
  • player: (Game.Player)


Game.Rule: OnPlayerJoiningSpawn (player)[]

Event callback that is called when the player first spawns after selecting a class.
Parameters:
  • player: (Game.Player)


Game.Rule: OnPlayerKilled (victim, killer, weapontype, hitbox)[]

An event callback that is called when the player dies.
Parameters:
  • victim: (Game.Player) Attacked player
  • killer: (Game.Player or nil) nil if killed for reasons other than player attack
  • weapontype: (Game.WeaponType) Type of weapon attacked
  • hitbox: (Game.HitBox) Attacked Area


Game.Rule: OnKilled (victim, killer)[]

An event callback that is called when the player or monster dies.
Parameters:
  • victim: (Game.Entity) Attacked entity
  • killer: (Game.Entity or nil) If reasons other than death attack of an entity, nil


Game.Rule: OnPlayerSignal (player, signal)[]

Event callback that is called when UI.Signal is used.
Parameters:
  • player: (Game.Player) The signaled player
  • signal: (int) Signal value sent by player


Game.Rule: OnUpdate (time)[]

This is an event callback that is called every certain time.
Called about every 0.1 seconds.
Parameters:
  • time: (number) Current game time


Game.Rule: OnPlayerAttack (victim, attacker, damage, weapontype, hitbox)[]

Event callback that is called when the player is attacked.
You can change the damage received by returning an arbitrary number.
Parameters:
  • victim: (Game.Player) attacked player
  • attacker: (Game.Player or nil) attacking player (nil if not player)
  • damage: (int) damage
  • weapontype: (Game.WeaponType) Type of weapon attacked
  • hitbox: (Game.HitBox) Attacked Area
Returns:
(Optional int) Damage changed
Usage:
function Game.Rule: OnPlayerAttack (victim, attacker, damage, weapontype, hitbox)
   -If a melee weapon has 0 damage
   if weapontype == Game.WEAPONTYPE.KNIFE then return 0 
   -Otherwise, the damage is received
end


Game.Rule: OnTakeDamage (victim, attacker, damage, weapontype, hitbox)[]

An event callback that is called when a player or monster is attacked.
You can change the damage received by returning an arbitrary number.
Parameters:
Returns:
(Optional int) Damage changed


Game.Rule: CanBuyWeapon (player, weaponid)[]

An event callback that checks if a weapon can be purchased. Weapons that are not on the list of script weapons are not called.
Parameters:
  • player (Game.Player) target player
  • weaponid: (Common.WEAPON) Weapon Type
Returns:
(bool) true if a weapon can be purchased


Game.Rule: CanHaveWeaponInHand (player, weaponid, weapon)[]

An event callback that checks to see if a weapon is available. Weapons that are not on the list of script weapons are not called. If no Weapon class has been used, the weapon argument is passed as nil.
Parameters:
  • player: (Game.Player) target player
  • weaponid: (Common.WEAPON) Weapon Type
  • weapon: (Game.Weapon or nil) weapon
Returns:
(bool) true if you can get a weapon


Game.Rule: OnGetWeapon (player, weaponid, weapon)[]

An event callback called when a weapon is acquired. Weapons that are not on the list of script weapons are not called. If no Weapon class has been used, the weapon argument is passed as nil.
Parameters:
  • player: (Game.Player) target player
  • weaponid: (Common.WEAPON) Weapon Type
  • weapon: (Game.Weapon or nil) weapon


Game.Rule: OnReload (player, weapon, time)[]

This is an event callback called when loading. If the Weapon class has never been used or is not a script weapon, the weapon argument is passed as nil.
Parameters:
  • player: (Game.Player) target player
  • weapon: (Game.Weapon or nil) weapon
  • time: (number) Time required for loading


Game.Rule: OnReloadFinished (player, weapon)[]

This is an event callback called after the loading is over. If the Weapon class has never been used or is not a script weapon, the weapon argument is passed as nil.
Parameters:
  • player: (Game.Player) target player
  • weapon: (Game.Weapon or nil) weapon


Game.Rule: OnSwitchWeapon (player)[]

This is an event callback called when replacing a weapon.
Parameters:
  • player: (Game.Player) target player


Game.Rule: PostFireWeapon (player, weapon, time)[]

This is an event callback called after launch. If the Weapon class has never been used or is not a script weapon, the weapon argument is passed as nil.
Parameters:
  • player: (Game.Player) target player
  • weapon: (Game.Weapon or nil) weapon
  • time: (number) Time taken to launch next


Game.Rule: OnGameSave (player)[]

This event callback is called when save information for each player is saved.
Parameters:
  • player: (Game.Player) target player


Game.Rule: OnLoadGameSave (player)[]

This event callback is called when save information for each player is loaded.
Parameters:
  • player: (Game.Player) target player


Game.Rule: OnClearGameSave (player)[]

This event callback is called when deleting save information for each player.
Parameters:
  • player: (Game.Player) target player
Advertisement