mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-15 08:17:57 +03:00
Created VScript : Filters (markdown)
parent
0a6764290d
commit
acfb4c6308
57
VScript-:-Filters.md
Normal file
57
VScript-:-Filters.md
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
Mapbase associates filters with VScript in a few different ways.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
Mapbase adds a few new functions which could be used on entity handles in VScript code:
|
||||||
|
|
||||||
|
* `PassesFilter`
|
||||||
|
* `PassesDamageFilter`
|
||||||
|
* `PassesFinalDamageFilter`
|
||||||
|
* `BloodAllowed`
|
||||||
|
* `DamageMod`
|
||||||
|
|
||||||
|
These are documented in more detail on the [[VScript in Mapbase]] article. They can be used like this:
|
||||||
|
|
||||||
|
```squirrel
|
||||||
|
function CheckIfPassFilter( entity )
|
||||||
|
{
|
||||||
|
local filter = Entities.FindByName(null,"filter_acceptable")
|
||||||
|
|
||||||
|
if ( filter != null )
|
||||||
|
{
|
||||||
|
return filter.PassesFilter( self, entity )
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## filter_script
|
||||||
|
|
||||||
|
**filter_script** is a new filter entity which uses its entity scripts for all regular filter functions, including functions new with Mapbase.
|
||||||
|
|
||||||
|
For example, the following code uses the `PassesFilter` hook to only pass activators with a weapon that has <10 ammo in it:
|
||||||
|
```squirrel
|
||||||
|
function PassesFilter()
|
||||||
|
{
|
||||||
|
if (activator.GetActiveWeapon())
|
||||||
|
{
|
||||||
|
local ammo = activator.GetActiveWeapon().Clip1()
|
||||||
|
if (ammo < 10)
|
||||||
|
{
|
||||||
|
printl("Has weapon with <10 ammo, damaging")
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printl("Has weapon with " + ammo + " ammo, no damage")
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printl("Returning false")
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user