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.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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) 

2vjs7it.jpg
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 ) 

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

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.

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