mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-18 22:36:04 +01:00
Fix IsAnimal checks getting confused
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
or other type (e.g., coyote). It uses predefined model hashes stored in the AnimalPeds table.
|
or other type (e.g., coyote). It uses predefined model hashes stored in the AnimalPeds table.
|
||||||
|
|
||||||
Global Flags:
|
Global Flags:
|
||||||
- isCat, isDog, isBigDog, isSmallDog, isCoyote, isAnimal: Booleans to track the player's
|
- isCat, isPedDog, isBigDog, isSmallDog, isCoyote, isAnimal: Booleans to track the player's
|
||||||
current animal classification.
|
current animal classification.
|
||||||
|
|
||||||
When running client-side (not on the server), the module checks the player's Ped after they load.
|
When running client-side (not on the server), the module checks the player's Ped after they load.
|
||||||
@@ -26,13 +26,13 @@
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
-- Global animal classification flags.
|
-- Global animal classification flags.
|
||||||
isCat, isDog, isBigDog, isSmallDog, isCoyote, isAnimal = false, false, false, false, false, false
|
isPedCat, isPedDog, isBigDog, isSmallDog, isCoyote, isAnimal = false, false, false, false, false, false
|
||||||
|
|
||||||
if not isServer() then
|
if not isServer() then
|
||||||
onPlayerLoaded(function()
|
onPlayerLoaded(function()
|
||||||
Wait(2000)
|
Wait(1000)
|
||||||
-- Reset classification flags
|
-- Reset classification flags
|
||||||
isCat, isDog, isBigDog, isSmallDog, isCoyote = false, false, false, false, false
|
isPedCat, isPedDog, isBigDog, isSmallDog, isCoyote = false, false, false, false, false
|
||||||
-- Check if the player's Ped is an animal.
|
-- Check if the player's Ped is an animal.
|
||||||
isPedAnimal()
|
isPedAnimal()
|
||||||
if isAnimal then
|
if isAnimal then
|
||||||
@@ -41,18 +41,18 @@ if not isServer() then
|
|||||||
|
|
||||||
-- Determine if the Ped is a cat:
|
-- Determine if the Ped is a cat:
|
||||||
-- Also treat 'ft-raccoon' as a cat unless it is 'ft-sphynx'
|
-- Also treat 'ft-raccoon' as a cat unless it is 'ft-sphynx'
|
||||||
isCat = (isCat(ped) or pedModel == `ft-raccoon`) and (pedModel ~= `ft-sphynx`)
|
isPedCat = (isCat(ped) == true or pedModel == `ft-raccoon`) and (pedModel ~= `ft-sphynx`)
|
||||||
|
|
||||||
-- Determine if the Ped is a dog and whether it's big:
|
-- Determine if the Ped is a dog and whether it's big:
|
||||||
isDog, isBigDog = isDog(ped)
|
isPedDog, isBigDog = isDog(ped)
|
||||||
isSmallDog = not isBigDog
|
isSmallDog = not isBigDog
|
||||||
if isDog and pedModel == `a_c_coyote` then isDog = false end
|
if isPedDog and pedModel == `a_c_coyote` then isPedDog = false end
|
||||||
|
|
||||||
-- Determine if the Ped is a coyote (special case):
|
-- Determine if the Ped is a coyote (special case):
|
||||||
isCoyote = (pedModel == `ft-sphynx` or pedModel == `a_c_coyote`)
|
isCoyote = (pedModel == `ft-sphynx` or pedModel == `a_c_coyote`)
|
||||||
|
|
||||||
-- Special override: if model is 'ft-capmonkey2', treat as a dog.
|
-- Special override: if model is 'ft-capmonkey2', treat as a dog.
|
||||||
if pedModel == `ft-capmonkey2` then isDog = true end
|
if pedModel == `ft-capmonkey2` then isPedDog = true end
|
||||||
end
|
end
|
||||||
end, true)
|
end, true)
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ if not isServer() then
|
|||||||
for animalModelHash, _ in pairs(animalCategory) do
|
for animalModelHash, _ in pairs(animalCategory) do
|
||||||
if PedModel == animalModelHash then
|
if PedModel == animalModelHash then
|
||||||
isAnimal = true
|
isAnimal = true
|
||||||
debugPrint("^6Bridge^7: ^2Ped is Animal")
|
debugPrint("^4isAnimal^7: ^2Ped is ^4Animal")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -109,6 +109,7 @@ if not isServer() then
|
|||||||
local PedModel = GetEntityModel(ped or PlayerPedId())
|
local PedModel = GetEntityModel(ped or PlayerPedId())
|
||||||
for modelHash, _ in pairs(AnimalPeds.CatPeds) do
|
for modelHash, _ in pairs(AnimalPeds.CatPeds) do
|
||||||
if PedModel == modelHash then
|
if PedModel == modelHash then
|
||||||
|
debugPrint("^4isAnimal^7: ^2Ped is ^4Cat")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -126,8 +127,8 @@ if not isServer() then
|
|||||||
---
|
---
|
||||||
---@usage
|
---@usage
|
||||||
--- ```lua
|
--- ```lua
|
||||||
--- local isDog, isBigDog = isDog()
|
--- local isPedDog, isBigDog = isDog()
|
||||||
--- if isDog then
|
--- if isPedDog then
|
||||||
--- if isBigDog then
|
--- if isBigDog then
|
||||||
--- print("Player is a big dog!")
|
--- print("Player is a big dog!")
|
||||||
--- else
|
--- else
|
||||||
@@ -151,11 +152,13 @@ if not isServer() then
|
|||||||
local PedModel = GetEntityModel(ped or PlayerPedId())
|
local PedModel = GetEntityModel(ped or PlayerPedId())
|
||||||
for modelHash, _ in pairs(AnimalPeds.BigDogs) do
|
for modelHash, _ in pairs(AnimalPeds.BigDogs) do
|
||||||
if PedModel == modelHash then
|
if PedModel == modelHash then
|
||||||
|
debugPrint("^4isAnimal^7: ^2Ped is ^4Dog")
|
||||||
return true, true
|
return true, true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for modelHash, _ in pairs(AnimalPeds.SmallDogs) do
|
for modelHash, _ in pairs(AnimalPeds.SmallDogs) do
|
||||||
if PedModel == modelHash then
|
if PedModel == modelHash then
|
||||||
|
debugPrint("^4isAnimal^7: ^2Ped is ^4Small Dog")
|
||||||
return true, false
|
return true, false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user