Hello, so I have a script that will fire a missile when a specific key is pressed and a waypoint is set.
The code to fire is
ShootSingleBulletBetweenCoords(x, y, 900.0, x+math.random(-20, 20), y+math.random(-20, 20), 0.0, 0, false, “WEAPON_AIRSTRIKE_ROCKET1”, source, true, false, -1.0)
How would I go about making synced to other players, because right now only the person who called in the “airstrike” can see it and ShootSingleBullet… is only a client native.
The native docs states:
Maybe send an event to all clients requesting the weapon asset? Not sure if thats even the issue as to why they dont see it, but you could try it.
The Request_Weapon_Asset is only client sided.
I tried registering it as an event and calling it in the server script but that didn’t work either.
Any ideas?
You’ll have a register a server event that triggers a client event
server:
RegisterServerEvent("ServerEvent")
AddEventHandler("ServerEvent", function()
TriggerClientEvent("ClientEvent", -1)
end)
client:
RegisterNetEvent("ClientEvent")
AddEventHandler("ClientEvent", function()
RequestWeaponAsset(...)
end)
Rightnow I have this
cl.lua
RegisterNetEvent(“strike_weapon”)
AddEventHandler(“strike_weapon”, function(source)
RequestWeaponAsset(GetHashKey(“WEAPON_AIRSTRIKE_ROCKET1”))
while not HasWeaponAssetLoaded(GetHashKey(“WEAPON_AIRSTRIKE_ROCKET1”)) do
Wait(0)
end
end)
sv.lua
RegisterCommand(“strike”, function(source)
if IsPlayerAceAllowed(source, “arty.strike”) then
TriggerClientEvent(‘strike_weapon’, -1)
TriggerClientEvent(‘strike_client’, source)
else
TriggerClientEvent(‘chatMessage’, source, “^1Insufficient Permissions!”)
end
end)