Hello all,
I was making a simple toggleable K9 for vRP police.
here’s what i have so far. When F1 is pressed it should spawn the dog, get it to follow the player. Then when its pressed again it simply deletes the dog.
RegisterNetEvent('PoliceDog')
AddEventHandler('PoliceDog', function(x, y, z)
-- PED variables
local ped = GetPlayerPed(-1) -- Define Player
local heading = GetEntityHeading(ped) -- Gets the players looking direction
local user_id = vRP.getUserId(source) -- get the Players ID
local plyPos = GetEntityCoords(ped(1), true) -- Define Player location
-- K9 Variables
local modelName = "A_C_Husky" -- Police K9 PED model
local modelHash = (GetHashKey(modelName)) -- Gets the models HashKey
RequestModel(modelHash) -- NOT SURE TBH
local K9 = CreatePed(modelHash, plyPos.x + (frontx * 10), plyPos.y + (fronty * 10)-- Creates The K9 entity variable
local K9Spawned = false -- is K9 spawned boolean
Citizen.Wait(0) -- Prevents crashing
if user_id ~= nil and vRP.hasPermission(user_id,"police.paycheck") then -- Check if player exists and is on duty as cop
Citizen.Wait(0) -- Prevents crashing
if IsControlJustPressed(3,288) and (K9Spawned = false) then -- F1 Key pressed do...
-- Spawn in K9
CreatePed(modelHash, plyPos.x + (frontx * 10), plyPos.y + (fronty * 10)
TaskGoToEntity(K9, ped, -1, 1.0, 10.0, 1073741824.0, 0) -- Get K9 to follow player
SetPedKeepTask(K9, true) -- Make sure the K9 doesnt run away cause his life is bad...
K9Spawned = true
else
if IsControlJustPressed(3,288) and (K9Spawned = true) then
DeletePed(K9)
K9Spawned = false
end
end
elseif user_id ~= nil and (ped ~= vRP.hasPermission(user_id,"police.paycheck")) then -- Prevents Cives without police.paycheck from spawning K9
if IsControlJustPressed(3,288) then -- F1 Key pressed do...
SetNotificationTextEntry("STRING") -- Makes the notification a string
AddTextComponentString("~b~You are not on duty as a Police Officer.") -- Notification Text
DrawNotification(true, false) -- Spawn notification
end
end
end)
That’s all done on the client side. When i press the key the dog doesn’t spawn. Is the key wrong or is there something wring with the script.
Any ideas?
Regards
Catraz