This article's documentation is for anything that uses the Source engine. Click here for more information.

Spraycan: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(note)
No edit summary
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Ent not in fgd|nolink=1}}
{{TabsBar|main=Spraycan}}
{{Ent not in fgd|codeonly=1}}
{{CD|CSprayCan|file1=player.cpp}}
{{CD|CSprayCan|file1=player.cpp}}
{{this is a|point entity|name=spraycan|except=Counter-Strike: Global Offensive}} This is the entity that applies player-chosen spray on walls when they use their spray bind.
{{This is a|point entity|name=spraycan|except=Counter-Strike: Global Offensive}} This is the entity that applies player-chosen spray on walls when they use their spray bind ({{cmd|impulse|201}}).
{{note|Only one spray can be active at once and can be used only on {{ent|worldspawn}} brushes}}


== ConVars ==
== ConVars ==
Line 10: Line 12:
{{varcom|cl_playerspraydisable|0||Disable visibility of player sprays.}}
{{varcom|cl_playerspraydisable|0||Disable visibility of player sprays.}}
{{varcom|end}}
{{varcom|end}}
== Example vscript use ==
{{note|Tested in {{l4d2}}}}
Can be used to spray a spray of a chosen connected player. Following function takes player handle of a player from whose eye position and angles spraycan is created at and handle of the player whose spray we want to use.
<syntaxhighlight lang=js>
function SprayDummy() {}
function Spray(sprayer, sprayowner) {
    local spraycan = SpawnEntityFromTable("spraycan", {
    origin = sprayer.GetCenter() + Vector(0,0,32),
    angles = sprayer.EyeAngles().ToKVString(),
    vscripts = "spraycan_setup", //vscripts key needs to be non-empty for the entity to work, can be even non existent file but that prints warning to console
        nextthink = 1, //won't work without this
    thinkfunction = "SprayDummy" //thinkfunction key needs to be non-empty for the entity to work
    });
NetProps.SetPropEntity(spraycan, "m_hOwnerEntity", sprayowner);
EmitSoundOn("SprayCan.Paint", spraycan);
DoEntFire("!self", "Kill", "", 2, null, spraycan);
}
</syntaxhighlight>


== See also ==
== See also ==
* {{ent|info_projecteddecal}}
* {{ent|info_projecteddecal}}
* {{ent|infodecal}}
* {{ent|infodecal}}

Latest revision as of 09:31, 19 May 2025

edit
Icon-NotInFGD.png
This entity is not in the FGD by default.
It should not be put directly in a map because it can only be configured through code.
C++ Class hierarchy
CSprayCan
CPointEntity
CBaseEntity
C++ player.cpp

spraycan is a point entity available in all Source Source games except Counter-Strike: Global Offensive Counter-Strike: Global Offensive. This is the entity that applies player-chosen spray on walls when they use their spray bind (impulse 201).

Note.pngNote:Only one spray can be active at once and can be used only on worldspawn brushes

ConVars

Cvar/Command Parameters or default value Descriptor Effect
decalfrequency 10 seconds How much must a player wait in seconds before they are able to spray another time
r_spray_lifetime 10 Number of rounds player sprays are visible
Note.pngNote:In Left 4 Dead seriesLeft 4 Dead series sprays disappear after r_spray_lifetime / 2 rounds
cl_logofile Spraypoint logo decal.
cl_playerspraydisable 0 Disable visibility of player sprays.

Example vscript use

Note.pngNote:Tested in Left 4 Dead 2

Can be used to spray a spray of a chosen connected player. Following function takes player handle of a player from whose eye position and angles spraycan is created at and handle of the player whose spray we want to use.

function SprayDummy() {}
function Spray(sprayer, sprayowner) {
    local spraycan = SpawnEntityFromTable("spraycan", {
    	origin = sprayer.GetCenter() + Vector(0,0,32),
    	angles = sprayer.EyeAngles().ToKVString(),
    	vscripts = "spraycan_setup", //vscripts key needs to be non-empty for the entity to work, can be even non existent file but that prints warning to console
        nextthink = 1, //won't work without this
    	thinkfunction = "SprayDummy" //thinkfunction key needs to be non-empty for the entity to work
    });
	NetProps.SetPropEntity(spraycan, "m_hOwnerEntity", sprayowner);
	EmitSoundOn("SprayCan.Paint", spraycan);
	DoEntFire("!self", "Kill", "", 2, null, spraycan);
}

See also