Jump to content

Hydra model just for team


Recommended Posts

Is it possible that one modded hydra model will spawn for a specific team only? Otherwise, if player isnt in that specific team it will spawn the default hydra?

Can someone put an example?

function replaceModel() 
local team = getPlayerTeam(source) 
if team and getTeamFromName("Warriors") then 
--engine replace thingy-- 
else 
return false 
end 
end 
addEventHandler("onClientResourceStart", root, replaceModel) 

Should it be like this? Please help.

Link to comment
Is it possible that one modded hydra model will spawn for a specific team only? Otherwise, if player isnt in that specific team it will spawn the default hydra?

Can someone put an example?

function replaceModel() 
local team = getPlayerTeam(source) 
if team and getTeamFromName("Warriors") then 
--engine replace thingy-- 
else 
return false 
end 
end 
addEventHandler("onClientResourceStart", root, replaceModel) 

Should it be like this? Please help.

Wrong , simply because you are trying to check the resource team

The source of this event "onClientResourceStart" is the started resource's root element.

e84c6cadc6.png

Link to comment

I actually wanted it for my shop system, so I edited the code where we buy the hydra. Should it be like this?

function theHydra() 
local team = getPlayerTeam(source) 
if team and getTeamFromName("Warriors") then 
txd = engineLoadTXD ( "hydra.txd" ) 
engineImportTXD ( txd, 587 ) 
dff = engineLoadDFF ( "hydra.dff", 0 ) 
engineReplaceModel ( dff, 587 ) 
end 
end 
local money = getPlayerMoney(source) 
if not (money > 24999) then 
return outputChatBox("You don't have enough money to afford this vehicle!", source, 255, 0, 0) 
end 
takePlayerMoney(source, 25000) 
local x, y, z = getElementPosition(source) 
local veh = createVehicle(520, x, y, z) 
outputChatBox("You purchased #ffffffHydra!", source, 0, 355, 0, true) 
warpPedIntoVehicle(source, veh) 
end 
addEventHandler("Hydra", root, theHydra) 

Will it spawn the modded hydra for the team and default hydra if player isnt in Warriors team?

Link to comment

-- Client side

addEventHandler("onClientResourceStart",resourceRoot, 
function() 
    triggerServerEvent( "clientReady", resourceRoot ) 
end 
) 

-- Server side

  
local readyPlayerList = {} 
  
addEvent("clientReady", true ) 
addEventHandler("clientReady",resourceRoot, 
function() 
    table.insert( readyPlayerList, client ) 
end 
) 
  
  
function YourFunction() 
    for i, v in pairs (readyPlayerList) do 
  
    -- your code here 
    -- Use TriggerClientEvent now to replace the hydra model 
  
    end  
end  
  
  
-- table.removevalue function, in case you don't already have it 
function table.removevalue(t, val) 
    for i,v in ipairs(t) do 
        if v == val then 
            table.remove(t, i) 
            return i 
        end 
    end 
    return false 
end 

Or use "onPlayerLogin"

Link to comment

I tried this, but doesn't work. It doesn't spawn any hydra even.

server.lua

addEvent("clientReady", true) 
addEventHandler("clientReady",resourceRoot, 
function() 
    table.insert( readyPlayerList, client ) 
end 
) 
  
function theHydra() 
for i, v in pairs (readyPlayerList) do 
local team = getPlayerTeam(source) 
if team and getTeamFromName("Warriors") then 
triggerClientEvent(player, "replacemodel", player) 
end 
local money = getPlayerMoney(source) 
if not (money > 24999) then 
return outputChatBox("You don't have enough money to afford this vehicle!", source, 255, 0, 0) 
end 
takePlayerMoney(source, 25000) 
local x, y, z = getElementPosition(source) 
local veh = createVehicle(520, x, y, z) 
outputChatBox("You purchased #ffffffHydra!", source, 0, 355, 0, true) 
warpPedIntoVehicle(source, veh) 
player = source 
triggerClientEvent(player, "replacemodel", player) 
end 
end 
addEventHandler("Hydra", root, theHydra) 

client.lua

addEvent("replacemodel", true) 
addEventHandler("replacemodel", root, 
function() 
txd = engineLoadTXD ( "hydra.txd" ) 
engineImportTXD ( txd, 587 ) 
dff = engineLoadDFF ( "hydra.dff", 0 ) 
engineReplaceModel ( dff, 587 ) 
end 
) 
  
addEventHandler("onClientResourceStart",resourceRoot, 
function() 
    triggerServerEvent( "clientReady", resourceRoot ) 
end 
) 

Link to comment

I replaced every source with v, and then:

lua 15 : bad argument #1 to 'pairs' table expected got nil.

addEvent("clientReady", true) 
addEventHandler("clientReady",resourceRoot, 
function() 
    table.insert( readyPlayerList, client ) 
end 
) 
  
function theHydra() 
for i, v in pairs (readyPlayerList) do 
local team = getPlayerTeam(v) 
if team and getTeamFromName("Warriors") then 
triggerClientEvent(v, "replacemodel", v) 
end 
local money = getPlayerMoney(v) 
if not (money > 24999) then 
return outputChatBox("You don't have enough money to afford this vehicle!", v, 255, 0, 0) 
end 
takePlayerMoney(v, 25000) 
local x, y, z = getElementPosition(v) 
local veh = createVehicle(520, x, y, z) 
outputChatBox("You purchased #ffffffHydra!", v, 0, 355, 0, true) 
warpPedIntoVehicle(v, veh) 
triggerClientEvent(v, "replacemodel", v) 
end 
end 
addEventHandler("Hydra", root, theHydra) 

Link to comment

:o where is the table

local readyPlayerList = {} 

-- Client side

  
addEventHandler("onClientResourceStart",resourceRoot, 
function() 
    triggerServerEvent( "clientReady", resourceRoot ) 
end 
) 
  
addEvent("replacemodel", true) 
addEventHandler("replacemodel", resourceRoot, 
function() 
    txd = engineLoadTXD ( "hydra.txd" ) 
    engineImportTXD ( txd, 587 ) 
    dff = engineLoadDFF ( "hydra.dff", 0 ) 
    engineReplaceModel ( dff, 587 ) 
end 
) 
  

-- Server side

local readyPlayerList = {} 
  
addEvent("clientReady", true ) 
addEventHandler("clientReady",resourceRoot, 
function() 
    table.insert( readyPlayerList, client ) 
    theHydra() 
end 
) 
  
function theHydra() 
    for i, v in pairs (readyPlayerList) do  
        if getTeamFromName(getPlayerTeam(v)) == "Warriors" then 
            local money = getPlayerMoney(v) 
                if (money > 24999) then 
                takePlayerMoney(v, 25000) 
                triggerClientEvent(v, "replacemodel",resourceRoot) 
                local x, y, z = getElementPosition(v) 
                local veh = createVehicle(520, x, y, z) 
                warpPedIntoVehicle(v, veh) 
            end  
        end 
    end 
end 
  
-- table.removevalue function, in case you don't already have it 
function table.removevalue(t, val) 
    for i,v in ipairs(t) do 
        if v == val then 
            table.remove(t, i) 
            return i 
        end 
    end 
    return false 
end 

Link to comment
Still doesn't work and gives everybody hydra on start.

It should work

addEventHandler("onClientResourceStart",resourceRoot, 
function() 
    triggerServerEvent( "clientReady", resourceRoot ) 
end 
) 
  
addEvent("replacemodel", true) 
addEventHandler("replacemodel", root, 
function() 
    txd = engineLoadTXD ( "hydra.txd" ) 
    engineImportTXD ( txd, 587 ) 
    dff = engineLoadDFF ( "hydra.dff", 0 ) 
    engineReplaceModel ( dff, 587 ) 
end 
) 

-- Server side

local readyPlayerList = {} 
  
addEvent("clientReady", true ) 
addEventHandler("clientReady",resourceRoot, 
function() 
    table.insert( readyPlayerList, client ) 
    theHydra() 
end 
) 
  
function theHydra() 
    for i, v in pairs (readyPlayerList) do 
        if getTeamName(getPlayerTeam(v)) == "Warriors" then 
            local money = getPlayerMoney(v) 
                if (money > 24999) then 
                takePlayerMoney(v, 25000) 
                triggerClientEvent(v, "replacemodel",v) 
                local x, y, z = getElementPosition(v) 
                local veh = createVehicle(520, x, y, z) 
                warpPedIntoVehicle(v, veh) 
            end 
        end 
    end 
end 
  
-- table.removevalue function, in case you don't already have it 
function table.removevalue(t, val) 
    for i,v in ipairs(t) do 
        if v == val then 
            table.remove(t, i) 
            return i 
        end 
    end 
    return false 
end 

Link to comment
Gives an hydra on start, doesn't work when we press buy hydra, and doesn't even replace hydra model.

What are you talking about there is no GUI in my code only Gives hydra on start.

Next time post full code with Gui.

I dont wanna share it so I pmed you it.

Link to comment
Is it possible that one modded hydra model will spawn for a specific team only? Otherwise, if player isnt in that specific team it will spawn the default hydra?

Can someone put an example?

function replaceModel() 
local team = getPlayerTeam(source) 
if team and getTeamFromName("Warriors") then 
--engine replace thingy-- 
else 
return false 
end 
end 
addEventHandler("onClientResourceStart", root, replaceModel) 

Should it be like this? Please help.

OMG Bilal this its not cloning no,noo. ITs just copying goam and stealing his ideas :P

Link to comment
Is it possible that one modded hydra model will spawn for a specific team only? Otherwise, if player isnt in that specific team it will spawn the default hydra?

Can someone put an example?

function replaceModel() 
local team = getPlayerTeam(source) 
if team and getTeamFromName("Warriors") then 
--engine replace thingy-- 
else 
return false 
end 
end 
addEventHandler("onClientResourceStart", root, replaceModel) 

Should it be like this? Please help.

OMG Bilal this its not cloning no,noo. ITs just copying goam and stealing his ideas :P

Says the guy who named his server 'Blueroam'

Link to comment

Anyways, it wasn't working, so most probably reason for that we were unable to get player's team properly.

This is how it has to be done, to get player's team. This was my 8th experiment.

local team = getPlayerTeam(source) 
local warriors = getTeamFromName("Warriors") 
if (team == warriors) then 
--bla bla-- 

Link to comment
  • 1 year later...
  1. addEventHandler("onClientResourceStart",resourceRoot,
  2. function()
  3.     triggerServerEvent( "clientReady", resourceRoot )
  4. end
  5. )
  6.  
  7. addEvent("replacemodel", true)
  8. addEventHandler("replacemodel", root,
  9. function()
  10.     txd = engineLoadTXD ( "hydra.txd" )
  11.     engineImportTXD ( txd, 520 )  It's should be 520, becuse  520=Hydra 
  12.     dff = engineLoadDFF ( "hydra.dff", 520 )
  13.     engineReplaceModel ( dff, 520 )
  14. end
  15.  
  16. local readyPlayerList = {}
  17.  
  18. addEvent("clientReady", true )
  19. addEventHandler("clientReady",resourceRoot,
  20. function()
  21.     table.insert( readyPlayerList, client )
  22.     theHydra()
  23. end
  24. )
  25.  
  26. function theHydra()
  27.     for i, v in pairs (readyPlayerList) do
  28.         if getTeamName(getPlayerTeam(v)) == "Warriors" then
  29.             local money = getPlayerMoney(v)
  30.                 if (money > 24999) then
  31.                 takePlayerMoney(v, 25000)
  32.                 triggerClientEvent(v, "replacemodel",v)
  33.                 local x, y, z = getElementPosition(v)
  34.                 local veh = createVehicle(520, x, y, z)
  35.                 warpPedIntoVehicle(v, veh)
  36.             end
  37.         end
  38.     end
  39. end
  40.  
  41. -- table.removevalue function, in case you don't already have it
  42. function table.removevalue(t, val)
  43.     for i,v in ipairs(t) do
  44.         if v == val then
  45.             table.remove(t, i)
  46.             return i
  47.         end
  48.     end
  49.     return false
  50. end
Link to comment
1 hour ago, Mohameddz said:
  1. addEventHandler("onClientResourceStart",resourceRoot,
  2. function()
  3.     triggerServerEvent( "clientReady", resourceRoot )
  4. end
  5. )
  6.  
  7. addEvent("replacemodel", true)
  8. addEventHandler("replacemodel", root,
  9. function()
  10.     txd = engineLoadTXD ( "hydra.txd" )
  11.     engineImportTXD ( txd, 520 )  It's should be 520, becuse  520=Hydra 
  12.     dff = engineLoadDFF ( "hydra.dff", 520 )
  13.     engineReplaceModel ( dff, 520 )
  14. end
  15.  
  16. local readyPlayerList = {}
  17.  
  18. addEvent("clientReady", true )
  19. addEventHandler("clientReady",resourceRoot,
  20. function()
  21.     table.insert( readyPlayerList, client )
  22.     theHydra()
  23. end
  24. )
  25.  
  26. function theHydra()
  27.     for i, v in pairs (readyPlayerList) do
  28.         if getTeamName(getPlayerTeam(v)) == "Warriors" then
  29.             local money = getPlayerMoney(v)
  30.                 if (money > 24999) then
  31.                 takePlayerMoney(v, 25000)
  32.                 triggerClientEvent(v, "replacemodel",v)
  33.                 local x, y, z = getElementPosition(v)
  34.                 local veh = createVehicle(520, x, y, z)
  35.                 warpPedIntoVehicle(v, veh)
  36.             end
  37.         end
  38.     end
  39. end
  40.  
  41. -- table.removevalue function, in case you don't already have it
  42. function table.removevalue(t, val)
  43.     for i,v in ipairs(t) do
  44.         if v == val then
  45.             table.remove(t, i)
  46.             return i
  47.         end
  48.     end
  49.     return false
  50. end

can people see that model? i mean can there be 2 hydra models?

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