Hello, So Im sure you guys remember me right, I had been gone a long while and I am finally back wanting to make LUA scripts and its been a while and kind of lost track of the scritping but I cant find a documentation or anything that would help me make some awesome scripts like Hospital Healing markers or medic jobs, etc. so far heres all I got in the heal script for roleplaying servers.
local hospitals = {}
for i=0, GetNumberOfActiveBlips() do
if GetBlipSprite( i ) == 61 then
table.insert( hospitals, GetBlipCoords( i ) )
end
end
Citizen.Trace( string.format( "%d hospitals found:\n\t%s\n", #hospitals, table.concat( hospitals, "\n\t" ) )
But I don’t actually know if Blip is an integer starting at 0 (but this is easy to figure out). 61 is the sprite ID for the hospitals.
I’m reluctant to post which resources I’m using due to the fact that anyone can edit the documentation and quite a few trolls roaming these forums. Pass me a PM and I’ll put up a list for you. Other than that I believe they’re working on a new wiki (Mods: I could contribute? PM me) or you can browse the natives.lua in your FiveReborn client folder.
EDIT: Well, concatinating a table which contains tables isn’t going to do much. Oh well. You get the idea. Coord tables afaik always use .x, .y and .z, and not [0], [1] and [2] by the way.
alright thanks thats a start, I plan to do this in order starting by adding the blips on the radar for each hospital, then a marker that will pop up a simple menu that will display heal and cancel, and will heal the player if the heal button is pressed for a certain amount of money.
Hospitals have a blip by default, or did you want to define your own (and possibly make-shift hospitals / clinics)? In that case you might be thinking about removing the default hospital blips and you’ll end up looking at RemoveBlip( Blip* ). This implementation is broken however and will crash your game. You can instead hide a blip by doing SetBlipSprite( Blip, 2 ) where 2 is the index of an empty sprite or you can call SetBlipAlpha( Blip, 0 ) to preserve sprite data and just make it transparent instead.
Either way you’ll want to figure out positions to put your new markers at. I’ll save you some time by sharing this bit of code I used to help me define some better spawn points:
You can use Blip AddBlipForCoord( x, y, z ) and SetBlipSprite( Blip, 61 ) for your new hospital/clinic markers.
--Script by Cody196 and for open source use.
local hospitals = {}
for i=0, GetNumberOfActiveBlips() do
if GetBlipSprite( i ) == 61 then
table.insert( hospitals, GetBlipCoords( i ) )
end
end
Citizen.Trace( string.format( "%d hospitals found:\n\t%s\n", #hospitals, table.concat( hospitals, "\n\t" ) )
--For Sandy Shores Medical Center, draws marker, blip and then the health pickup to heal the player
function DrawMarker(type, x, y, z)
--DrawMarker(Cylinder, 1839.6, 3672.93, 34.28)
AddBlipForCoord(1839.6, 3672.93, 34.28)
SetBlipSprite(61, true)
CreatePickup(-1888453608, 1839.6, 3672.93, 34.28)
end
this is what i have so far and it is giving me Err_FIL_COMMON fatal error upon joining server but it dont show any errors in console.
SetBlipSprite takes as paramaters ( Blip, integer ). Blip really is just an integer so there’s no script error but “61” is not connected to anything at all and you’re trying to set a sprite (true = 1, so sprite#1) to it. To fix the error you would do:
Edit:
Might want to change table.insert( hospitals, GetBlipCoords( i ) ) to table.insert( hospitals, table.concat( GetBlipCoords( i ), ", " ) as well if you want any sensible output in your console…
--Script by Cody196 and for open source use.
--For Sandy Shores Medical Center, draws marker
local hospitalPickup = {
Pickup = {-1888453608, 1839.03, 3673.25, 34.28}
local marker = AddBlipForCoord( 1839.6, 3672.93, 34.28 );
SetBlipSprite( marker, 61 );
function createPickup(typeHash, posX, posY, posZ)
CreatePickup(-1888453608, 1839.03, 3673.25, 34.28)
wait(60)
return
end
function createBlip()
local blip = AddBlipForCoord(pos[1],pos[2],pos[3])
SetBlipAsShortRange(blip,true)
SetBlipSprite(blip,61)