Jump to content

[HELP]Replacing models


TheBull

Recommended Posts

Posted

Helloo

I tried to make a script which can replace the current hydra to a customized one for (VIP) players only ,The script didn't work

I would really appreciate if you guys help me , Here is my code :

local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
txd = engineLoadTXD("hydra.txd") 
engineImportTXD(txd, 520) 
dff = engineLoadDFF("hydra.dff", 560) 
engineReplaceModel(dff, 520) end 

and the error is : ERROR:Hydra\replace.lua:1: attempt to call global "getPlayerAccount" (a nil value)

Posted

To be more descriptive; you're trying to use server-side functions in a client-side script.

You'll need to do the ACL check in a server-sided script, and if they are listed as a VIP - then you can use triggerClientEvent to replace their vehicle model.

Also make sure the thePlayer variable is a player element, and not returning nil.

Posted

Hmm,Here's what i made :

Server :

function vipReplaceModele () 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
    end 
    triggerServerEvent ( "onReplace", resourceRoot )    
end 

Client :

function replaceModele ()    
    txd = engineLoadTXD("hydra.txd") 
    engineImportTXD(txd, 520) 
    dff = engineLoadDFF("hydra.dff", 520) 
    engineReplaceModel(dff, 520) 
end 
addEvent( "onReplace", true ) 
addEventHandler( "onReplace", resourceRoot, replaceModele ) 

But it didn't work tho,there are no errors.

Posted

Server

function vipReplaceModele (thePlayer) 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
    end 
end 
addEvent( "onReplace", true ) 
addEventHandler( "onReplace", root, vipReplaceModele ) 

client

  
function replaceModele ()   
triggerServerEvent("onReplace",localPlayer) 
    txd = engineLoadTXD("hydra.txd") 
    engineImportTXD(txd, 520) 
    dff = engineLoadDFF("hydra.dff", 520) 
    engineReplaceModel(dff, 520) 
end 
addEventHandler("onPlayerLogin",root,replaceModele) 

Posted
function vipReplaceModele (_, acc) 
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
           triggerClientEvent (source,  "onReplace", root )   
    end 
end 
addEventHandler('onPlayerLogin', root, vipReplaceModele) 

  
function replaceModele ()   
    local txd = engineLoadTXD("hydra.txd") 
    engineImportTXD(txd, 520) 
    local dff = engineLoadDFF("hydra.dff", 520) 
    engineReplaceModel(dff, 520) 
end 
addEvent( "onReplace", true ) 
addEventHandler( "onReplace", root, replaceModele ) 

Posted

It works perfectly,but the one i want is that vip players have their own hydra, and when a vip player see a player who's not vip he will see him in the normal hydra,not the customized one which the vip player have,and the same situation to the non-vip player.

Posted

You can replace models for certain players, however, you can't replace certain vehicles, you have to replace all the vehicles of the same model.

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