spraycan
Jump to navigation
Jump to search

![]() |
---|
CSprayCan |
![]() |
spraycan
is an entity available in all Source games except
Counter-Strike: Global Offensive. This is the entity that applies player-chosen spray on walls when they use their spray bind (impulse 201).
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 | |
cl_logofile | Spraypoint logo decal. | ||
cl_playerspraydisable | 0 | Disable visibility of player sprays. |
Example vscript use
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 and userid of player whose spray we want to use.
function Spray(sprayer, userid) {
SpawnEntityFromTable("spraycan", {
vscripts = "spraycan_setup",
target = ""+userid, //passing userid via target keyvalue (of course can be achieved in other ways)
origin = sprayer.EyePosition(),
angles = sprayer.EyeAngles().ToKVString(),
nextthink = 1, //won't work without this
thinkfunction = "RocketRaccoonSupremacy" //existing thinkfunction needs to be specified for the entity to work
});
}
spraycan_setup.nut
contains:
function RocketRaccoonSupremacy() {
EntFire("!self", "Kill", "", 2); //entity killed after 2 seconds just in case something fails
return 999;
}
local target = NetProps.GetPropString(self, "m_target");
local id = target.tointeger();
local player = GetPlayerFromUserID(id);
NetProps.SetPropEntity(self, "m_hOwnerEntity", player);
EmitSoundOn("SprayCan.Paint", self);