Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blood on screen and movement affected, map that shows all players when collected #6

Open
wants to merge 10 commits into
base: rewrite
Choose a base branch
from
Open
11 changes: 10 additions & 1 deletion __resource.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937"
resource_type 'gametype' { name = 'CorruptSnail' }

shared_script "config.lua"
ui_page "html/ui.html"

files {
"html/ui.html",
"html/ui.css",
"html/ui.js",
"html/sanje.png"
}
client_scripts {
"cl_utils.lua",
"cl_entityenum.lua",
Expand All @@ -12,5 +19,7 @@ client_scripts {
"cl_pedscache.lua",
"spawning/cl_player.lua",
"spawning/cl_zombies.lua",
"spawning/cl_savezones.lua"
"spawning/cl_savezones.lua",
"cl_hud.lua",
"cl_map.lua"
}
28 changes: 28 additions & 0 deletions cl_hud.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local hurt = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(250)
local myHealth = GetEntityHealth(GetPlayerPed(-1))
SendNUIMessage({
health = myHealth;
})
if myHealth <= 159 then
playerHurt()
elseif hurt == true and myHealth > 130 then
playerNotHurt()
end
end
end)

function playerHurt()
hurt = true
RequestAnimSet('move_m@injured')
SetPedMovementClipset(GetPlayerPed(-1), 'move_m@injured', true)
end

function playerNotHurt()
hurt = false
ResetPedMovementClipset(GetPlayerPed(-1))
ResetPedWeaponMovementClipset(GetPlayerPed(-1))
ResetPedStrafeClipset(GetPlayerPed(-1))
end
178 changes: 178 additions & 0 deletions cl_map.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
--[[TO DO:
*Add good places for map locations
--]]

--[[Reworked]]
local Map = "prop_tourist_map_01"
local MapCoords ={
{x= 719.52940, y= -963.195, z=31.3872}
}
local Maps = {}
local collected = false

AddEventHandler('playerSpawned',function()
Citizen.CreateThread(function()
for _, prop in ipairs(MapCoords) do
MapSpawning = CreateObject(GetHashKey(Map), prop.x, prop.y, prop.z - 1, false, false, true)

blip = AddBlipForEntity(MapSpawning)
SetBlipSprite(blip, 274)
SetBlipAsShortRange(blip, true)
SetBlipAlpha(blip, 255)
SetBlipScale(blip, 0.5)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('Map')
EndTextCommandSetBlipName(blip)
table.insert(Maps, MapSpawning)
end
end)
end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
for i, MapSpawning in pairs(Maps) do
playerX, playerY, playerZ = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
propX, propY, propZ = table.unpack(GetEntityCoords(MapSpawning, true))
if(Vdist(playerX, playerY, playerZ, propX, propY, propZ) < 1.5) then
DisplayHelpText("Press ~INPUT_CONTEXT~ to get the map.")
if IsControlJustReleased(1, 51) then
ShowNotification("Picked up: ~g~[Map]")
DeleteObject(MapSpawning)
RemoveBlip(blip)
table.remove(Maps, i)
collected = true
end
end
if IsPedDeadOrDying(PlayerPedId(), 1) == 1 then
DeleteObject(MapSpawning)
RemoveBlip(blip)
table.remove(Maps, i)
collected = false
end
end
if collected == true then
DisplayAllMap()
end
end
end)

function DisplayAllMap()
for id = 0, 64 do
if NetworkIsPlayerActive( id ) and GetPlayerPed( id ) ~= GetPlayerPed( -1 ) then
ped = GetPlayerPed( id )
blip = GetBlipFromEntity( ped )
if not DoesBlipExist( blip ) then -- Add blip and create head display on player
blip = AddBlipForEntity( ped )
SetBlipSprite( blip, 1 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, true ) -- Player Blip indicator
else -- update blip
veh = GetVehiclePedIsIn( ped, false )
blipSprite = GetBlipSprite( blip )
if not GetEntityHealth( ped ) then -- dead
if blipSprite ~= 274 then
SetBlipSprite( blip, 274 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif veh then
vehClass = GetVehicleClass( veh )
VehModel = GetEntityModel( veh )
if vehClass == 15 then -- jet
if blipSprite ~= 422 then
SetBlipSprite( blip, 422 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif vehClass == 16 then -- plane
if vehModel == GetHashKey( "besra" ) or vehModel == GetHashKey( "hydra" )
or vehModel == GetHashKey( "lazer" ) then -- jet
if blipSprite ~= 424 then
SetBlipSprite( blip, 424 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif blipSprite ~= 423 then
SetBlipSprite( blip, 423 )
Citizen.InvokeNative (0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif vehClass == 14 then -- boat
if blipSprite ~= 427 then
SetBlipSprite( blip, 427 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif vehModel == GetHashKey( "insurgent" ) or vehModel == GetHashKey( "insurgent2" )
or vehModel == GetHashKey( "limo2" ) then -- insurgent (+ turreted limo cuz limo blip wont work)
if blipSprite ~= 426 then
SetBlipSprite( blip, 426 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif vehModel == GetHashKey( "rhino" ) then -- tank
if blipSprite ~= 421 then
SetBlipSprite( blip, 421 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, false ) -- Player Blip indicator
end
elseif blipSprite ~= 1 then -- default blip
SetBlipSprite( blip, 1 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, true ) -- Player Blip indicator
end
-- Show number in case of passangers
passengers = GetVehicleNumberOfPassengers( veh )
if passengers then
if not IsVehicleSeatFree( veh, -1 ) then
passengers = passengers + 1
end
ShowNumberOnBlip( blip, passengers )
else
HideNumberOnBlip( blip )
end
else
-- Remove leftover number
HideNumberOnBlip( blip )
if blipSprite ~= 1 then -- default blip
SetBlipSprite( blip, 1 )
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, true ) -- Player Blip indicator
end
end
SetBlipRotation( blip, math.ceil( GetEntityHeading( veh ) ) ) -- update rotation
SetBlipNameToPlayerName( blip, id ) -- update blip name
SetBlipScale( blip, 0.85 ) -- set scale
-- set player alpha
if IsPauseMenuActive() then
SetBlipAlpha( blip, 255 )
else
x1, y1 = table.unpack( GetEntityCoords( GetPlayerPed( -1 ), true ) )
x2, y2 = table.unpack( GetEntityCoords( GetPlayerPed( id ), true ) )
distance = ( math.floor( math.abs( math.sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ) ) / -1 ) ) + 900
if distance < 0 then
distance = 0
elseif distance > 255 then
distance = 255
end
SetBlipAlpha( blip, distance )
end
end
end
end

end
function ShowPlayers()
local players = {}

for i = 0, NetworkGetNumConnectedPlayers() do
if NetworkIsPlayerActive(i) then
table.insert(players, i)
end
end

return players
end

function DisplayHelpText(str)
SetTextComponentFormat("STRING")
AddTextComponentString(str)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end

function ShowNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
Binary file added html/sanje.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions html/ui.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
body, html {
height: 100%;
margin: 0;
}
.sange{
background-image: url('sanje.png');
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
12 changes: 12 additions & 0 deletions html/ui.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en-USA">
<head>
<meta charset="utf-8">
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<link rel="stylesheet" href="ui.css" type="text/css">
<script src="ui.js" type="text/javascript"></script>
</head>

<body>
<div class = "sange"></div>
</body>
24 changes: 24 additions & 0 deletions html/ui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$(document).ready(function() {
window.addEventListener('message', function(event) {
var data = event.data;
if(data.health >165){
$(".sange").hide()
}
else if (data.health <= 165 && data.health > 150){
$(".sange").show();
$(".sange").css( "opacity", .1);
}
else if(data.health <= 150 && data.health > 130){
$(".sange").show();
$(".sange").css( "opacity", .35);
}
else if(data.health <= 130 && data.health > 115){
$(".sange").show();
$(".sange").css( "opacity", .7);
}
else if(data.health <= 115){
$(".sange").show();
$(".sange").css( "opacity", 1.0);
}
}
)})