[vRP] Pets

Are they synched for everyone to see or is it client side?

You can see the Pet after the other Player not…

So only you can see it?

Yes this is right only you

@Naifen everyone can see the pet when you tell him to get to you when you press F9, would it make any sense if only you could see your pet, hmmm ?

@Dominic1337

can you help?
Failed to load script @mysql-async/lib/MySQL.lua.

how can i spawn the Pet ? or control hem

http://prntscr.com/jpnd20 added the pet collumn and when i tryied to import the sql file to my DB it shows this error

I am having the following error the animal does not appear and does not write to the database already added right I created a pets column

Sorry, my english, I’m Brazilian.

is this mod relevant with the currently released vRP?

@everyoneThatsHavingIssues

i’ve updated the instalation guide on the README.md

go and check if you’ve done everything.

Você irá realizar para vRPEX?

Trying to convert to the latest vRP,

Resource

description 'vrp_pets'

dependencies{
  "vrp",
  "GHMattiMySQL"
}

client_scripts {
  "@vrp/lib/utils.lua",
	'client.lua'
}

server_scripts {
  "@vrp/lib/utils.lua",
	'server.lua'
}

server

local Tunnel = module("vrp", "lib/Tunnel")
local Proxy = module("vrp", "lib/Proxy")

vRP = Proxy.getInterface("vRP")

local pets = {
	["chien"] = {
		name = "Cão",
		price = 50000
	},
	["chat"] = {
		name = "Gato",
		price = 15000
	},
	["loup"] = {
		name = "Lobo",
		price = 30000
	},
	["lapin"] = {
		name = "Coelho",
		price = 25000
	},
	["husky"] = {
		name = "Husky",
		price = 35000
	},
	["cochon"] = {
		name = "Porco",
		price = 10000
	},
	["caniche"] = {
		name = "Poodle",
		price = 50000
	},
	["carlin"] = {
		name = "Pug",
		price = 5000
	},
	["retriever"] = {
		name = "Retriever",
		price = 10000
	},
	["berger"] = {
		name = "Cão Alsatian",
		price = 55000
	},
	["westie"] = {
		name = "Westie",
		price = 50000
	}
}

RegisterServerEvent("vrp_pets:animalname")
AddEventHandler("vrp_pets:animalname", function (source, method)
	local _source = source
	local player = vRP.getUserId(_source)
	vRP._prepare('SELECT * FROM vrp_users WHERE id = @id', {['@id'] = player}, function(result)
		if method == "callPet" then
			TriggerClientEvent("vrp_pets:callPet", _source, result[1].pet)
		elseif method == "orders" then
			TriggerClientEvent("vrp_pets:orders", _source, result[1].pet)
		end
	end)
end)

RegisterServerEvent("vrp_pets:dead")
AddEventHandler("vrp_pets:dead", function()
	local _source = source
	local player = vRP.getUserId(_source)
	
	vRP._prepare('UPDATE vrp_users SET pet = NULL WHERE id = @id', {['@id'] = player})
end)

RegisterServerEvent('vrp_pets:startHarvest')
AddEventHandler('vrp_pets:startHarvest', function()
	local _source = source
	local player = vRP.getUserId(_source)
	vRP.tryGetInventoryItem(player, 'dogfood', 1)
end)

RegisterServerEvent('vrp_pets:takeanimal')
AddEventHandler('vrp_pets:takeanimal', function (source, petid, price)
	local _source = source
	local player = vRP.getUserId(_source)
	local playerMoney = vRP.getMoney(player)

	if playerMoney >= price then
		vRP.tryPayment(player, price)
		vRP._prepare('UPDATE vrp_users SET pet = @pet WHERE id = @id', {['@id'] = player, ['@pet'] = petid})
		vRPclient.notify(_source, {"You get one " .. pets[petid].name .. " pet " .. price})
	else
		vRPclient.notify(_source, {"~r~Insufficient Money!"})
	end
end)

RegisterServerEvent("vrp_pets:buypet")
AddEventHandler("vrp_pets:buypet", function ()
	local _source = source
	local player = vRP.getUserId(_source)
	local menudata = {}
	
	menudata.name = "Pet Shop"
	menudata.css = "align = 'top-left'"

	for k, v in pairs(pets) do
		menudata[v.name] = {function (choice)
			TriggerEvent("vrp_pets:takeanimal", _source, k, v.price)
			vRP.closeMenu(_source)
		end, "$" .. v.price}
	end
	
	vRP.openMenu(_source, menudata)
end)

RegisterServerEvent("vrp_pets:petMenu")
AddEventHandler("vrp_pets:petMenu", function (status, come, isInVehicle)
	local _source = source
	local player = vRP.getUserId(_source)
	local menudata = {}

	menudata.name = "Pet Manager"
	menudata.css = {align = 'top-left'}

	if come == 1 then
		menudata["Give Food"] = {function (choice)
			local data = vRP.getUserDataTable(player)
			TriggerClientEvent("vrp_pets:givefood", _source, data.inventory)
			vRP.closeMenu(_source)
		end, "Fome :" .. status .. "%"}
		menudata["Attach or detach your pet"] = {function (choice)
			TriggerClientEvent("vrp_pets:attachdetach", _source)
			vRP.closeMenu(_source)
		end}

		if isInVehicle then
			menudata["Tell your pet to get out of the car"] = {function (choice)
				TriggerClientEvent("vrp_pets:enterleaveveh", _source)
				vRP.closeMenu(_source)
			end}
		else
			menudata["Tell your pet to get in the car"] = {function (choice)
				TriggerClientEvent("vrp_pets:enterleaveveh", _source)
				vRP.closeMenu(_source)
			end}
		end

		menudata["Give Order"] = {function (choice)
			TriggerEvent("vrp_pets:animalname", _source, "orders")
			vRP.closeMenu(_source)
		end}
	else
		menudata["Name you pet"] = {function (choice)
			if come == 0 then
				TriggerEvent("vrp_pets:animalname", _source, "callPet")
				vRP.closeMenu(_source)
			end
		end}
	end

	vRP.openMenu(_source, menudata)
end)

RegisterServerEvent("vrp_pets:ordersMenu")
AddEventHandler("vrp_pets:ordersMenu", function (data, model, inanimation)
	local _source = source
	local player = vRP.getUserId(_source)
	local menudata = {}

	menudata.name = "Orders"
	menudata.css = {align = 'top-left'}
	
	if not inanimation then
		if model ~= 1462895032 then
			menudata["Procurar a bola"] = {function (choice) -- balle
				TriggerClientEvent("vrp_pets:findball", _source)
				vRP.closeMenu(_source)
			end}
		end
		menudata["Follow-me"] = {function (choice) -- pied
			TriggerClientEvent("vrp_pets:followme", _source)
			vRP.closeMenu(_source)
		end}
		menudata["Tell the pet to enter the dog house"] = {function (choice) -- niche
			TriggerClientEvent("vrp_pets:goHome", _source)
			vRP.closeMenu(_source)
		end}
		
		if (data == "Dog") then
			menudata["Sentar"] = {function (choice) -- assis
				TriggerClientEvent("vrp_pets:seat", _source, 1)
				vRP.closeMenu(_source)
			end}
			menudata["Lay"] = {function (choice) -- coucher
				TriggerClientEvent("vrp_pets:laydown", _source, 1)
				vRP.closeMenu(_source)
			end}
		end
		if (data == "Bark") then
			menudata["Deitar"] = {function (choice) -- coucher2
				TriggerClientEvent("vrp_pets:laydown", _source, 2)
				vRP.closeMenu(_source)
			end}
		end
		if (data == "Lay") then
			menudata["Deitar"] = {function (choice) -- coucher3
				TriggerClientEvent("vrp_pets:laydown", _source, 3)
				vRP.closeMenu(_source)
			end}
		end
		if (data == "Kneel") then
			menudata["Sentar"] = {function (choice) -- assis2
				TriggerClientEvent("vrp_pets:seat", _source, 2)
				vRP.closeMenu(_source)
			end}
		end
		if (data == "Sit") then
			menudata["Sentar"] = {function (choice) -- assis3
				TriggerClientEvent("vrp_pets:seat", _source, 3)
				vRP.closeMenu(_source)
			end}
		end
	else
		menudata["Stand"] = {function (choice) -- debout
			TriggerClientEvent("vrp_pets:standup", _source)
			vRP.closeMenu(_source)
		end}
	end

	vRP.openMenu(_source, menudata)
end)

Client

local Tunnel = module("vrp", "lib/Tunnel")
local Proxy = module("vrp", "lib/Proxy")
vRP = Proxy.getInterface("vRP")
vRPclient = Tunnel.getInterface("vRP")

local Keys = {
	["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
	["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
	["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
	["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
	["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
	["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
	["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
	["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
	["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}

local Config = {}

Config.Zones = {
	PetShop = {
		Pos = {
			x = 562.19805908203,
			y = 2741.3090820313,
			z = 41.868915557861
		},
		Sprite = 463,
		Display = 4,
		Scale = 1.0,
		Size = {
			x = 1.5,
			y = 1.5,
			z = 1.0
		},
		Color = {
			r = 204,
			g = 204,
			b = 0
		},
		Type = 1
	}
}

local GUI = {}
GUI.Time = 0

local ped = {}
local model = {}
local status = 100

local come = 0
local isAttached = false
local animation = {}

local objCoords = nil
local balle = false
local object = {}

local inanimation = false
local getball = false
local bool = false

RegisterNetEvent("vrp_pets:callPet")
AddEventHandler("vrp_pets:callPet", function (data)
	if (data == "chien") then
		model = -1788665315
		come = 1
		spawnpet()
	elseif (data == "chat") then
		model = 1462895032
		come = 1
		spawnpet()
	elseif (data == "loup") then
		model = 1682622302
		come = 1
		spawnpet()
	elseif (data == "lapin") then
		model = -541762431
		come = 1
		spawnpet()
	elseif (data == "husky") then
		model = 1318032802
		come = 1
		spawnpet()
	elseif (data == "cochon") then
		model = -1323586730
		come = 1
		spawnpet()
	elseif (data == "caniche") then
		model = 1125994524
		come = 1
		spawnpet()
	elseif (data == "carlin") then
		model = 1832265812
		come = 1
		spawnpet()
	elseif (data == "retriever") then
		model = 882848737
		come = 1
		spawnpet()
	elseif (data == "berger") then
		model = 1126154828
		come = 1
		spawnpet()
	elseif (data == "westie") then
		model = -1384627013
		come = 1
		spawnpet()
	end
end)

RegisterNetEvent("vrp_pets:givefood")
AddEventHandler("vrp_pets:givefood", function (data)
	local inventory = data
	local amount = 0
	local coords1 = GetEntityCoords(GetPlayerPed(-1))
	local coords2 = GetEntityCoords(ped)
	local distance = GetDistanceBetweenCoords(coords1.x, coords1.y, coords1.z, coords2.x, coords2.y, coords2.z, true)
	for k,v in pairs(inventory) do
		if k == 'dogfood' then
			amount = inventory[k].amount
		end
	end
	if distance < 5 then
		if amount >= 1 then
			if status < 100 then
				status = status + math.random(2, 15)
				vRPClient._notify("You fed you pet.")
				TriggerServerEvent('vrp_pets:startHarvest')
				if status > 100 then
					status = 100
				end
				vRP.closeMenu()
			else
				vRPClient._notify("Your pet is full.")
			end
		else
			vRPClient._notify("~sr~Ran out of food!~s~")
		end
	else
		vRPClient._notify("~r~Your pet is too far away!~s~")
	end
end)

RegisterNetEvent("vrp_pets:attachdettach")
AddEventHandler("vrp_pets:attachdettach", function ()
	if not IsPedSittingInAnyVehicle(ped) then
		if isAttached == false then
			attached()
			isAttached = true
		else
			detached()
			isAttached = false
		end
	else
		vRPClient._notify("~r~You can\'t attach your pet in a car!~s~")
	end
end)

RegisterNetEvent("vrp_pets:enterleaveveh")
AddEventHandler("vrp_pets:enterleaveveh", function ()
	local coords = GetEntityCoords(GetPlayerPed(-1))
	local vehicle = GetVehiclePedIsUsing(GetPlayerPed(-1))
	local coords2 = GetEntityCoords(ped)
	local distance = GetDistanceBetweenCoords(coords.x, coords.y, coords.z, coords2.x,coords2.y,coords2.z,true)
	if not isInVehicle then
		if IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
			if distance < 8 then
				attached()
				Wait(200)
				if IsVehicleSeatFree(vehicle, 1) then
					SetPedIntoVehicle(ped, vehicle, 1)
					isInVehicle = true
				elseif IsVehicleSeatFree(vehicle, 2) then
					isInVehicle = true
					SetPedIntoVehicle(ped, vehicle, 2)
				elseif IsVehicleSeatFree(vehicle, 0) then
					isInVehicle = true
					SetPedIntoVehicle(ped, vehicle, 0)
				end 
				vRP.closeMenu()
			else
				vRPClient._notify("~r~Your pet is too far from the car!~s~")
			end
		else
			vRPClient._notify("You need to be in the car!")
		end
	else
		if not IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then
			SetEntityCoords(ped, coords.x, coords.y, coords.z, 1, 0, 0, 1)
			Wait(100)
			detached()
			isInVehicle = false
			vRP.closeMenu()
		else
			vRPClient._notify("Your still inside the car.")
		end
	end
end)

RegisterNetEvent("vrp_pets:findball")
AddEventHandler("vrp_pets:findball", function ()
	object = GetClosestObjectOfType(GetEntityCoords(ped).x, GetEntityCoords(ped).y, GetEntityCoords(ped).z, 190.0, GetHashKey('w_am_baseball'))
	if DoesEntityExist(object) then 
		balle = true
		objCoords = GetEntityCoords(object)
		TaskGoToCoordAnyMeans(ped, objCoords.x, objCoords.y, objCoords.z, 5.0, 0, 0, 786603, 0xbf800000)
		local GroupHandle = GetPlayerGroup(PlayerId())
		SetGroupSeparationRange(GroupHandle, 1.9)
		SetPedNeverLeavesGroup(ped, false)
	else
		vRPClient._notify("No balls left")
	end
end)

RegisterNetEvent("vrp_pets:followme")
AddEventHandler("vrp_pets:followme", function ()
	local coords1 = GetEntityCoords(GetPlayerPed(-1))
	TaskGoToCoordAnyMeans(ped, coords1.x, coords1.y, coords1.z, 5.0, 0, 0, 786603, 0xbf800000)
end)

RegisterNetEvent("vrp_pets:goHome")
AddEventHandler("vrp_pets:goHome", function ()
	local GroupHandle = GetPlayerGroup(PlayerId())
	local coords= GetEntityCoords(GetPlayerPed(-1))
	SetGroupSeparationRange(GroupHandle, 1.9)
	SetPedNeverLeavesGroup(ped, false)
	TaskGoToCoordAnyMeans(ped, coords.x + 40, coords.y, coords.z, 5.0, 0, 0, 786603, 0xbf800000)
	Wait(5000)
	DeleteEntity(ped)
	come = 0
end)
RegisterNetEvent("vrp_pets:seat")
AddEventHandler("vrp_pets:seat", function (method)
	if method == 1 then
		RequestAnimDict('creatures@rottweiler@amb@world_dog_sitting@base')
		while not HasAnimDictLoaded('creatures@rottweiler@amb@world_dog_sitting@base') do
			Wait(0)
		end
		TaskPlayAnim(ped, 'creatures@rottweiler@amb@world_dog_sitting@base', 'base' ,8.0, -8, -1, 1, 0, false, false, false) 
		inanimation = true
	elseif method == 2 then
		RequestAnimDict('creatures@carlin@amb@world_dog_sitting@idle_a')
		while not HasAnimDictLoaded('creatures@carlin@amb@world_dog_sitting@idle_a') do
			Wait(0)
		end
		TaskPlayAnim(ped, 'creatures@carlin@amb@world_dog_sitting@idle_a', 'idle_b' ,8.0, -8, -1, 1, 0, false, false, false)
		inanimation = true
	elseif method == 3 then
		RequestAnimDict('creatures@retriever@amb@world_dog_sitting@idle_a')
		while not HasAnimDictLoaded('creatures@retriever@amb@world_dog_sitting@idle_a') do
			Wait(0)
		end
		TaskPlayAnim(ped, 'creatures@retriever@amb@world_dog_sitting@idle_a', 'idle_c' ,8.0, -8, -1, 1, 0, false, false, false)
		inanimation = true
	end
end)

RegisterNetEvent("vrp_pets:laydown")
AddEventHandler("vrp_pets:laydown", function (method)
	if method == 1 then
		RequestAnimDict('creatures@rottweiler@amb@sleep_in_kennel@')
		while not HasAnimDictLoaded('creatures@rottweiler@amb@sleep_in_kennel@') do
			Wait(0)
		end
		TaskPlayAnim(ped, 'creatures@rottweiler@amb@sleep_in_kennel@', 'sleep_in_kennel' ,8.0, -8, -1, 1, 0, false, false, false)
		inanimation = true
	elseif method == 2 then
		RequestAnimDict('creatures@cat@amb@world_cat_sleeping_ground@idle_a')
		while not HasAnimDictLoaded('creatures@cat@amb@world_cat_sleeping_ground@idle_a') do
			Wait(0)
		end
		TaskPlayAnim(ped, 'creatures@cat@amb@world_cat_sleeping_ground@idle_a', 'idle_a' ,8.0, -8, -1, 1, 0, false, false, false)
		inanimation = true
	elseif method == 3 then
		RequestAnimDict('creatures@coyote@amb@world_coyote_rest@idle_a')
		while not HasAnimDictLoaded('creatures@coyote@amb@world_coyote_rest@idle_a') do
			Wait(0)
		end
		TaskPlayAnim(ped, 'creatures@coyote@amb@world_coyote_rest@idle_a', 'idle_a' ,8.0, -8, -1, 1, 0, false, false, false)
		inanimation = true
	end
end)

RegisterNetEvent("vrp_pets:standup")
AddEventHandler("vrp_pets:standup", function ()
	ClearPedTasks(ped)
	inanimation = false
end)

function OpenAnimal()
	TriggerServerEvent("vrp_pets:petMenu", status, come, isInVehicle)
end

RegisterNetEvent("vrp_pets:orders")
AddEventHandler("vrp_pets:orders", function (data)
	TriggerServerEvent("vrp_pets:ordersMenu", data, model, inanimation)
end)

Citizen.CreateThread(function()
	while true do
		Wait(30)
		if balle == true then
			local coords1 = GetEntityCoords(GetPlayerPed(-1))
			local coords2 = GetEntityCoords(ped)
			local distance = GetDistanceBetweenCoords(objCoords.x, objCoords.y, objCoords.z, coords2.x, coords2.y, coords2.z, true)
			local distance2 = GetDistanceBetweenCoords(coords1.x, coords1.y, coords1.z, coords2.x, coords2.y, coords2.z, true)
			if distance < 0.5 then
				AttachEntityToEntity(object, ped, GetPedBoneIndex(ped, 17188), 0.120, 0.010, 0.010, 5.0, 150.0, 0.0, true, true, false, true, 1, true)
				TaskGoToCoordAnyMeans(ped, coords1.x, coords1.y, coords1.z, 5.0, 0, 0, 786603, 0xbf800000)
				balle = false
				getball = true
			end
		end
		if getball == true then
			local coords1 = GetEntityCoords(GetPlayerPed(-1))
			local coords2 = GetEntityCoords(ped)
			local distance2 = GetDistanceBetweenCoords(coords1.x, coords1.y, coords1.z, coords2.x, coords2.y, coords2.z, true)
			if distance2 < 1.5 then
				DetachEntity(object,false,false)
				Wait(50)
				SetEntityAsMissionEntity(object)
				DeleteEntity(object)
				GiveWeaponToPed(GetPlayerPed(-1), GetHashKey("WEAPON_BALL"), 1, false, true)
				local GroupHandle = GetPlayerGroup(PlayerId())
				SetGroupSeparationRange(GroupHandle, 999999.9)
				SetPedNeverLeavesGroup(ped, true)
				SetPedAsGroupMember(ped, GroupHandle)
				getball = false
			end
		end
	end
end)

function attached()
	local playerPed = GetPlayerPed(-1)
	local GroupHandle = GetPlayerGroup(PlayerId())
	SetGroupSeparationRange(GroupHandle, 1.9)
	SetPedNeverLeavesGroup(ped, false)
	FreezeEntityPosition(ped, true)
end

function detached()
	local playerPed = GetPlayerPed(-1)
	local GroupHandle = GetPlayerGroup(PlayerId())
	SetGroupSeparationRange(GroupHandle, 999999.9)
	SetPedNeverLeavesGroup(ped, true)
	SetPedAsGroupMember(ped, GroupHandle)
	FreezeEntityPosition(ped, false)
end

function spawnpet()
	RequestModel(model)
	while(not HasModelLoaded(model)) do
		Citizen.Wait(1)
	end
	local playerPed = GetPlayerPed(-1)
	local LastPosition = GetEntityCoords(GetPlayerPed(-1))
	local GroupHandle = GetPlayerGroup(PlayerId())
	RequestAnimDict('rcmnigel1c')
	while not HasAnimDictLoaded('rcmnigel1c') do
		Wait(0)
	end
	TaskPlayAnim(GetPlayerPed(-1), 'rcmnigel1c', 'hailing_whistle_waive_a', 8.0, -8, -1, 120, 0, false, false, false)
	SetTimeout(5000, function() -- 5 secondes
		ped = CreatePed(28, model, LastPosition.x +1, LastPosition.y +1, LastPosition.z -1, 1, 1)
		SetPedAsGroupLeader(playerPed, GroupHandle)
		SetPedAsGroupMember(ped, GroupHandle)
		SetPedNeverLeavesGroup(ped, true)
		SetPedCanBeTargetted(ped, false)
		SetEntityAsMissionEntity(ped, true,true)
		status = math.random(40, 90)
		Wait(5)
		attached()
		Wait(5)
		detached()
	end)
end

Citizen.CreateThread(function()
	while true do
		Wait(math.random(60000, 120000))
		if come == 1 then
			status = status - 1
		end
		if status == 0 then
			TriggerServerEvent('vrp_pets:dead')
			DeleteEntity(ped)
			vRPClient._notify("Your pet died of starvation, you need to feed him!")
			come = 3
			status = "die"
		end
	end
end)

-- Key Controls
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsControlPressed(0, Keys['F9']) and (GetGameTimer() - GUI.Time) > 150 then
			OpenAnimal()
			GUI.Time = GetGameTimer()
		end
	end
end)

-- Create Blips
Citizen.CreateThread(function()
	local blip = AddBlipForCoord(Config.Zones.PetShop.Pos.x, Config.Zones.PetShop.Pos.y, Config.Zones.PetShop.Pos.z)
	
	SetBlipSprite(blip, Config.Zones.PetShop.Sprite)
	SetBlipDisplay(blip, Config.Zones.PetShop.Display)
	SetBlipScale(blip, Config.Zones.PetShop.Scale)
	SetBlipAsShortRange(blip, true)
	BeginTextCommandSetBlipName("STRING")
	AddTextComponentString("Loja de Animais")
	EndTextCommandSetBlipName(blip)
end)

Citizen.CreateThread(function()
	while true do
		Wait(0)
		local coord = GetEntityCoords(GetPlayerPed(-1), true)
		if GetDistanceBetweenCoords(coord, Config.Zones.PetShop.Pos.x,Config.Zones.PetShop.Pos.y,Config.Zones.PetShop.Pos.z, false) < 5 then
			DisplayHelpText("Press [~g~E~s~] to open the the pet store.")
			if IsControlJustPressed(0, Keys['E']) then
				buy_animal()
			end
		end
		if CurrentAction ~= nil then
			SetTextComponentFormat('STRING')
			AddTextComponentString(CurrentActionMsg)
			DisplayHelpTextFromStringLabel(0, 0, 1, -1)
			if IsControlPressed(0, Keys['E']) and (GetGameTimer() - GUI.Time) > 150 then
				if CurrentAction == 'remove_entity' then
					DeleteEntity(CurrentActionData.entity)
				end
				CurrentAction = nil
				GUI.Time = GetGameTimer()
			end
		end
	end
end)

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

function buy_animal()
	TriggerServerEvent("vrp_pets:buypet")
end


-- Bal

Almost works any idea to get it working properly Guys!

1 Like

Nothing BradXY. I’ve tried all the ways. I’m having trouble converting to use vrp_mysql

Hello. I have a server that uses phpMyAdmin but I do not know how to insert the column to make the animals appear on the server. Can someone help me?

Pure a me non spawnano gli animali.

[ERROR] [MySQL] An error happens on MySQL for query “SELECT * FROM vrp_users WHERE id = @id {@id=1}”: Access denied for user ‘dbxxx’@‘xxx.xx.xx.xxx’ (using password: NO)

Any1 solved this ? I replaced ip etc with “X” just to be safe here.

Is your MySQL server on the same machine of the server ? Is your MySQL server configured to accept outcomming connections ? If yes and no, replace the IP on the connection with 127.0.0.1
If yes or no and yes, you probably just need to create that user for outcomming connections (%)

Also: if your answer to the first question is yes, it isn’t a good idea to have a user without a password to be able to connect to the MySQL server remotely

Same machine, it is configured to accept outcoming connections, i would love to even try to change that IP, but there’s no specificated file location for it.

Go on phpmyadmin if you have it, create a new user with that name for the ip “%” that will make it so that user can connect from any IP, also try adding a password to your user because you already gave half of your user name here, that is if you don’t want people entering your MySQL server and dropping every table