Jump to content

2 questions about scripts


tim260

Recommended Posts

first off can someone see what wrong to the code below so thats the first question :P

function createTeamsOnStart () 
    teamPolice = createTeam ( "Police", 0, 0, 255 ) 
    teamRobber = createTeam ( "Robber", 255, 0, 0 ) 
    teamMechanics = createTeam ( "Mechanics", 0, 255, 0 ) 
    teamWhores = createTeam ( "Whores", 255, 0, 255 ) 
    teamPilot = createTeam ( "Pilot", 255, 255, 0 ) 
    teamTruker = createTeam ( "Trucker", 192, 192, 192 ) 
    teamNubcaker = createTeam ( "Nubcaker INC.", 192, 192, 192 ) 
    teamDealers = createTeam ( "Dealers", 255, 0, 0 ) 
    teamMilitary = createTeam ( "Military", 0, 255, 0 ) 
    teamNaval = createTeam ( "Naval", 0, 255, 0 ) 
    teamSecurity = createTeam ( "Security", 0, 255, 0 ) 
    teamSecurity = createTeam ( "investors", 255, 255, 0 ) 
    teamGuests = createTeam ( "Guests", 255, 255, 0 ) 
  
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart  ) 

Second question,

Is it possible to replace weapons i tried it with the

engineLoadDFF 
engineLoadTXD 

but it didnt work so can someone explain it to me.

Link to comment

1): Check if your meta.xml in the script of teams is type="server".

2): Use this:

function load() 
    txd = engineLoadTXD ("m4.txd" ) 
    engineImportTXD ( txd, 356 ) 
    dff = engineLoadDFF ( "m4.dff", 0 ) 
    engineReplaceModel ( dff, 356 ) 
end 
  
addEventHandler("onClientResourceStart",resourceRoot, 
function () 
    local version = getVersion() 
    if string.find(version.mta, "1.1.1") then 
        setTimer ( load, 1000, 1) 
    end 
end) 

The script for weapon replacement must be type="client" in meta.xml.

You can only replace weapons, skin models in MTA 1.1.1, not 1.1.

Link to comment

Yes i changed it ;p

function load()  
  txd = engineLoadTXD("gun.txd", 31 ) 
  engineImportTXD(txd, 31) 
  dff = engineLoadDFF("gun.dff", 31 ) 
  engineReplaceModel(dff, 31) 
end 
  
addEventHandler("onClientResourceStart",resourceRoot, 
function () 
    local version = getVersion() 
    if string.find(version.mta, "1.1.1") then 
        setTimer ( load, 1000, 1) 
    end 
end) 

  
 
   type="script" version="1.0" author="tim"/>  
   

Link to comment

See? you changed my script, you didn't read how it worked.

You must use the weapon OBJECT model ID's not the weapon model ID.

You can find weapon OBJECT model in this link: https://wiki.multitheftauto.com/wiki/Weapons

-- client.lua

function load() 
  txd = engineLoadTXD("gun.txd", 356 ) 
  engineImportTXD(txd, 356) 
  dff = engineLoadDFF("gun.dff", 0 ) -- IT HAS TO BE 0 IF NOT REPLACING A VEHICLE. 
  engineReplaceModel(dff, 356) 
end 
  
addEventHandler("onClientResourceStart",resourceRoot, 
function () 
    local version = getVersion() 
    if string.find(version.mta, "1.1.1") then 
        setTimer ( load, 1000, 1) 
    end 
end) 

-- meta.xml:

   type="script" version="1.0" author="tim"/> 
   

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