[Release] Player bullet was off (meters) from victim
-
Put this in onplayerconnect:
player.first = true;Put this in onplayerspawned and run it only once:
if (self.first) { self thread watchBullet(); self.first = false; }Put this anywhere in your code:
watchBullet() { /* If you want the victim who about got hit on to recieve a message, you would do: player iprintln(self.name " almost hit you"); */ self endon("death"); self endon("disconnect"); level endon("game_ended"); for(;;) { self waittill("weapon_fired"); // you can edit this to your liking but this worked for me radius = 100; maxDist = 110; forward = self getTagOrigin("j_head"); end = vectorScale(anglestoforward(self getPlayerAngles()), 1000000); predictedLoc = bulletTrace( forward, end, false, self )["position"]; foreach(player in level.players) { // found the teambased vars in a dump, probably helpful. its in there just in case (: if( !isAlive(player) || player == self || player.team == self.team && level.teamBased ) { continue; } } dist = distance(player.origin, predictedLoc); if(dist < radius && dist <= maxDist) { self iprintln("Shot ^6" + int(distance(self.origin, attacker.origin)*0.0254) + " ^7meters off of ^6" + player.name); } } }You can edit the radius and maxDist variable but I only recommend if you know what you are doing. I don't think any external functions are needed but if you get a error at vectorScale, make sure your includes are correct or you have a vectorScale function.
-
Just in case you need it:
vectorScale(vec,scale) { vec=(vec[0]*scale,vec[1]*scale,vec[2]*scale); return vec; } -
Just in case you need it:
vectorScale(vec,scale) { vec=(vec[0]*scale,vec[1]*scale,vec[2]*scale); return vec; }mikey said in [Release] Player bullet was off (meters) from victim:
Just in case you need it:
vectorScale(vec,scale) { vec=(vec[0]*scale,vec[1]*scale,vec[2]*scale); return vec; }Last I checked you can't use a variable before initializing it and expect it to work
predictedLoc = bulletTrace( forward, end, false, self )["position"];
end = vectorScale(anglestoforward(self getPlayerAngles()), 1000000); -
mikey To do that you can use the EB code, you can find the code for this type of EB online, is a free to use.
I don't know why you keep calling radius and mixDist for every single shoot, is not necessary.watch_player_near(){ radius = 100; for(;;) { self waittill("weapon_fired"); end = vectorScale(anglestoforward(self getPlayerAngles()), 1000000); forward = self getTagOrigin("j_head"); predictedLoc = bulletTrace( forward, end, false, self )["position"]; foreach(player in level.players) { if( isAlive(player) && player != self || (player.team != self.team && level.teamBased) ){ if(distance(player.origin, predictedLoc) < radius) self iprintln("Shot ^6" + int(distance(self.origin, player.origin)*0.0254) + " ^7meters off of ^6" + player.name); } } } }I don't know why you use a maximum distance, everyone can be hit if you don't have a limit (like in my servers, in my server you can hit enemy to close).
The attacker is not defined in this function. I don't know what is the point of calling the attacker. -
mikey said in [Release] Player bullet was off (meters) from victim:
Just in case you need it:
vectorScale(vec,scale) { vec=(vec[0]*scale,vec[1]*scale,vec[2]*scale); return vec; }Last I checked you can't use a variable before initializing it and expect it to work
predictedLoc = bulletTrace( forward, end, false, self )["position"];
end = vectorScale(anglestoforward(self getPlayerAngles()), 1000000);Matrix my bad, rushed the code and forgot to double look
-
mikey To do that you can use the EB code, you can find the code for this type of EB online, is a free to use.
I don't know why you keep calling radius and mixDist for every single shoot, is not necessary.watch_player_near(){ radius = 100; for(;;) { self waittill("weapon_fired"); end = vectorScale(anglestoforward(self getPlayerAngles()), 1000000); forward = self getTagOrigin("j_head"); predictedLoc = bulletTrace( forward, end, false, self )["position"]; foreach(player in level.players) { if( isAlive(player) && player != self || (player.team != self.team && level.teamBased) ){ if(distance(player.origin, predictedLoc) < radius) self iprintln("Shot ^6" + int(distance(self.origin, player.origin)*0.0254) + " ^7meters off of ^6" + player.name); } } } }I don't know why you use a maximum distance, everyone can be hit if you don't have a limit (like in my servers, in my server you can hit enemy to close).
The attacker is not defined in this function. I don't know what is the point of calling the attacker.Sorex my bad, i completely rushed the code and did not take a second to relook and fix stuff. i take blame

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login