- Joined
- Apr 12, 2019
- Messages
- 357
it isnt pushing them enough
CSS:
function Push() {
local playerperson = getplayerbyplayer(activator)
local power = playerperson.push
local playert = activator.entindex()
local guy = ToExtendedPlayer( VS.GetPlayerByIndex(playert) );
local forwardVector = guy.EyeForward()
local scope = caller.GetScriptScope()
local front = activator.EyePosition() + (Vector(guy.EyeForward().x, guy.EyeForward().y, 0) * 64) //supposed to be a vector 64 units in front of the player
local frontb = activator.EyePosition() + (Vector(guy.EyeForward().x, guy.EyeForward().y, 0) * 32) //supposed to be a vector 64 units in front of the player
local closestplayer = null;
if (playerperson.push == false) {
local allplayers = VS.GetAllPlayers()
foreach (index, player in allplayers) {
if (player == activator) {
continue;
}
local curPlayerdist = (player.GetOrigin() - frontb).Length2D()
if (curPlayerdist < 20) {
if (!closestplayer) {
closestplayer = player
}
if ((closestplayer.GetOrigin() - frontb).Length2D() > curPlayerdist) {
closestplayer = player
}
}
}
}
if (playerperson.push == false){
if (closestplayer) {
playerperson.push = true;
local pushhard = (Vector(guy.EyeForward().x, guy.EyeForward().y, 0) * 1000)
pushhard.z = 128;
//printl(pushhard)
closestplayer.SetVelocity(pushhard)
PlaySound(activator.GetOrigin(), "physics/body/body_impact_self_06.wav", "2000");
}
}
else if (playerperson.push == true){
local script = Entities.FindByName(null, "script_chair")
if (script) {
if (playerperson.spam == false) {
EntFireByHandle(script, "RunScriptCode", "ResetPush()", 6, activator, null)
}
playerperson.spam = true;
}
}
}





