hi guy i need some help wiht a script ,i try make a bodyarmor2 sell near gunshop
here my server code
local bodyarmorshop= {
{ ['x'] = 18.5651359558105, ['y'] = -1110.1748046875, ['z'] = 28.897025680542 }
}
RegisterServerEvent('es_roleplay:bodyarmor')
AddEventHandler('es_roleplay:bodyarmor', function(name, delay)
Citizen.CreateThread(function()
AddArmourToPed(GetPlayerPed(-1), 100)
end)
end)
client code
function DisplayHelpText(str)
SetTextComponentFormat("STRING")
AddTextComponentString(str)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
local function drawTxt(x,y ,width,height,scale, text, r,g,b,a, outline, center)
SetTextFont(0)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
if(center)then
Citizen.Trace("CENTER\n")
SetTextCentre(false)
end
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
if(outline)then
SetTextOutline()
end
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - width/2, y - height/2 + 0.005)
end
local bodyarmorshop= {
{ ['x'] = 18.5651359558105, ['y'] = -1110.1748046875, ['z'] = 28.897025680542 }
}
local displayingBoughtMessage = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if(displayingBoughtMessage)then
Citizen.Wait(3000)
displayingBoughtMessage = false
end
end
end)
RegisterNetEvent('es_roleplay:bodyarmor')
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if(displayingBoughtMessage)then
DisplayHelpText("You ~g~bought~w~ a ~g~BodyArmor!~w~")
end
local pos = GetEntityCoords(GetPlayerPed(-1), false)
for k,v in ipairs(twentyfourseven_shops) do
if(Vdist(v.x, v.y, v.z, pos.x, pos.y, pos.z) < 20.0)then
DrawMarker(1, v.x, v.y, v.z - 1, 0, 0, 0, 0, 0, 0, 1.0001, 1.0001, 1.5001, 0, 25, 165, 165, 0,0, 0,0)
if(Vdist(v.x, v.y, v.z, pos.x, pos.y, pos.z) < 1.0)then
if(GetPlayerMaxArmour(GetPlayerPed(-1)) < 100)then
DisplayHelpText("Press ~INPUT_CONTEXT~ to buy a ~y~BodyArmor~w~ for ~g~£25000~w~")
if(IsControlJustReleased(1, 51))then
TriggerServerEvent('es_roleplay:bodyarmor', k)
displayingBoughtMessage = true
end
else
if(not displayingBoughtMessage)then
DisplayHelpText("You already got a BodyArmor")
end
end
end
end
end
end
end)
shop marker is there its also say if i get armor already but i cant buy it or its not give it me maybe cuz wrong code?,(i try wiht ```
AddArmourToPed(GetPlayerPed(-1), 100)
SetPlayerMaxArmour(GetPlayerPed(-1), 100)
SetPedArmour(GetPlayerPed(-1), 100) )
but not workingi copy the foodstore code from es_miscstore
any1 know whats wrong?
im realy noob in this hope someone can help :slight_smile: