Bilal135 Posted May 23, 2015 Share Posted May 23, 2015 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
Mr.unpredictable. Posted May 23, 2015 Share Posted May 23, 2015 Yea it is possible i will show an example when i'm on my pc. Link to comment
Walid Posted May 23, 2015 Share Posted May 23, 2015 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. Link to comment
Bilal135 Posted May 23, 2015 Author Share Posted May 23, 2015 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
Walid Posted May 23, 2015 Share Posted May 23, 2015 -- 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
Bilal135 Posted May 23, 2015 Author Share Posted May 23, 2015 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
Walid Posted May 23, 2015 Share Posted May 23, 2015 Cmon man it's table ,replace source with v Link to comment
Bilal135 Posted May 23, 2015 Author Share Posted May 23, 2015 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
Walid Posted May 23, 2015 Share Posted May 23, 2015 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
Walid Posted May 23, 2015 Share Posted May 23, 2015 Doesn't work. replace getTeamFromName with getTeamName Link to comment
Bilal135 Posted May 23, 2015 Author Share Posted May 23, 2015 Still doesn't work and gives everybody hydra on start. Link to comment
Walid Posted May 23, 2015 Share Posted May 23, 2015 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
Bilal135 Posted May 23, 2015 Author Share Posted May 23, 2015 Gives an hydra on start, doesn't work when we press buy hydra, and doesn't even replace hydra model. Link to comment
Walid Posted May 23, 2015 Share Posted May 23, 2015 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. Link to comment
Bilal135 Posted May 23, 2015 Author Share Posted May 23, 2015 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
-Doc- Posted May 25, 2015 Share Posted May 25, 2015 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 Link to comment
SunArrow Posted May 25, 2015 Share Posted May 25, 2015 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 Says the guy who named his server 'Blueroam' Link to comment
Bilal135 Posted May 25, 2015 Author Share Posted May 25, 2015 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
Mohameddz Posted May 2, 2017 Share Posted May 2, 2017 addEventHandler("onClientResourceStart",resourceRoot, function() triggerServerEvent( "clientReady", resourceRoot ) end ) addEvent("replacemodel", true) addEventHandler("replacemodel", root, function() txd = engineLoadTXD ( "hydra.txd" ) engineImportTXD ( txd, 520 ) It's should be 520, becuse 520=Hydra dff = engineLoadDFF ( "hydra.dff", 520 ) engineReplaceModel ( dff, 520 ) end ) 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
Avagard Posted May 2, 2017 Share Posted May 2, 2017 1 hour ago, Mohameddz said: addEventHandler("onClientResourceStart",resourceRoot, function() triggerServerEvent( "clientReady", resourceRoot ) end ) addEvent("replacemodel", true) addEventHandler("replacemodel", root, function() txd = engineLoadTXD ( "hydra.txd" ) engineImportTXD ( txd, 520 ) It's should be 520, becuse 520=Hydra dff = engineLoadDFF ( "hydra.dff", 520 ) engineReplaceModel ( dff, 520 ) end ) 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 can people see that model? i mean can there be 2 hydra models? Link to comment
NeXuS™ Posted May 2, 2017 Share Posted May 2, 2017 You'll have to change the hydra's texture with a shader mate. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now