Jump to content

Problem Weapon


WASSIm.

Recommended Posts

hi guys i want make functions weapon server side like createWeapon and setWeaponOwner... but have problem

Client

function oncreateWeapon( theWeapon, x, y, z ) 
    createWeapon(theWeapon, x, y, z ) 
end 
  
function onfireWeapon( theWeapon ) 
    fireWeapon(theWeapon) 
end 
  
function ongetWeaponState( theWeapon ) 
    getWeaponState(theWeapon) 
end 
  
function ongetWeaponTarget( theWeapon ) 
    getWeaponTarget(theWeapon) 
end 
  
function ongetWeaponOwner( theWeapon ) 
    getWeaponOwner(theWeapon) 
end 
  
function ongetWeaponFlags( theWeapon ) 
    getWeaponOwner(theWeapon) 
end 
  
function ongetWeaponAmmo( theWeapon ) 
    getWeaponAmmo(theWeapon) 
end 
  
function ongetWeaponClipAmmo( theWeapon ) 
    getWeaponClipAmmo(theWeapon) 
end 
  
function onresetWeaponFiringRate( theWeapon ) 
    resetWeaponFiringRate(theWeapon) 
end 
  
function onsetWeaponProperty( theWeapon, strProperty, theValue ) 
    setWeaponProperty(theWeapon,strProperty,theValue) 
end 
  
function onsetWeaponState( theWeapon, theState ) 
    setWeaponState(theWeapon,theState) 
end 
  
function onsetWeaponTarget( theWeapon, theTarget, iComponentID ) 
    setWeaponTarget(theWeapon,theTarget,iComponentID) 
end 
  
function onsetWeaponOwner( theWeapon, theOwner ) 
    setWeaponOwner(theWeapon,theOwner) 
end 
  
function onsetWeaponFlags( theWeapon, theFlag, theValue ) 
    setWeaponFlags(theWeapon,theOwner) 
end 
  
function onsetWeaponFiringRate( theWeapon, firingRate ) 
    setWeaponFiringRate(theWeapon,firingRate) 
end 
  
function onsetWeaponAmmo( theWeapon, Ammo ) 
    setWeaponAmmo(theWeapon,Ammo) 
end 
  
function onsetWeaponClipAmmo( theWeapon, clipAmmo ) 
    setWeaponClipAmmo(theWeapon,clipAmmo) 
end 
  
addEvent ( "oncreateWeapon", true ) 
addEvent ( "onfireWeapon", true ) 
addEvent ( "ongetWeaponState", true ) 
addEvent ( "ongetWeaponTarget", true ) 
addEvent ( "ongetWeaponOwner", true ) 
addEvent ( "ongetWeaponFlags", true ) 
addEvent ( "ongetWeaponAmmo", true ) 
addEvent ( "ongetWeaponClipAmmo", true ) 
addEvent ( "onresetWeaponFiringRate", true ) 
addEvent ( "onsetWeaponProperty", true ) 
addEvent ( "onsetWeaponState", true ) 
addEvent ( "onsetWeaponTarget", true ) 
addEvent ( "onsetWeaponOwner", true ) 
addEvent ( "onsetWeaponFlags", true ) 
addEvent ( "onsetWeaponFiringRate", true ) 
addEvent ( "onsetWeaponAmmo", true ) 
addEvent ( "onsetWeaponClipAmmo", true ) 
addEventHandler ( "oncreateWeapon", getRootElement(), oncreateWeapon ) 
addEventHandler ( "onfireWeapon", getRootElement(), onfireWeapon ) 
addEventHandler ( "ongetWeaponState", getRootElement(), ongetWeaponState ) 
addEventHandler ( "ongetWeaponTarget", getRootElement(), ongetWeaponTarget ) 
addEventHandler ( "ongetWeaponOwner", getRootElement(), ongetWeaponOwner ) 
addEventHandler ( "ongetWeaponFlags", getRootElement(), ongetWeaponFlags ) 
addEventHandler ( "ongetWeaponAmmo", getRootElement(), ongetWeaponAmmo ) 
addEventHandler ( "ongetWeaponClipAmmo", getRootElement(), ongetWeaponClipAmmo ) 
addEventHandler ( "onresetWeaponFiringRate", getRootElement(), onresetWeaponFiringRate ) 
addEventHandler ( "onsetWeaponProperty", getRootElement(), onsetWeaponProperty ) 
addEventHandler ( "onsetWeaponState", getRootElement(), onsetWeaponState ) 
addEventHandler ( "onsetWeaponTarget", getRootElement(), onsetWeaponTarget ) 
addEventHandler ( "onsetWeaponOwner", getRootElement(), onsetWeaponOwner) 
addEventHandler ( "onsetWeaponFlags", getRootElement(), onsetWeaponFlags) 
addEventHandler ( "onsetWeaponFiringRate", getRootElement(), onsetWeaponFiringRate) 
addEventHandler ( "onsetWeaponAmmo", getRootElement(), onsetWeaponAmmo) 
addEventHandler ( "onsetWeaponClipAmmo", getRootElement(), onsetWeaponClipAmmo) 

Server

function createWeapon( theWeapon, x, y, z ) 
    triggerClientEvent ( "oncreateWeapon", getRootElement(), theWeapon, x, y, z ) 
end 
  
function fireWeapon( theWeapon ) 
    triggerClientEvent ( "onfireWeapon", getRootElement(), theWeapon ) 
end 
  
function getWeaponState( theWeapon ) 
    triggerClientEvent ( "ongetWeaponState", getRootElement(), theWeapon ) 
end 
  
function getWeaponTarget( theWeapon ) 
    triggerClientEvent ( "ongetWeaponTarget", getRootElement(), theWeapon ) 
end 
  
function getWeaponOwner( theWeapon ) 
    triggerClientEvent ( "ongetWeaponOwner", getRootElement(), theWeapon ) 
end 
  
function getWeaponFlags( theWeapon ) 
    triggerClientEvent ( "ongetWeaponFlags", getRootElement(), theWeapon ) 
end 
  
function getWeaponAmmo( theWeapon ) 
    triggerClientEvent ( "ongetWeaponAmmo", getRootElement(), theWeapon ) 
end 
  
function getWeaponClipAmmo( theWeapon ) 
    triggerClientEvent ( "ongetWeaponClipAmmo", getRootElement(), theWeapon ) 
end 
  
function resetWeaponFiringRate( theWeapon ) 
    triggerClientEvent ( "onresetWeaponFiringRate", getRootElement(), theWeapon ) 
end 
  
function setWeaponProperty( theWeapon, strProperty, theValue ) 
    triggerClientEvent ( "onsetWeaponProperty", getRootElement(), theWeapon, strProperty, theValue ) 
end 
  
function setWeaponState( theWeapon, theState ) 
    triggerClientEvent ( "onsetWeaponState", getRootElement(), theWeapon, theState ) 
end 
  
function setWeaponTargete( theWeapon, theTarget, iComponentID ) 
    triggerClientEvent ( "onsetWeaponTarget", getRootElement(), theWeapon, theTarget, iComponentID  ) 
end 
  
function setWeaponOwner( theWeapon, theOwner ) 
    triggerClientEvent ( "onsetWeaponOwner", getRootElement(), theWeapon, theOwner ) 
end 
  
function setWeaponFlags( theWeapon, theFlag, theValue ) 
    triggerClientEvent ( "onsetWeaponFlags", getRootElement(), theWeapon, theFlag, theValue ) 
end 
  
function setWeaponFiringRate( theWeapon, firingRate ) 
    triggerClientEvent ( "onsetWeaponFiringRate", getRootElement(), theWeapon, firingRate ) 
end 
  
function setWeaponAmmo( theWeapon, Ammo ) 
    triggerClientEvent ( "onsetWeaponAmmo", getRootElement(), theWeapon, Ammo ) 
end 
  
function setWeaponClipAmmo( theWeapon, clipAmmo ) 
    triggerClientEvent ( "onsetWeaponClipAmmo", getRootElement(), theWeapon, clipAmmo ) 
end 

this Test Exmple (Server side)

function createMinigunWeapon(player) 
    local x, y, z = getElementPosition(player) 
    local weapon = createWeapon("minigun", x, y, z + 1) 
    setWeaponClipAmmo ( weapon,99999) 
    setWeaponState ( weapon,"firing") 
end 
addCommandHandler("createminigun", createMinigunWeapon) 

tell me in debug:jnS0vIm.png

Edited by Guest
Link to comment
delete Client server

server you mode /upgrade all

function createMinigunWeapon() 
    local x, y, z = getElementPosition(getLocalPlayer()) 
    local weapon = createWeapon("minigun", x, y, z + 1) 
    setWeaponClipAmmo ( weapon,99999) 
    setWeaponState ( weapon,"firing") 
end 
addCommandHandler("createminigun", createMinigunWeapon) 

https://wiki.multitheftauto.com/wiki/CreateWeapon

i testing script with functions weapons server side

Link to comment

i use like this. but its before i make script swat tank shot minigun and i lost that script

Client

function oncreateWeapon( theWeapon, x, y, z ) 
    createWeapon(theWeapon, x, y, z ) 
end 
  
function onfireWeapon( theWeapon ) 
    fireWeapon(theWeapon) 
end 
  
function ongetWeaponState( theWeapon ) 
    getWeaponState(theWeapon) 
end 
  
function ongetWeaponTarget( theWeapon ) 
    getWeaponTarget(theWeapon) 
end 
  
function ongetWeaponOwner( theWeapon ) 
    getWeaponOwner(theWeapon) 
end 
  
function ongetWeaponFlags( theWeapon ) 
    getWeaponOwner(theWeapon) 
end 
  
function ongetWeaponAmmo( theWeapon ) 
    getWeaponAmmo(theWeapon) 
end 
  
function ongetWeaponClipAmmo( theWeapon ) 
    getWeaponClipAmmo(theWeapon) 
end 
  
function onresetWeaponFiringRate( theWeapon ) 
    resetWeaponFiringRate(theWeapon) 
end 
  
function onsetWeaponProperty( theWeapon, strProperty, theValue ) 
    setWeaponProperty(theWeapon,strProperty,theValue) 
end 
  
function onsetWeaponState( theWeapon, theState ) 
    setWeaponState(theWeapon,theState) 
end 
  
function onsetWeaponTarget( theWeapon, theTarget, iComponentID ) 
    setWeaponTarget(theWeapon,theTarget,iComponentID) 
end 
  
function onsetWeaponOwner( theWeapon, theOwner ) 
    setWeaponOwner(theWeapon,theOwner) 
end 
  
function onsetWeaponFlags( theWeapon, theFlag, theValue ) 
    setWeaponFlags(theWeapon,theOwner) 
end 
  
function onsetWeaponFiringRate( theWeapon, firingRate ) 
    setWeaponFiringRate(theWeapon,firingRate) 
end 
  
function onsetWeaponAmmo( theWeapon, Ammo ) 
    setWeaponAmmo(theWeapon,Ammo) 
end 
  
function onsetWeaponClipAmmo( theWeapon, clipAmmo ) 
    setWeaponClipAmmo(theWeapon,clipAmmo) 
end 
  
addEvent ( "oncreateWeapon", true ) 
addEvent ( "onfireWeapon", true ) 
addEvent ( "ongetWeaponState", true ) 
addEvent ( "ongetWeaponTarget", true ) 
addEvent ( "ongetWeaponOwner", true ) 
addEvent ( "ongetWeaponFlags", true ) 
addEvent ( "ongetWeaponAmmo", true ) 
addEvent ( "ongetWeaponClipAmmo", true ) 
addEvent ( "onresetWeaponFiringRate", true ) 
addEvent ( "onsetWeaponProperty", true ) 
addEvent ( "onsetWeaponState", true ) 
addEvent ( "onsetWeaponTarget", true ) 
addEvent ( "onsetWeaponOwner", true ) 
addEvent ( "onsetWeaponFlags", true ) 
addEvent ( "onsetWeaponFiringRate", true ) 
addEvent ( "onsetWeaponAmmo", true ) 
addEvent ( "onsetWeaponClipAmmo", true ) 
addEventHandler ( "oncreateWeapon", getRootElement(), oncreateWeapon ) 
addEventHandler ( "onfireWeapon", getRootElement(), onfireWeapon ) 
addEventHandler ( "ongetWeaponState", getRootElement(), ongetWeaponState ) 
addEventHandler ( "ongetWeaponTarget", getRootElement(), ongetWeaponTarget ) 
addEventHandler ( "ongetWeaponOwner", getRootElement(), ongetWeaponOwner ) 
addEventHandler ( "ongetWeaponFlags", getRootElement(), ongetWeaponFlags ) 
addEventHandler ( "ongetWeaponAmmo", getRootElement(), ongetWeaponAmmo ) 
addEventHandler ( "ongetWeaponClipAmmo", getRootElement(), ongetWeaponClipAmmo ) 
addEventHandler ( "onresetWeaponFiringRate", getRootElement(), onresetWeaponFiringRate ) 
addEventHandler ( "onsetWeaponProperty", getRootElement(), onsetWeaponProperty ) 
addEventHandler ( "onsetWeaponState", getRootElement(), onsetWeaponState ) 
addEventHandler ( "onsetWeaponTarget", getRootElement(), onsetWeaponTarget ) 
addEventHandler ( "onsetWeaponOwner", getRootElement(), onsetWeaponOwner) 
addEventHandler ( "onsetWeaponFlags", getRootElement(), onsetWeaponFlags) 
addEventHandler ( "onsetWeaponFiringRate", getRootElement(), onsetWeaponFiringRate) 
addEventHandler ( "onsetWeaponAmmo", getRootElement(), onsetWeaponAmmo) 
addEventHandler ( "onsetWeaponClipAmmo", getRootElement(), onsetWeaponClipAmmo) 

Server

function createWeapon( theWeapon, x, y, z ) 
    triggerClientEvent ( "oncreateWeapon", getRootElement(), theWeapon, x, y, z ) 
end 
  
function fireWeapon( theWeapon ) 
    triggerClientEvent ( "onfireWeapon", getRootElement(), theWeapon ) 
end 
  
function getWeaponState( theWeapon ) 
    triggerClientEvent ( "ongetWeaponState", getRootElement(), theWeapon ) 
end 
  
function getWeaponTarget( theWeapon ) 
    triggerClientEvent ( "ongetWeaponTarget", getRootElement(), theWeapon ) 
end 
  
function getWeaponOwner( theWeapon ) 
    triggerClientEvent ( "ongetWeaponOwner", getRootElement(), theWeapon ) 
end 
  
function getWeaponFlags( theWeapon ) 
    triggerClientEvent ( "ongetWeaponFlags", getRootElement(), theWeapon ) 
end 
  
function getWeaponAmmo( theWeapon ) 
    triggerClientEvent ( "ongetWeaponAmmo", getRootElement(), theWeapon ) 
end 
  
function getWeaponClipAmmo( theWeapon ) 
    triggerClientEvent ( "ongetWeaponClipAmmo", getRootElement(), theWeapon ) 
end 
  
function resetWeaponFiringRate( theWeapon ) 
    triggerClientEvent ( "onresetWeaponFiringRate", getRootElement(), theWeapon ) 
end 
  
function setWeaponProperty( theWeapon, strProperty, theValue ) 
    triggerClientEvent ( "onsetWeaponProperty", getRootElement(), theWeapon, strProperty, theValue ) 
end 
  
function setWeaponState( theWeapon, theState ) 
    triggerClientEvent ( "onsetWeaponState", getRootElement(), theWeapon, theState ) 
end 
  
function setWeaponTargete( theWeapon, theTarget, iComponentID ) 
    triggerClientEvent ( "onsetWeaponTarget", getRootElement(), theWeapon, theTarget, iComponentID  ) 
end 
  
function setWeaponOwner( theWeapon, theOwner ) 
    triggerClientEvent ( "onsetWeaponOwner", getRootElement(), theWeapon, theOwner ) 
end 
  
function setWeaponFlags( theWeapon, theFlag, theValue ) 
    triggerClientEvent ( "onsetWeaponFlags", getRootElement(), theWeapon, theFlag, theValue ) 
end 
  
function setWeaponFiringRate( theWeapon, firingRate ) 
    triggerClientEvent ( "onsetWeaponFiringRate", getRootElement(), theWeapon, firingRate ) 
end 
  
function setWeaponAmmo( theWeapon, Ammo ) 
    triggerClientEvent ( "onsetWeaponAmmo", getRootElement(), theWeapon, Ammo ) 
end 

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...