is player behind object
#1

Hi. I've been thinking of adding a flashbang system to my script so I've been wondering if it's possible to check if player is behind an object or something like that? I want to make it like that when a player throws a flashbang he can run behind a wall so he won't get blind. That's the only thing that's stopping me from making it.
Reply
#2

Using ColAndreas could help you to achieve this.

https://sampforum.blast.hk/showthread.php?tid=586068
Reply
#3

I don't know how to make it with ColAndreas. Could anyone help?
Reply
#4

There's another way to it, you can use AbyssMorgan's IsElementOnPlayerScreen to see if the flashbang object was seen by the player and thus flash him: https://www.youtube.com/watch?v=ih9P_Cwkz68
Reply
#5

Quote:
Originally Posted by Battlezone
Посмотреть сообщение
There's another way to it, you can use AbyssMorgan's IsElementOnPlayerScreen to see if the flashbang object was seen by the player and thus flash him: https://www.youtube.com/watch?v=ih9P_Cwkz68
Thanks, that's exactly what I wanted before, but it would be too easy to avoid the flashbang if player could just turn their screen away. What I want is to check if there's something like a wall between the player and the flashbang. Is that possible with ColAndreas? If not then I think I'll use IsElementOnPlayerScreen.
Reply
#6

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
Thanks, that's exactly what I wanted before, but it would be too easy to avoid the flashbang if player could just turn their screen away. What I want is to check if there's something like a wall between the player and the flashbang. Is that possible with ColAndreas? If not then I think I'll use IsElementOnPlayerScreen.
That's definitely possible, but I'm actually too busy to search the appropriate functions as I've almost never used it before and am pretty unexperienced, so just wait for someone used with it to help
Edit: A simple proof that it is possible is that people use in NPC systems, you would see NPCs changing directions whenever they come across walls in some servers
Edit: Another way to it is to use simple Ray casting, it makes a virtual line between the player and the flashbang objects and checks if an objects is between them, but according to my knowledge, I know how to code it only in case a created object is between those 2, not a world object, maybe this would help though if you find a function in colandreas that helps in detecting world objects
Reply
#7

About Screen function:
Reply
#8

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
About Screen function:
It's solved then, you just have to find code Abyss used for walls detection in his screen script
Reply
#9

Quote:
Originally Posted by Battlezone
Посмотреть сообщение
It's solved then, you just have to find code Abyss used for walls detection in his screen script
OK, thanks, I'll have a look tomorrow.
Reply
#10

If anyone has the same question then I could achieve that by using CA_RayCastLine and IsPlayerFacingPoint. I used CA_RayCastLine to check if there's something between the player and the flashbang and IsPlayerFacingPoint obviously to check if player is even facing the flashbang. That's all to know whether the character sees the flashbang, not the player itself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)