Flashbang concept

Scripter or interested in scripting? This place just may fancy to your likings!

Moderators: Game Admins, FM, Lead Admins

User avatar
Ari
- Gold Member -
- Gold Member -
Posts: 211
Joined: Wed Aug 28, 2013 7:33 pm
Location: Australia

Flashbang concept

Post by Ari » Tue May 31, 2016 10:23 am

Flashbang Proof of Concept

Introduction
The inspiration for this, as I create a concept this time comes from Adio's LS-RP videos where he tosses tear gas grenades into rooms which are roleplayed as flashbang grenades. I was limited by the fact that grenades aren't entirely synced and therefore you cannot get the Vector information about the location where they were thrown and landed. I came up with just using shotgun cartridges like the Beanbag rounds that are for non-lethal circumstances. I had created a similar concept a long time ago but never shared it or completed it.

That being said, this is only a proof of concept and I only spent about half an hour writing this.

What does it do? Well you can load your shotgun with "Flashbang" cartridges using /toggleflashshells or /tfs for short, and you shoot at, or near where you want a flashbang to occur. All the players within 15 units of where the shot lands will be blinded with a TextDraw and will get a nice little explosion sound played for them. This forces a player to roleplay the flash, where often or not they will claim they "looked away".


To-do list
  • Make a 3dTextLabel appear where the shot landed, and display how long ago it landed there (Using GetTickCount() but not sure whether or not to remove this feature completely, could be overkill or useless.
  • "Flashed!" to come up above the effected players heads, will disappear when they are no longer flashed. A good indicator for law enforcement to know if someone is suffering the effects
  • Add the "Drunk" effect, getting flashbanged will be disorientating for a player and they shouldn't feel fine afterwards.
  • Allow the shooter to only load a certain amount of shells. This allows them to go straight back to firing lethal 12 Gauge after they've used up their flashbang shells (ex: /toggleflashshells 3 will load 3 flashbang cartridges then revert back to normal buckshot)
  • Add auto RP line for when you load a shell (ex: Ari has loaded three flashbang cartridges into their shotgun.)
  • Convert where appropriate to Incognito's "CreateDynamic_"
  • Add a RP line similar to when a player is tazed (ex: "John was blinded by Ari's flashbang!")


Dependencies
  • ZCMD
  • sscanf
  • Incognito's Streamer


Source Code
The source code is viewable on my GitHub found here


Media
Screenshots:
Spoiler: show
http://i.imgur.com/ZYJRWKj.jpg
http://i.imgur.com/uXHdPDc.png


Videos:
Spoiler: show
Coming soon...


Feel free to expand or completely re-write this code, it was only proof of concept and I was only doing it for some fun!
Image

User avatar
Renz0
Wannabe Don
Wannabe Don
Posts: 2240
Joined: Mon May 02, 2011 3:54 pm
Ingame name: #ElCapitano
Location: Slovakia
Contact:

Re: Flashbang concept

Post by Renz0 » Wed Jun 08, 2016 11:51 pm

Very nice. Such a creative guy you are. I personally like this a lot,man.

User avatar
WizzG
Gangster
Gangster
Posts: 107
Joined: Thu Dec 17, 2015 2:42 pm
Ingame name: Wizzy
Location: Kosovo

Re: Flashbang concept

Post by WizzG » Fri Jun 24, 2016 11:23 am

Nice! :)
| These niggas hate me n' i dont give a fucc |

User avatar
IzDylan
Silver Member
Silver Member
Posts: 61
Joined: Fri Jun 03, 2016 11:14 pm
Location: Africa

Re: Flashbang concept

Post by IzDylan » Fri Jun 24, 2016 11:39 am

Nice. Kinda surprised this isn't implemented. I do think it needs to be tweaked. It's a little overpowered for it to be fired from a shotgun - let alone completely unrealistic. Maybe switch it for the smoke grenade or satchel charge even. Also if someone does actually RP looking away and they get flashed it's kinda unfair for them. Might I suggest directional scripting? If your player model is faced away they wouldn't be affected, if they were exposed one side they'd get half-blinded?

Just my thought. I've seen similar coding done in ArmA before.

User avatar
Ari
- Gold Member -
- Gold Member -
Posts: 211
Joined: Wed Aug 28, 2013 7:33 pm
Location: Australia

Re: Flashbang concept

Post by Ari » Sat Jun 25, 2016 2:28 am

IzDylan wrote:Nice. Kinda surprised this isn't implemented. I do think it needs to be tweaked. It's a little overpowered for it to be fired from a shotgun - let alone completely unrealistic. Maybe switch it for the smoke grenade or satchel charge even. Also if someone does actually RP looking away and they get flashed it's kinda unfair for them. Might I suggest directional scripting? If your player model is faced away they wouldn't be affected, if they were exposed one side they'd get half-blinded?

Just my thought. I've seen similar coding done in ArmA before.


I wrote it simply as a proof of concept, and as I detailed you cannot get vector data from grenades since they're not synced. Thus making the shotgun a good alternative, easily could make it so you can only fire one shot at a time, then you have to wait before you can fire another flashbang.

The only problem with being "Half flashed" is people would still try to shoot at the entering police, but this could easily be countered by applying the player with a drunk effect (which was in my notepad to do, anyway) so I suppose that could be halved too, or possibly depended on their GetPlayerRotation from the impact destination.
Image

User avatar
OPZ
Silver Member
Silver Member
Posts: 64
Joined: Sun Jun 19, 2016 11:38 pm
Location: Canada
Contact:

Re: Flashbang concept

Post by OPZ » Wed Aug 10, 2016 4:38 am

IzDylan wrote:It's a little overpowered for it to be fired from a shotgun
^

It's an amazing idea and I hope it gets implemented, just as long as it's within reason and doesn't give unfair advantages in regards to how the script works. Good luck with this!
Image
W E B D E V E L O P E R
my projects
LS-RP Archive (in development)


Image
Image

User avatar
Private200
Silver Member
Silver Member
Posts: 117
Joined: Thu Feb 11, 2016 10:34 pm

Re: Flashbang concept

Post by Private200 » Tue Aug 16, 2016 1:24 am

I'm not sure about the fX, fY and fZ of OnPlayerWeaponShot (https://wiki.sa-mp.com/wiki/OnPlayerWeaponShot), but I think you are able to retrieve the coordinations you shot at with the shotgun when flashband is active and run a loop to retrieve the ID's of the users around those coordinations and flashbanging them. The flashbang will not work on law enforcers due to wearing some sort of protective thingy that you can work on or that the LEO's will have to RP.

I suggest you to use a fading effect as it is way more real istic than a plain white textdraw disappearing over time.

EDIT: Disregard first part, didn't notice the source code. I like the way you organize things in your code.

User avatar
Ari
- Gold Member -
- Gold Member -
Posts: 211
Joined: Wed Aug 28, 2013 7:33 pm
Location: Australia

Re: Flashbang concept

Post by Ari » Tue Aug 16, 2016 9:34 am

Private200 wrote:I'm not sure about the fX, fY and fZ of OnPlayerWeaponShot (https://wiki.sa-mp.com/wiki/OnPlayerWeaponShot), but I think you are able to retrieve the coordinations you shot at with the shotgun when flashband is active and run a loop to retrieve the ID's of the users around those coordinations and flashbanging them. The flashbang will not work on law enforcers due to wearing some sort of protective thingy that you can work on or that the LEO's will have to RP.

I suggest you to use a fading effect as it is way more real istic than a plain white textdraw disappearing over time.

EDIT: Disregard first part, didn't notice the source code. I like the way you organize things in your code.
I did this as a concept, and I haven't worked on it since I created it. I could've made this so much better looking back now, laziness got the better of me though.

Yeah I spend that little bit of extra time to make sure my code is readable, clear and concise. It does wonders for the eyes.
Image

User avatar
Augisto
Wannabe Don
Wannabe Don
Posts: 1254
Joined: Sun Sep 07, 2014 11:46 am
Ingame name: Frank_Mora
Location: G GUMPY

Re: Flashbang concept

Post by Augisto » Thu Sep 15, 2016 5:31 pm

Wow, creative. I like it, you should make some more shit man, you're good at scripting.

User avatar
Ari
- Gold Member -
- Gold Member -
Posts: 211
Joined: Wed Aug 28, 2013 7:33 pm
Location: Australia

Re: Flashbang concept

Post by Ari » Sun Sep 18, 2016 1:11 am

Augisto wrote:Wow, creative. I like it, you should make some more shit man, you're good at scripting.
Thanks man. I usually just do work when someone wants something, or if I have an idea. But I only publish things that are obviously useful for the community. Check out my github I'm working on a submarine for an organisation on a server, I haven't been working on it lately but my local version is almost ready to receive the last touch ups before testing then I'll release it :)
Image

User avatar
Ari
- Gold Member -
- Gold Member -
Posts: 211
Joined: Wed Aug 28, 2013 7:33 pm
Location: Australia

Re: Flashbang concept

Post by Ari » Mon Sep 19, 2016 3:09 am

Private200 wrote:I'm not sure about the fX, fY and fZ of OnPlayerWeaponShot (https://wiki.sa-mp.com/wiki/OnPlayerWeaponShot), but I think you are able to retrieve the coordinations you shot at with the shotgun when flashband is active and run a loop to retrieve the ID's of the users around those coordinations and flashbanging them. The flashbang will not work on law enforcers due to wearing some sort of protective thingy that you can work on or that the LEO's will have to RP.
I didn't initially respond to this part of your post but I'll just point out the fact that what you described does exactly what I did in my code.

Image
First, I check if the player that fired the shotgun was using flashbang shells. (Line 209)
Then we ensure that the weapon they're firing is the pump action shotgun. (Line 211)
Then we loop through the players (Line 214) and check if they were within 15.0 units of the vector where the shotgun slug lands (Line 216) and if they are, they're flashed.

Adding a feature where LEO's wouldn't be flashed is stupid, in real life they have to look away. Whoever is using this weapon would just have to make sure they don't stand within the range of the flashbang or fire close (danger close) to any friendlies. A device that stops you from being affected doesn't exist and thus shouldn't be roleplayed.

--

I already explained why the feature is done via a shotgun in other posts. I'm willing to answer questions on my thought process, what I designed this for and future plans if anyone is interested just post below.
Image

justice96
Gangster
Gangster
Posts: 96
Joined: Tue Jun 30, 2015 8:45 pm
Location: Indonesia
Contact:

Re: Flashbang concept

Post by justice96 » Wed Nov 09, 2016 5:30 pm

Use SetPlayerDrunkLevel(); instead of textdraw, not bad at all.
Image
Add me to your server

User avatar
Ari
- Gold Member -
- Gold Member -
Posts: 211
Joined: Wed Aug 28, 2013 7:33 pm
Location: Australia

Re: Flashbang concept

Post by Ari » Mon Nov 14, 2016 6:27 am

justice96 wrote:Use SetPlayerDrunkLevel(); instead of textdraw, not bad at all.
"Add the "Drunk" effect, getting flashbanged will be disorientating for a player and they shouldn't feel fine afterwards."

Already was on my notes, I have done this already on my local version too.
Image

F Sullivan
Mafia
Mafia
Posts: 573
Joined: Sun Mar 22, 2015 7:23 am

Re: Flashbang concept

Post by F Sullivan » Wed Nov 16, 2016 10:40 pm

I'd recommend using multiple conditions in one if statement.

Code: Select all

if(GetPVarInt(playerid, "_flashShells") && weaponid == 25) {

}
Also, I think it's generally better practice to return SendClientMessage within your sscanf conditional, rather than using the else clause.

Might I also add that functions such as:

Code: Select all

stock ReturnPlayerName(iPlayerID)
{
    new
        szName[MAX_PLAYER_NAME];

    GetPlayerName(iPlayerID, szName, sizeof(szName));
    return szName;
}
... can be 'deprecated' in a sense. A players name won't change whilst they're online. I'd recommend storing it and using a ReturnPlayerName define if you're going to require names frequently.

User avatar
Ari
- Gold Member -
- Gold Member -
Posts: 211
Joined: Wed Aug 28, 2013 7:33 pm
Location: Australia

Re: Flashbang concept

Post by Ari » Fri Nov 18, 2016 1:16 pm

F Sullivan wrote:I'd recommend using multiple conditions in one if statement.

Code: Select all

if(GetPVarInt(playerid, "_flashShells") && weaponid == 25) {

}
Also, I think it's generally better practice to return SendClientMessage within your sscanf conditional, rather than using the else clause.

Might I also add that functions such as:

Code: Select all

stock ReturnPlayerName(iPlayerID)
{
    new
        szName[MAX_PLAYER_NAME];

    GetPlayerName(iPlayerID, szName, sizeof(szName));
    return szName;
}
... can be 'deprecated' in a sense. A players name won't change whilst they're online. I'd recommend storing it and using a ReturnPlayerName define if you're going to require names frequently.
For the first one that's completely correct, I forgot to add the weapon check and just threw it in quickly so yes it should be multiple condition.

As for the second one this was built on my gamemode, so name changing can occur online. This function is apart of my template that I use so it was just copied over to make code more streamline. This wasn't developed for LS-RP either, this was just a proof of concept. Had this ever made it into the server I'd expect it'd be rewritten anyhow, theres a lot missing from the concept too I was just showing that it is possible.
Image

Post Reply

Return to “Scripting Section”

Who is online

Users browsing this forum: No registered users and 1 guest