Xwad Posted February 1, 2016 Share Posted February 1, 2016 Hi! I downloaded this script: This script is only working on dayz mod (becaouse i need to move the item in the vehicles inventory). And i want to make that the minigun will be attached to the vehicle when the player enters the vehicle..I tryed to edit the script (with onCLientVehicleEnter) but it was not working, i just got errors.. So my question is that can you help me please to edit the script? So i want to make that the minigun will be attached when the player enters the vehicle I hope you can help me.. Thanks these are just part of the script (parts where the minigun will be attached) CLIENT.LUA addEventHandler("onClientVehicleExit",getRootElement(),function() triggerServerEvent("sv_destroyWeapon", getRootElement(), getLocalPlayer()) end) addEventHandler("onClientVehicleEnter",getRootElement(),function() triggerServerEvent("sv_createWeapon", getRootElement(), getLocalPlayer()) end) SERVER.LUA addEvent("sv_createWeapon", true) addEventHandler("sv_createWeapon", getRootElement(), function(item, loot, player) if loot then local veh = getElementData(loot,"parent") local x,y,z = getElementPosition(veh) local mid = getElementModel(veh) if weapOff[mid] and item == minigun_name and not getElementData(veh, "weapon2") then local weapon = createObject ( 362, x+weapOff[mid][1],y+weapOff[mid][2],z+weapOff[mid][3]) local weapon_base = createObject ( 336, x+weapOff[mid][1],y+weapOff[mid][2],z) attachElements ( weapon_base, veh, weapOff[mid][1], weapOff[mid][2], weapOff[mid][3], 0, 0, 0) attachElements ( weapon, weapon_base, 0, -0.3, 0.9, weapOff[mid][4], weapOff[mid][5], weapOff[mid][6]) setElementData(veh, "weapon", weapon_base) setElementData(veh, "weapon2", weapon) end end --triggerClientEvent("cl_waitForKey", getRootElement(), veh, weapon, player) end) addEvent("sv_destroyWeapon", true) addEventHandler("sv_destroyWeapon", getRootElement(), function(item, loot, player) local veh = getElementData(loot,"parent") if isElement(veh) and not getElementData(veh,"vehicle") then return end if (getElementData(loot, minigun_name)or 0) <= 0 then if getElementData(veh,"vehicle") then destroyElement(getElementData(veh, "weapon2")) destroyElement(getElementData(veh, "weapon")) setElementData(veh, "weapon", false) setElementData(veh, "weapon2", false) end end end) Link to comment
ViRuZGamiing Posted February 1, 2016 Share Posted February 1, 2016 "i just got errors.." Show them Link to comment
Moderators IIYAMA Posted February 1, 2016 Moderators Share Posted February 1, 2016 Those errors are obvious... You should first ask permission from the owner, because this resource is afaik not on the community. Also you need permission from the owner to show this code to the public. Link to comment
Xwad Posted February 1, 2016 Author Share Posted February 1, 2016 Why need i ask for permissoon if its uploaded to the internet? Link to comment
Moderators IIYAMA Posted February 1, 2016 Moderators Share Posted February 1, 2016 Because it is most likely stolen if it is not on the community... With other words, it is not on the community because he didn't want other people to have it. So... stolen and leaked. If you want to use and edit leaked scripts, enjoy yourself. But don't be so disrespectful with somebody else his code and ask permission first. Link to comment
Bonus Posted February 2, 2016 Share Posted February 2, 2016 1. Why are you using getRootElement(), getLocalPlayer() Why not use the localPlayer as the source of the event? 2. You only trigger the localPlayer in your code. That means you get only 1 argument in your function, the player, not item or loot. You can't just write down "item" and expect it to become an item. If you dont trigger item as an argument you cant use it. Dont even understand what item or loot is. Its like you just copy and paste, don't even think about what you wrote. Try that: addEventHandler("onClientVehicleExit",getRootElement(),function() triggerServerEvent("sv_destroyWeapon", getLocalPlayer(), source) end) addEventHandler("onClientVehicleEnter",getRootElement(),function() triggerServerEvent("sv_createWeapon", getLocalPlayer(), source) end) addEvent("sv_createWeapon", true) addEventHandler("sv_createWeapon", getRootElement(), function( veh ) local x,y,z = getElementPosition(veh) local mid = getElementModel(veh) if weapOff[mid] and not getElementData(veh, "weapon2") then local weapon = createObject ( 362, x+weapOff[mid][1],y+weapOff[mid][2],z+weapOff[mid][3]) local weapon_base = createObject ( 336, x+weapOff[mid][1],y+weapOff[mid][2],z) attachElements ( weapon_base, veh, weapOff[mid][1], weapOff[mid][2], weapOff[mid][3], 0, 0, 0) attachElements ( weapon, weapon_base, 0, -0.3, 0.9, weapOff[mid][4], weapOff[mid][5], weapOff[mid][6]) setElementData(veh, "weapon", weapon_base) setElementData(veh, "weapon2", weapon) end --triggerClientEvent("cl_waitForKey", getRootElement(), veh, weapon, player) end) Not sure if its better to trigger the vehicle or get it serversided with getPedOccupiedVehicle. Don't think there's much difference. 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