Enhance player availability check and add function to get player ped offset
This commit is contained in:
@@ -19,4 +19,4 @@ Copy the `effect_template.lua` file into your effects directory, change as neede
|
|||||||
- Restore all modified game state(s) in `OnStop()`.
|
- Restore all modified game state(s) in `OnStop()`.
|
||||||
|
|
||||||
## Updates
|
## Updates
|
||||||
- This script template will get minimal updates for additional function or changes.
|
- This script template will get minimal updates for additional functions or changes.
|
||||||
@@ -43,15 +43,20 @@ end
|
|||||||
-- Add custom helper functions below.
|
-- Add custom helper functions below.
|
||||||
|
|
||||||
function IS_PLAYER_AVAILABLE()
|
function IS_PLAYER_AVAILABLE()
|
||||||
local player_ped = PLAYER.PLAYER_PED_ID()
|
local player_ped = PLAYER_PED_ID()
|
||||||
if not DOES_ENTITY_EXIST(player_ped) or IS_ENTITY_DEAD(player_ped) then
|
if not DOES_ENTITY_EXIST(player_ped) or IS_ENTITY_DEAD(player_ped) or IS_PLAYER_SWITCH_IN_PROGRESS() then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GET_PLAYER_PED_OFFSET(offset_x, offset_y, offset_z)
|
||||||
|
local player_ped = PLAYER_PED_ID()
|
||||||
|
return GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(player_ped, offset_x, offset_y, offset_z)
|
||||||
|
end
|
||||||
|
|
||||||
function GET_PLAYER_PED_HEADING()
|
function GET_PLAYER_PED_HEADING()
|
||||||
local player_ped = PLAYER.PLAYER_PED_ID()
|
local player_ped = PLAYER_PED_ID()
|
||||||
return GET_ENTITY_HEADING(player_ped)
|
return GET_ENTITY_HEADING(player_ped)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -63,12 +68,11 @@ function RANDOM_CHOICE(p1)
|
|||||||
return choice
|
return choice
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Example helper function: creates a ghost ped at an offset from the player
|
|
||||||
function CREATE_GHOST(ped_model, offset_x, offset_y, offset_z)
|
function CREATE_GHOST(ped_model, offset_x, offset_y, offset_z)
|
||||||
local player_ped = PLAYER.PLAYER_PED_ID()
|
|
||||||
local player_heading = GET_PLAYER_PED_HEADING()
|
local player_heading = GET_PLAYER_PED_HEADING()
|
||||||
local ped_model_hash = GET_HASH_KEY(ped_model)
|
local ped_model_hash = GET_HASH_KEY(ped_model)
|
||||||
local player_coords = GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(player_ped, offset_x, offset_y, offset_z)
|
local player_coords = GET_PLAYER_PED_OFFSET(offset_x, offset_y, offset_z)
|
||||||
local ghost = CreatePoolPed(1, ped_model_hash, player_coords.x, player_coords.y, player_coords.z, player_heading)
|
local ghost = CreatePoolPed(1, ped_model_hash, player_coords.x, player_coords.y, player_coords.z, player_heading)
|
||||||
SET_ENTITY_ALPHA(ghost, 0, false)
|
SET_ENTITY_ALPHA(ghost, 0, false)
|
||||||
return ghost
|
return ghost
|
||||||
|
|||||||
Reference in New Issue
Block a user