Skip to content

Commit

Permalink
v0.5.5 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheStonedTurtle authored Sep 24, 2017
1 parent 80a3fa5 commit 80a0afc
Show file tree
Hide file tree
Showing 15 changed files with 1,386 additions and 328 deletions.
26 changes: 26 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
<h1>v0.5.5 (09-24-2017)</h1>
Added new trainer features, new Setting Saving, and some general bug fixes/improvments



<h3>Changes</h3>
<ul>
<li>Fixed Cosmetic Damage toggle showing scratches</li>
<li>Updated <b>data-require</b> to work with <b>data-action</b>, was previously only working with <b>data-sub</b></li>
<li>Fixed Skin Changing menu when loading a saved skin</li>
<li>Fixed Voice Proximity Sync</li>
<li>Fixed Voice Channel Menu and added Syncing</li>
<li>Fixed incorrect submenu linking</li>
<li>JSON Menu Name updates(credits @Matty45)</li>
</ul>

<h3>Additions</h3>
<ul>
<li>Added Restore Apperance toggle (Default = ON)</li>
<li>Added Local Setting Saving System (Trainer Toggles)</li>
<li>Added Some MK2 Weapons and some of their attachments</li>
<li>Added custom privledge information to the readme document</li>
</ul>



<h1>v0.5.0 (09-06-2017)</h1>
JSON Updates, JSON Editor, Setting Sync System, New Location Menu, Blip/Overhead System Rewrite, and many other code improvements.

Expand Down
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ This section is only intended for people with LUA experience and a basic underst
<tr><td>data-sub</td><td>ID of the new menu to show when selected.</td></tr>
<tr><td>data-share</td><td>Information to share with the sub menu action options.(won't do anything unless data-sub is also specified)</td></tr>
<tr><td>data-shareid</td><td>Updates the submenu ID to this if it exists. Useful for ensuring that a menu that is used my multiple different options will return to the correct place within the trainer.</td></tr>
<tr><td>data-require</td><td>Used for permission checks for <b>data-action</b> and <b>data-sub</b> events. See Below</td></tr>
</tbody>
</table>

Expand Down Expand Up @@ -144,4 +145,45 @@ This section is only intended for people with LUA experience and a basic underst
<h2>JSON Editing</h2>
I created a website hosted on my github.io pages for editing the Mello Trainer JSON. It is not the best website and may have performance issues but it accomplishes the required task. Please read the above JSON information before trying/asking questions about this editor.

<a href="https://thestonedturtle.github.io/mellotrainer/mellotrainer.html" target="_blank">TheStonedTurtle.github.io</a></li>
<a href="https://thestonedturtle.github.io/mellotrainer/mellotrainer.html" target="_blank">TheStonedTurtle.github.io</a></li>


<h2>Custom Privileges</h2>
To create custom privileges within mello trainer using data-require you can follow the below template. This works for data-action and data-sub but does not support data-hover events. <i>Note: This can be done without triggering a server event.</i>

<h3>Client.lua</h3>
Add the below to any client lua file.


```
-- Request Cop Status
RegisterNUICallback("requirecop", function(data, cb)
TriggerServerEvent("mellotrainer:requestCopStatus")
end)
-- Recieve Cop Status
RegisterNetEvent("mellotrainer:copstatus")
AddEventHandler("mellotrainer:copstatus", function(status)
if(status)then
SendNUIMessage({customprivilegecheck = true})
else
drawNotification("~r~Permission Denied!")
end
end)
```

<h3>Server.lua</h3>

Add the below to any server lua file.


```
RegisterServerEvent('mellotrainer:requestCopStatus')
AddEventHandler('mellotrainer:requestCopStatus', function(id)
local result = false
-- Logic to check if they are a cop here
TriggerClientEvent("mellotrainer:copstatus",source,result)
end)
```
87 changes: 78 additions & 9 deletions mellotrainer/cl_general.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,43 @@ end

-- Manually Sync Trainer Settings
function syncSettings()
local distance = 0
local distance = 0.0
if(featureVPAllPlayers)then
distance = 0;
distance = 0.0
elseif(featureVPTooClose)then
distance = 5
distance = 5.0
elseif(featureVPVeryClose)then
distance = 25
distance = 25.0
elseif(featureVPClose)then
distance = 75
distance = 75.0
elseif(featureVPNearby)then
distance = 200
distance = 200.0
elseif(featureVPDistant)then
distance = 500
distance = 500.0
elseif(featureVPFar)then
distance = 2500
distance = 2500.0
elseif(featureVPVeryFar)then
distance = 8000
distance = 8000.0
end

NetworkSetTalkerProximity(distance) -- Voice Proximity
NetworkSetVoiceActive(featureVoiceChat) -- Voice Toggle

-- Voice Channel
if(featureChannelDefault)then
NetworkClearVoiceChannel()
elseif(featureChannel1)then
NetworkSetVoiceChannel(1)
elseif(featureChannel2)then
NetworkSetVoiceChannel(2)
elseif(featureChannel3)then
NetworkSetVoiceChannel(3)
elseif(featureChannel4)then
NetworkSetVoiceChannel(4)
elseif(featureChannel5)then
NetworkSetVoiceChannel(5)
end

if(featurePlayerRadio)then
SetMobileRadioEnabledDuringGameplay(featurePlayerRadio) -- Player Radio
SetUserRadioControlEnabled(true)
Expand Down Expand Up @@ -173,6 +188,12 @@ AddEventHandler("mellotrainer:init", function()

-- Initialize Client Settings
syncSettings()

-- Create Mellotrainer Spawn Event Handler.

AddEventHandler("playerSpawned", function(spawn)
TriggerEvent("mellotrainer:playerSpawned")
end)
end)


Expand Down Expand Up @@ -347,4 +368,52 @@ Citizen.CreateThread(function()
end

end
end)


-- *
-- * Toggle Saving/Loading System
-- *

function setFeatureToggleStates(data)
for k,v in pairs(data) do
_G[k] = v
end
end


function getFeatureToggleStates()
local featureVariables = {}
for k,v in pairs(_G)do
if string.find(k,"feature") then
featureVariables[k] = v
if string.find(k,"Updated") then -- Force sync
featureVariables[k] = true
end
end
end
return featureVariables
end


RegisterNUICallback("savefeaturevariables", function()
local toggles = getFeatureToggleStates()
TriggerServerEvent( "wk:DataSave", "toggles", toggles, 0)
drawNotification("Current settings saved")
end)

RegisterNUICallback("resetfeaturevariables", function()
TriggerServerEvent( "wk:DataSave", "toggles", {}, 0)
drawNotification("Saved settings cleared Reconnect to resync")
end)

RegisterNUICallback("loadfeaturevariables", function()
TriggerServerEvent( "wk:DataLoad", "toggles")
end)

RegisterNetEvent("wk:RecieveSavedToggles")
AddEventHandler("wk:RecieveSavedToggles", function(data)
setFeatureToggleStates(data["0"])
syncSettings()
drawNotification("Settings loaded")
end)
3 changes: 3 additions & 0 deletions mellotrainer/cl_player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ RegisterNUICallback("player", function(data, cb)
elseif action == "keepclean" then
featureKeepClean = newstate
drawNotification("Keep Clean: "..tostring(text))
elseif action == "restoreappearance"then
featureRestoreAppearance = newstate
drawNotification("Restore Appearance: "..tostring(text))
end

if(cb)then cb("ok") end
Expand Down
38 changes: 38 additions & 0 deletions mellotrainer/cl_player_skin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function SetSkin( skin )
SetPlayerModel( PlayerId(), skin )
SetPedDefaultComponentVariation( PlayerId() )
SetModelAsNoLongerNeeded( skin )
resetTrainerMenus("playerskinmodify playerpropmodify")
end
end
end
Expand Down Expand Up @@ -545,3 +546,40 @@ function checkValidPropComponents(propID)
end
return valid
end



local playerSkin = {}
local pmodel = nil
function savePlayerAppearanceVariables(pmod)
pmodel = pmod
local ped = PlayerPedId()
for i=0,12,1 do
table.insert(playerSkin, {
drawable = GetPedDrawableVariation(ped, i),
dtexture = GetPedTextureVariation(ped, i),
prop = GetPedPropIndex(ped, i),
ptexture = GetPedPropTextureIndex(ped, i),
palette = GetPedPaletteVariation(ped, i),
index = i
})
end
end


function restorePlayerAppearance()
_LoadModel(pmodel)
SetPlayerModel(PlayerId(),pmodel)
local ped = GetPlayerPed(-1)
for _,obj in pairs(playerSkin) do
SetPedComponentVariation(ped, obj.index, obj.drawable, obj.dtexture, obj.palette)
SetPedPropIndex(ped, obj.index, obj.prop, obj.ptexture)
end
SetModelAsNoLongerNeeded(pmodel)
end

AddEventHandler("mellotrainer:playerSpawned",function()
if(featureRestoreAppearance)then
restorePlayerAppearance()
end
end)
24 changes: 19 additions & 5 deletions mellotrainer/cl_settings_notifications.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function checkForDeaths()
if ( DoesEntityExist( currentPed ) and IsEntityDead( currentPed ) ) then

if(deadPlayers[i] == nil)then
handlePlayerDeathMessage( i, currentPed )
TriggerEvent("mellotrainer:playerDeath", i)
deadPlayers[i] = true
end
else
Expand All @@ -157,8 +157,22 @@ Citizen.CreateThread( function()
while true do
Citizen.Wait( 0 )

if ( featureDeathNotifications ) then
checkForDeaths()
end
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 )
end)
16 changes: 16 additions & 0 deletions mellotrainer/cl_settings_voice.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ function updateVoiceDistanceVariables(distance)
end


-- Update voice channel variables
function updateVoiceChannelVariables(channel)
featureChannelDefault = false;
featureChannel1 = false;
featureChannel2 = false;
featureChannel3 = false;
featureChannel4 = false;
featureChannel5 = false;
if(channel == 0)then
featureChannelDefault = true
else
_G["featureChannel"..tostring(channel)] = true
end
end


RegisterNUICallback("voiceopts", function(data, cb)
local playerPed = GetPlayerPed(-1)
Expand All @@ -71,6 +86,7 @@ RegisterNUICallback("voiceopts", function(data, cb)
NetworkSetVoiceChannel(tonumber(request))
drawNotification("Now In Voice Channel: "..request)
end
updateVoiceChannelVariables(request)
elseif(action=="distance")then
local distance = tonumber(request) + 0.00

Expand Down
26 changes: 14 additions & 12 deletions mellotrainer/cl_variables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ featureHideHud = false;
featureBigHud = false;
featureMapBlips = true;
featureAreaStreetNames = false;
featureRestoreAppearance = true;
--featureRestoreWeapons = false;


--Vehicle Options
Expand Down Expand Up @@ -107,16 +109,24 @@ featureWeatherFreeze = false;
-- Voice
featureShowVoiceChatSpeaker = true;
featureVoiceChat = true;
-- One of the below must be true
-- One of the below must be true.
-- If multiple are true only the first one will apply.
featureVPAllPlayers = true;
featureVPTooClose = false;
featureVPVeryClose = false;
featureVPClose = false;
featureVPNearby = false;
featureVPDistant = false;
featureVPFar = false;
featureVPVeryFar = false;
featureVPAllPlayers = true;

-- One of the below must be true.
-- If multiple are true only the first one will apply.
featureChannelDefault = true;
featureChannel1 = false;
featureChannel2 = false;
featureChannel3 = false;
featureChannel4 = false;
featureChannel5 = false;



Expand Down Expand Up @@ -336,15 +346,7 @@ fib = nil;
--ptexture = {};
--pallet = {};


--featureChannelDefault = false;
--featureChannel1 = false;
--featureChannel2 = false;
--featureChannel3 = false;
--featureChannel4 = false;
--featureChannel5 = false;


-- Horizontal/Vertical Camera features.
--featureVC1 = false;
--featureVC2 = false;
--featureVC3 = false;
Expand Down
Loading

0 comments on commit 80a0afc

Please sign in to comment.