ESX_Mugging

Change Log:

Latest Version:

Added cooldown time in Config.CoolDownTime.  Default is set to 30 sec, set to 0 to turn off cooldown.
Added Config.MustUseVoice in config as well.  This will make it so the player has to use ingame voice to activate the mugging.
( I want to add a timeout in this so if you do not hit E or Use voice to start the mugging after a certain time the ped will run away but need find the best solution to get this coded in.  Hopefully next update will have this added)

Previous Fix:

Added check to see if ped is fleeing - no more stopping NPC from full sprint.
Removed the abality to mug NPC from inside vehicle.
Changed the check for target running away - check for target distance. ( no more mugging and running away from NPC and still getting cash)
Added support for BlackMoney in Config.   Just set  Config.DirtyMoney = true   and will payout only BlackMoney.
Fixed error that was showing up on server script for expected then near =
Removed the function to mug animals (funny but unintentional)
Added check for player so you can not mug other players on the server.
Added Police Requirement in Config
Added progressBar support in Config if set to false you do not have to have progressBar installed.
Moved Giveable items to the Config for easier adjusting for server owners.
Fixed ESX.jobname not noticing new job until restart - thanks to XxFri3ndlyxX
Removed Mugging MissionEntityPeds so servers with doctors or clerks stationed around town dont need to worry about them.

Features:

This script will allow anyone other then police to mug locals on a server. This was based off https://github.com/D3uxx/esx_robnpc with a few improvements.

Download:

ESX_Mugging:

Features

  • Can Mug any local you are with-in 5.0m
  • Will receive random amount from Config.MinMoney to Config.MaxMoney - default is 5 - 100
  • Can set Police Notify Percentage - default is set to 40%
  • Can set Always Notify on death - This will always notify Police of Murder if NPC is killed during mugging. Once they start running the script will not notify if you kill them.
  • Must have Weapon that is not from melee/explosive catagory to start a mugging.
  • If you aim at a vehicle that is moving at all (even being pushed) the NPC will ignore the mugging script and act as the game dictates.
  • If you aim at a driver of a stopped vehicle the driver will exit the vehicle and put hands up you can then start the mugging.
  • Player can stop same NPC but if that npc is last one mugged will not be able to mug again.
  • Police Notification gives Alert as well as Circle that will slowly vanish over time (default is 250 seconds - not in Config.lua with this version)

Known Issues:

  • GCPhone support not 100% - has worked on 1 server but another server does not get sms alerts.

Planned Features:

  • I am looking into randomly having the NPC stop and turn to player and take picture. And the Alert would then have mugshot of criminal added instead of the 911 Alert picture.

  • I am looking into having to use voice to get the NPC to react at all. If you point a gun at driver of a car but do not say anything in game they will just drive away after a second or two. If you point at a driver and in game tell them to get out of the vehicle they will step out and raise hands.

Original release had 1 bad line of code that was causing continues cpu usage which has been addressed and is not in this release.

Any questions or comments feel free to send me a msg here and ill respond as soon as i can.

SpikE

26 Likes

Have it tested on 2 different servers and have not had anyone tell me about lost FPS so ill look into it… thnx for the feed back.

edit: lost FPS in general or when aiming only?

I suggest you always look at the resmon while working on a resource

thnx for the reply. Just getting into lua and FiveM did not know about resmon will have a look to find out what is taking up so much resouces and see about getting another relase out.

SpikE

Could you send the link to the Github? I may find the problem for you.

Unlisted until fixed

Thank you to the mod that unlisted this while i figure out the issues. I have put a new version on Github that does address the 2.10ms the entire time the script was running.

Now will only get to around 1.67 while the player is aiming at a ped to mug them. I am trying to see where else i can trim that down a bit.

SpikE

Found the bad line of code that was causing the horrible spike in cpu usage. Taken it out and max spike is now 0.25 while mugging. Updated code on github.

Error on line 35, attempt to index a nil value (field ‘job’)

let me have a look… see if the last edit i did messed something up…

updated github with new code that pulls job. can download new from github… or replace lines 17 - 24 with this

Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)
Citizen.Wait(0)
end

while ESX.GetPlayerData().job == nil do
	Citizen.Wait(10)
end

ESX.PlayerData = ESX.GetPlayerData()

end)

again im finding its the little things that get you with lua.

SpikE

good release ty

would be nice if you would add the option to restrict it to certain ped types.

I can look into adding a PED blacklist… what ped types were you thinking about so i can start looking into it.

Working perfectly now, what a beast script, exactly what i was looking for an gives the perfect building blocks for greater things!

really glad that fixed it for you.

I’m just thinking out loud right now but,

if you added the option in the config where people could put the ped hash in the list and then people would not beable to mug sed ped’s.

as on my server i have certain ped’s placed which are frozen so having this script if people mugged them it would reset the ped and unfreeze them.

not something major important but would be a nice option to have just a suggestion. :slight_smile:

Any idea why some peds in a vehicle stopped get out and put their hands up, and some drive off?

Anyway to force them all to get out if they are stopped?

Edit: Just noticed i’m also getting an error on line 127 of main, attempt to index a nil value (global ‘PlyPos’)

Just fixed the error you saw with line 127 had to deal with police notification locations.

As far as the peds in vehicles. I used IsVehicleStopped stopped to determine if Ped is not moving. With is fuction if the vehicle is getting pushed at all it will consider it not stopped - and the script will make the ped ignore the mugging and act as the game dictates. I assume this is what you are seeing.

The new version of main_c.lua on github should fix the error you were getting for line 127.

SpikE