Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cash = 0 -- Container for loop.
- RegisterNetEvent('ReceiveUserMoney')
- AddEventHandler('ReceiveUserMoney', function(value)
- cash = value
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if (IsNear() == true) then
- TriggerServerEvent("GetUserMoney")
- Citizen.Wait(math.random(100,500))
- end
- end
- end)
- Citizen.CreateThread(function()
- if NetworkIsSessionStarted() then
- for k, pos in pairs (config.pos) do
- blip = AddBlipForCoord(pos[1],pos[2],pos[3])
- SetBlipSprite(blip, 52)
- SetBlipAsShortRange(blip, true)
- BeginTextCommandSetBlipName("STRING")
- AddTextComponentString("Magasin")
- SetBlipScale (blip, 0.7)
- EndTextCommandSetBlipName(blip)
- end
- end
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if (IsNear() == true) then
- drawTxt('Appuyer sur ~g~E~s~ pour accéder au magasin',0,1,0.5,0.8,0.6,255,255,255,255)
- if (IsControlJustPressed(1, 38) and IsNear() == true) then
- exports.ft_menuBuilder:Open("shopmenu")
- end
- end
- end
- end)
- function IsNear()
- local ply = GetPlayerPed(-1)
- local plyCoords = GetEntityCoords(ply, 0)
- for k, pos in pairs (config.pos) do
- local distance = GetDistanceBetweenCoords(pos[1],pos[2],pos[3], plyCoords["x"], plyCoords["y"], plyCoords["z"], true)
- if(distance <= 5) then
- return true
- end
- end
- end
- function drawTxt(text,font,centre,x,y,scale,r,g,b,a)
- SetTextFont(font)
- SetTextProportional(0)
- SetTextScale(scale, scale)
- SetTextColour(r, g, b, a)
- SetTextDropShadow(0, 0, 0, 0,255)
- SetTextEdge(1, 0, 0, 0, 255)
- SetTextDropShadow()
- SetTextOutline()
- SetTextCentre(centre)
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawText(x , y)
- end
- RegisterNetEvent('shop:buy')
- AddEventHandler('shop:buy', function(data)
- print(cash)
- print(data.price)
- print(data.object)
- if data.price < cash then
- TriggerServerEvent('UpdateUserMoney', -data.price)
- TriggerClientEvent("player:receiveItem", data.object, 1)
- exports.ft_base:Notification("Tu a acheter "..data.object..".")
- else
- exports.ft_base:Notification("Tu n'a pas assez d'argent sur toi.")
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment