Jump to content

Custom weapon firing but not damaging


Elmatus

Recommended Posts

Hi, thanks everyone beforehand

I'm making a script o attach a m4 in a migun base and that a player can enter it and shoot.

When I tested it with a friend in the server, he doesn't see the bullets coming out. I made it shootable everywhere (me far from the minigun bae) and I stepped in front of it, and I do get killed.

I think the problem has to be with being client-side. But createWeapon is only a client-side function.

Here is the function that fires the weapon:

Client-side

  
  
customWeapon = createWeapon ("m4",0,0,0) 
setElementAlpha(customWeapon,0) 
setElementCollisionsEnabled(customWeapon,false) -- For field of view bug 
attachElements (customWeapon,minigun,0.5,0,1.1,0,0,0) 
setWeaponClipAmmo(customWeapon, 99999) 
setWeaponFlags (customWeapon, "disable_model",true) -- Hides it 
setWeaponFiringRate(customWeapon,50) 
  
function startFiring (_, state) 
    if state == "down" then setWeaponState(customWeapon, "firing") 
    else setWeaponState(customWeapon, "ready") 
    end 
end 
  
bindKey ("mouse1","both",startFiring) 
  

Link to comment
Hi, thanks everyone beforehand

I'm making a script o attach a m4 in a migun base and that a player can enter it and shoot.

When I tested it with a friend in the server, he doesn't see the bullets coming out. I made it shootable everywhere (me far from the minigun bae) and I stepped in front of it, and I do get killed.

I think the problem has to be with being client-side. But createWeapon is only a client-side function.

Here is the function that fires the weapon:

Client-side

  
  
customWeapon = createWeapon ("m4",0,0,0) 
setElementAlpha(customWeapon,0) 
setElementCollisionsEnabled(customWeapon,false) -- For field of view bug 
attachElements (customWeapon,minigun,0.5,0,1.1,0,0,0) 
setWeaponClipAmmo(customWeapon, 99999) 
setWeaponFlags (customWeapon, "disable_model",true) -- Hides it 
setWeaponFiringRate(customWeapon,50) 
  
function startFiring (_, state) 
    if state == "down" then setWeaponState(customWeapon, "firing") 
    else setWeaponState(customWeapon, "ready") 
    end 
end 
  
bindKey ("mouse1","both",startFiring) 
  

Your problem is that you didn't sync your function to the server side, use triggerServerClient and then triggerClientEvent for all the players in the server

Link to comment

Your problem is that you didn't sync your function to the server side, use triggerServerClient and then triggerClientEvent for all the players in the server

I didn't realize that, thanks! I have another question, too small for making it a post.

Can you get a return in server-side, by a client-side? Or vice versa

Link to comment

Your problem is that you didn't sync your function to the server side, use triggerServerClient and then triggerClientEvent for all the players in the server

I didn't realize that, thanks! I have another question, too small for making it a post.

Can you get a return in server-side, by a client-side? Or vice versa

You can just use triggerServerEvent to trigger back

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...