forked from AlterGamingNetwork/mellotrainer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcl_settings_notifications.lua
178 lines (150 loc) · 6.41 KB
/
cl_settings_notifications.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
--[[--------------------------------------------------------------------------
*
* Mello Trainer
* (C) Michael Goodwin 2017
* http://github.com/thestonedturtle/mellotrainer/releases
*
* This menu used the Scorpion Trainer as a framework to build off of.
* https://github.com/pongo1231/ScorpionTrainer
* (C) Emre Cürgül 2017
*
* A lot of useful functionality has been converted from the lambda menu.
* https://lambda.menu
* (C) Oui 2017
*
* Additional Contributors:
* WolfKnight (https://forum.fivem.net/u/WolfKnight)
*
---------------------------------------------------------------------------]]
local selfDeathMessage = "~o~You ~s~died."
local deathSuicideMessage = "~o~You ~s~commited suicide."
-- Hold dead players to prevent multiple messages.
local deadPlayers = {}
RegisterNUICallback("notifications", function(data, cb)
local action = data.action
local state = data.newstate
local request = data.data[3]
local text,text2
if(state) then
text = "~g~ON"
text2 = "~r~OFF"
else
text = "~r~OFF"
text2 = "~g~ON"
end
if(action=="players")then
featurePlayerNotifications = state
drawNotification("Player Notifications: "..text)
elseif(action=="death")then
featureDeathNotifications = state
drawNotification("Death Notifications: "..text)
end
if(cb)then cb("ok") end
end)
RegisterNetEvent( 'mellotrainer:playerJoined' )
AddEventHandler( 'mellotrainer:playerJoined', function( ID )
local id = tonumber( ID )
if ( featurePlayerNotifications and id ~= PlayerId() ) then
local name = GetPlayerName( id )
drawNotification( "~g~<C>"..name.."</C> ~s~joined." )
end
end )
RegisterNetEvent( 'mellotrainer:playerLeft' )
AddEventHandler( 'mellotrainer:playerLeft', function( person )
if ( featurePlayerNotifications ) then
drawNotification( "~r~<C>" .. person.name .. "</C> ~s~left." )
end
end )
-- Better Death Messages
function killActionFromWeaponHash(weaponHash)
if (weaponHash ~= nil)then
if (weaponHash == GetHashKey("WEAPON_RUN_OVER_BY_CAR") or weaponHash == GetHashKey("WEAPON_RAMMED_BY_CAR")) then
return "flattened";
end
if (weaponHash == GetHashKey("WEAPON_CROWBAR") or weaponHash == GetHashKey("WEAPON_BAT") or weaponHash == GetHashKey("WEAPON_HAMMER") or weaponHash == GetHashKey("WEAPON_GOLFCLUB") or weaponHash == GetHashKey("WEAPON_NIGHTSTICK") or weaponHash == GetHashKey("WEAPON_KNUCKLE")) then
return "whacked";
end
if (weaponHash == GetHashKey("WEAPON_DAGGER") or weaponHash == GetHashKey("WEAPON_KNIFE")) then
return "stabbed";
end
if (weaponHash == GetHashKey("WEAPON_SNSPISTOL") or weaponHash == GetHashKey("WEAPON_HEAVYPISTOL") or weaponHash == GetHashKey("WEAPON_VINTAGEPISTOL") or weaponHash == GetHashKey("WEAPON_PISTOL") or weaponHash == GetHashKey("WEAPON_APPISTOL") or weaponHash == GetHashKey("WEAPON_COMBATPISTOL") or weaponHash == GetHashKey("WEAPON_SNSPISTOL")) then
return "shot";
end
if (weaponHash == GetHashKey("WEAPON_GRENADELAUNCHER") or weaponHash == GetHashKey("WEAPON_HOMINGLAUNCHER") or weaponHash == GetHashKey("WEAPON_STICKYBOMB") or weaponHash == GetHashKey("WEAPON_PROXMINE") or weaponHash == GetHashKey("WEAPON_RPG") or weaponHash == GetHashKey("WEAPON_EXPLOSION") or weaponHash == GetHashKey("VEHICLE_WEAPON_TANK")) then
return "bombed";
end
if (weaponHash == GetHashKey("WEAPON_MICROSMG") or weaponHash == GetHashKey("WEAPON_SMG") or weaponHash == GetHashKey("WEAPON_ASSAULTSMG") or weaponHash == GetHashKey("WEAPON_MG") or weaponHash == GetHashKey("WEAPON_COMBATMG") or weaponHash == GetHashKey("WEAPON_COMBATPDW") or weaponHash == GetHashKey("WEAPON_MINIGUN")) then
return "sprayed";
end
if (weaponHash == GetHashKey("WEAPON_ASSAULTRIFLE") or weaponHash == GetHashKey("WEAPON_CARBINERIFLE") or weaponHash == GetHashKey("WEAPON_ADVANCEDRIFLE") or weaponHash == GetHashKey("WEAPON_BULLPUPRIFLE") or weaponHash == GetHashKey("WEAPON_SPECIALCARBINE") or weaponHash == GetHashKey("WEAPON_GUSENBERG")) then
return "rifled";
end
if (weaponHash == GetHashKey("WEAPON_MARKSMANRIFLE") or weaponHash == GetHashKey("WEAPON_SNIPERRIFLE") or weaponHash == GetHashKey("WEAPON_HEAVYSNIPER") or weaponHash == GetHashKey("WEAPON_ASSAULTSNIPER") or weaponHash == GetHashKey("WEAPON_REMOTESNIPER")) then
return "sniped";
end
if (weaponHash == GetHashKey("WEAPON_BULLPUPSHOTGUN") or weaponHash == GetHashKey("WEAPON_ASSAULTSHOTGUN") or weaponHash == GetHashKey("WEAPON_PUMPSHOTGUN") or weaponHash == GetHashKey("WEAPON_HEAVYSHOTGUN") or weaponHash == GetHashKey("WEAPON_SAWNOFFSHOTGUN")) then
return "shotgunned";
end
if (weaponHash == GetHashKey("WEAPON_HATCHET") or weaponHash == GetHashKey("WEAPON_MACHETE")) then
return "eviscerated";
end
if (weaponHash == GetHashKey("WEAPON_MOLOTOV")) then
return "torched";
end
return "murdered";
end
return "murdered";
end
-- Other Player died
function handlePlayerDeathMessage( pedID, currentPed )
local me = PlayerId()
local entity, weaponHash = NetworkGetEntityKillerOfPlayer( pedID )
local name = GetPlayerName( pedID )
local msg = "~o~<C>" .. name .. "</C> ~s~died."
if ( IsPedAPlayer( entity ) ) then
local killer = NetworkGetPlayerIndexFromPed( entity )
local kname = GetPlayerName( killer )
if ( kname == name ) then
msg = "~o~<C>" .. name .. "</C> ~s~commited suicide."
elseif ( kname == GetPlayerName( me ) )then
msg = "~o~<C>You</C> ~s~" .. killActionFromWeaponHash( weaponHash ) .. " ~o~<C>" .. name .. "</C>~s~."
else
msg = "~y~<C>" .. kname .. "</C> ~s~" .. killActionFromWeaponHash( weaponHash ) .. " ~o~<C>" .. name .. "</C>~s~."
end
end
drawNotification( msg )
end
-- Check for death messages
function checkForDeaths()
local me = PlayerId()
for i = 0, maxPlayers, 1 do
if ( NetworkIsPlayerConnected( i ) ) then
local currentPed = GetPlayerPed( i )
if ( DoesEntityExist( currentPed ) and IsEntityDead( currentPed ) ) then
if(deadPlayers[i] == nil)then
TriggerEvent("mellotrainer:playerDeath", i)
deadPlayers[i] = true
end
else
deadPlayers[i] = nil
end
end
end
end
Citizen.CreateThread( function()
while true do
Citizen.Wait( 0 )
checkForDeaths()
end
end )
AddEventHandler("mellotrainer:playerDeath", function(id)
local ped = GetPlayerPed(id)
-- Death Notifications
if(featureDeathNotifications)then
handlePlayerDeathMessage( id, ped )
end
-- Restore Appearance
if(featureRestoreAppearance and id == PlayerId())then
savePlayerAppearanceVariables(GetEntityModel(ped))
end
end)