Skip to content

Commit

Permalink
defaultstats: small fixes (#366)
Browse files Browse the repository at this point in the history
* Update stats.

* Update defaultstats.lua
  • Loading branch information
ds1-e authored Nov 22, 2021
1 parent bbd536d commit b09bd68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
26 changes: 14 additions & 12 deletions [gameplay]/defaultstats/defaultstats.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local stats = {
local statsTable = {
[69] = 500, -- Pistol
[70] = 999, -- Silenced pistol
[71] = 999, -- Desert eagle
Expand All @@ -15,22 +15,24 @@ local stats = {
[230] = 999 -- Cycling
}

local function applyStatsForPlayer(player)
for stat, value in pairs(stats) do
player:setStat(stat, value)
local function applyStatsForPlayer(playerElement)
for statName, statValue in pairs(statsTable) do
setPedStat(playerElement, statName, statValue)
end
end

local function applyStatsForEveryone()
for _, player in pairs(Element.getAllByType "player") do
applyStatsForPlayer(player)
end
end
addEventHandler("onResourceStart", resourceRoot, applyStatsForEveryone)
addEventHandler("onGamemodeMapStart", root, applyStatsForEveryone)

local function applyStatsForSource()
applyStatsForPlayer(source)
end
addEventHandler("onPlayerJoin", root, applyStatsForSource)
addEventHandler("onPlayerSpawn", root, applyStatsForSource)

local function applyStatsForEveryone()
local playersTable = getElementsByType("player")

for playerID = 1, #playersTable do
applyStatsForPlayer(playersTable[playerID])
end
end
addEventHandler("onResourceStart", resourceRoot, applyStatsForEveryone)
addEventHandler("onGamemodeMapStart", root, applyStatsForEveryone)
5 changes: 2 additions & 3 deletions [gameplay]/defaultstats/meta.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<meta>
<script src="defaultstats.lua"/>
<oop>true</oop>
</meta>
<script src="defaultstats.lua" type="server"/>
</meta>

0 comments on commit b09bd68

Please sign in to comment.