- 
                Posts1,090
- 
                Joined
- 
                Last visited
Everything posted by Xwad
- 
	I have always problems with argumentums.. Please can you make me an example? argumentums are very difficult for me.
- 
	Hi! I have a problem with setPedAnimation. Theres a bind in my script, and if a player press the bind then he will start doing this animation: setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) server side The animation is working correctly but the problem is that if a player dies and goes back to the player who is doing the animation then he will see nothing, no animation (just standing). I mean if forexample player1 is starting the animation then player2 will see the animation (what the player1 is doing) but if player2 dies and goes back to player1 then he wont see the animation anymore (he will just see standing).. BUT if i use this code then its working 100% setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1 ) but this animation is not what i want
- 
	Hi community! Im working on a vehicle machinegun script. I have a big problem. In my script i create a minigun object and attach it to a vehicle, and i add a bindkey which will attach the player to the minigun.. So, the problem is the attaching. When the player is attached to the minigun then the player is very oblique.. I tryed using setElementRotation but it didnt help me..So i wanna ask is that possible? to rotate the attached player (attached to the object). So here are 2 pictures about the issues. I hope you can help:) Thanks. Open the picture in a new side to see the full picture So here is the part where i create the object and attach the player to the object function attach(veh) setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) attachElements ( source, weapon, 0, 0.16, 0.35, 0, 0, 90 ) setElementCollisionsEnabled ( source, false ) toggleControl (source,"fire", false) end addEvent("attachPlayerToMinigun", true) addEventHandler("attachPlayerToMinigun",getRootElement(), attach) function createVehicleMachinegun (veh) local x,y,z = getElementPosition(veh) local mid = getElementModel(veh) if weapOff[mid] then weapon = createObject ( 362, x+weapOff[mid][1],y+weapOff[mid][2],z+weapOff[mid][3]) 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.20, -0.3, 0.77, weapOff[mid][4], weapOff[mid][5], weapOff[mid][6]) setElementData(veh, "weapon", weapon_base) setElementData(veh, "weapon2", weapon) setElementData(veh, "playerOnWeapon", nil) outputChatBox ( "Machinegun attached!" ) end end addEvent( "create", true ) addEventHandler( "create", root, createVehicleMachinegun )
- 
	can i also rotate player with setElementAttachedOffsets? becaouse i tryed it and its not working with player only with objects function attach() setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) attachElements ( source, weapon, 0, 0.06, 0, 10, 20, 30 ) toggleControl (source,"fire", false) local x, y, z, xr, yr, yz = getElementAttachedOffsets(source) setElementAttachedOffsets(source, 3, 4, 4, 25, 50, 30) <-- look here. The player rotation is not changing.. end addEvent("attachPlayerToMinigun", true) addEventHandler("attachPlayerToMinigun",getRootElement(), attach)
- 
	One more question. I attached the player to the weapon object. Its working but i cant rotate the player when i attach it to the object..i mean not rotating after attaching, i mean rotating while attaching..So i wanna attach it to a given rx,rz,ry.. Pls help! function attach() setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) attachElements ( source, weapon, 0, 0.06, 0, 10, 20, 30 ) --<---- look here i added the x,y,z,rx,rz,ry but only the x,y,z is working. the rotation is not working.. When the player is attaching to the object then the player does not rotate setElementCollisionsEnabled ( source, false ) setElementData ( source, "attachedToWeapon_v", veh ) setElementData ( source, "currentCol", nil ) setElementData ( source, "attachedToWeapon_w", weap ) setElementData ( veh, "playerOnWeapon", source ) toggleControl (source,"fire", false) end addEvent("attachPlayerToMinigun", true) addEventHandler("attachPlayerToMinigun",getRootElement(), attach)
- 
	Thanks
- 
	I already did that. function onHit() local x,y,z getElementPosition(localPlayer) if not isPedInVehicle(localPlayer) then guiSetVisible(text3, true) end end addEventHandler( "onClientColShapeHit", col, onHit ) function onLeave() guiSetVisible(text3, false) guiSetVisible(text4, false) end addEventHandler( "onClientColShapeLeave", col, onLeave ) I still have the same problem
- 
	listen. My script: when a player enters a patriot vehicle and press "r" then a minigun will attached to the vehicle. And if the player exit the vehicle and goes to the minigun and press h then he will be attached to the minigun. And the colshape is becaouse the minigun (the player will only be attached when he is inside the col). and "IF NOT IN A VEHICLE" is for that player cant enter the minigun if he is in the vehicle.
- 
	Okay:D i cahnged source to client but its the same debugscript this is the client side. When the player is inside the colshapa and press h then the event will be triggered client.lua function getIntoMacineGun () local x,y,z getElementPosition(localPlayer) if isElementWithinColShape(localPlayer, col) and not isPedInVehicle(localPlayer) then triggerServerEvent ( "attachPlayerToMinigun", localPlayer, veh) setElementData (localPlayer,"attachedToWeapon",true) outputChatBox ( "test" ) end end bindKey ( "h", "down", getIntoMacineGun)
- 
	cool now i understand it and its working! thanks:D But as always when i solve a problem then a new problem appears.. So i have a problem again with an argumentum.. So when i press h and the script triggers the server event then the server side script has a bad argumentum and its not working.. debugscript 3: Bad Argumentum @ 'getElementModel' [Expected element at argumentum 1,got nil] (line 11) weapOff = {} weapOff[422] = {-0.1, -1.9, -0.2, 0, 30, 60} weapOff[470] = {-0.1, 0.1, 1.0, 0, 30, 95} addEvent("attachPlayerToMinigun", true) addEventHandler("attachPlayerToMinigun",getRootElement(),function(veh) local mid = getElementModel ( veh ) if weapOff[mid] then local weap = getElementData ( veh, "weapon" ) setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) attachElements ( source, weap, -0.2, -0.5, 1, 0, 0, 90) setElementCollisionsEnabled ( source, false ) setElementData ( source, "attachedToWeapon_v", veh ) setElementData ( source, "currentCol", nil ) setElementData ( source, "attachedToWeapon_w", weap ) setElementData ( veh, "playerOnWeapon", source ) toggleControl (source,"fire", false) end end)
- 
	i didnt really understand it but ok i had read it again. So. i dont need it like this. I only want to attach the minigun in the vehicle, and not to bind. I want to make that if i press h then it will check that there is an elemnt minigun. if yes then it will trigger the server event and if theres no elemnt on the vehicle then not. and i dont know now that what argumentums i need to use.. Im confused
- 
	yes i had read it but i dont have problem with bind, the function is starting when i press h, the problem is with the getElementhModel debug
- 
	same debug, not working:/ function getIntoMacineGun ( key, keystate ) local weapon = getElementData ( veh, "weapon" ) if isElement ( weapon ) then if not isPedInVehicle(localPlayer) then triggerServerEvent ( "attachPlayerToMinigun", localPlayer, veh) setElementData (localPlayer,"attachedToWeapon",true) end end end bindKey ( "h", "down", getIntoMacineGun)
- 
	I have a problem again with getElementModel.. I want to make that when i press h then i will be attached to the minigun but its not triggering to server side when i press h and the debugscript 3 says: Bad Argumentum @ 'getElementData' [Expected element argumentum at argumentum 1, got tring 'h'] client function getIntoMacineGun (veh) local weapon = getElementData ( veh, "weapon" ) if isElement ( weapon ) then if not isPedInVehicle(localPlayer) then triggerServerEvent ( "attachPlayerToMinigun", localPlayer, veh) setElementData (localPlayer,"attachedToWeapon",true) end end end bindKey ( "h", "down", getIntoMacineGun) server addEvent("attachPlayerToMinigun", true) addEventHandler("attachPlayerToMinigun",getRootElement(),function(veh) local mid = getElementModel ( veh ) if weapOff[mid] then local weap = getElementData ( veh, "weapon" ) setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) attachElements ( source, weap, -0.2, -0.5, 1, 0, 0, 90) setElementCollisionsEnabled ( source, false ) setElementData ( source, "attachedToWeapon_v", veh ) setElementData ( source, "currentCol", nil ) setElementData ( source, "attachedToWeapon_w", weap ) setElementData ( veh, "playerOnWeapon", source ) toggleControl (source,"fire", false) end end)
- 
	ohh ok:D now its working thx!
- 
	One more question. I want to make that when the minigun is already attached when i enter the vehicle, then when i press r it will be detached else it will attach it. The problem is that when i enter the vehicle then its not get the element data and will attach when i press r debugscript3: Bad Argumentum @ 'getElementData' [Expected element argumentum at argumentum 1, got nil] Client function onVehicleEnter(theElement) if isElement ( getElementData ( veh, "weapon" ) ) then guiSetVisible(text2, true) bindKey ( "r", "down", bind_d ) else guiSetVisible(text, true) bindKey ( "r", "down", bind_c ) end end addEventHandler ( "onClientPlayerVehicleEnter", getRootElement(), onVehicleEnter ) function bind_c() local veh = getPedOccupiedVehicle( localPlayer ) if veh then guiSetVisible(text, false) guiSetVisible(text2, true) unbindKey ( "r", "down", bind_c ) bindKey ( "r", "down", bind_d ) triggerServerEvent ( "create", resourceRoot, veh ) end end function bind_d() local veh = getPedOccupiedVehicle( localPlayer ) if veh then guiSetVisible(text, true) guiSetVisible(text2, false) unbindKey ( "r", "down", bind_d ) bindKey ( "r", "down", bind_c ) triggerServerEvent ( "destroy", resourceRoot, veh ) end end server weapOff = {} weapOff[422] = {-0.1, -1.9, -0.2, 0, 30, 60} weapOff[470] = {-0.1, 0.1, 1.0, 0, 30, 95} function createVehicleMachinegun (veh) local x,y,z = getElementPosition(veh) local mid = getElementModel(veh) if weapOff[mid] 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.14, -0.3, 0.9, weapOff[mid][4], weapOff[mid][5], weapOff[mid][6]) setElementData(veh, "weapon", weapon_base) setElementData(veh, "weapon2", weapon) setElementData(veh, "playerOnWeapon", nil) outputChatBox ( "Machinegun attached!" ) end end addEvent( "create", true ) addEventHandler( "create", root, createVehicleMachinegun ) function destroyVehicleMachinegun (veh) destroyElement(getElementData(veh, "weapon2")) destroyElement(getElementData(veh, "weapon")) setElementData(veh, "weapon", false) setElementData(veh, "weapon2", false) outputChatBox ( "Machinegun detached!" ) end addEvent( "destroy", true ) addEventHandler( "destroy", root, destroyVehicleMachinegun )
- 
	Working !! Thanks guys!!
- 
	Hi i made this script but its not working:/ if i press r in the vehicle then it will trigger a server event and attach an object , but its not working:( If i add onPlayerVehicleEnter event in server side then its working:/ so when i press r then thevdebugscript 3 says: Bad Argumentum @ 'getElementPosition' [Expected element at argument 1,got nil] Bad Argumentum @ 'getElementModel' [Expected element at argument 1,got nil] client function onVehicleEnter() bindKey ( "r", "down", bind_c ) end addEventHandler ( "onClientPlayerVehicleEnter", getRootElement(), onVehicleEnter ) function bind_c() triggerServerEvent ( "create", resourceRoot ) end server weapOff = {} weapOff[422] = {-0.1, -1.9, -0.2, 0, 30, 60} weapOff[470] = {-0.1, 0.1, 1.0, 0, 30, 60} function createVehicleMachinegun (veh, thePlayer) local x,y,z = getElementPosition(veh) local mid = getElementModel(veh) if weapOff[mid] 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) setElementData(veh, "playerOnWeapon", nil) outputChatBox ( "Machinegun attached!" ) end end addEvent( "create", true ) addEventHandler( "create", root, createVehicleMachinegun )
- 
	Why need i ask for permissoon if its uploaded to the internet?
- 
	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)
- 
	i tried to rotate it but its not working:/ Whats the problem? -- Offsets local x,y,z,rx,ry,rz= 0,0.2,1.5,0,0,90 function createArmedBobcat(cmd, commandName) local lx, ly, lz = getElementPosition(localPlayer) -- get the position of the player lx = lx + 5 -- add 5 units to the x position base = createWeapon("m4", x, y, z) veh = createVehicle( 470, lx, ly, lz) -- create a bobcat setElementCollisionsEnabled ( base, false ) -- the minigun_base damages the car -- you could alternatively load an empty col file for the minigun object attachElements ( base, veh, x,y,z,rx,ry,rz) -- attach the base to the bobcat end function rotateIt(cmd, addZ) if(addZ) then local x, y, z, rx, ry, rz = getElementAttachedOffsets (base) -- get the offsets rz = rz + addZ setElementAttachedOffsets (base, x, y, z, rx+10, ry, rz+5) -- update offsets end end addCommandHandler("car", createArmedBobcat) addCommandHandler("rotate", rotateIt)
- 
	Hi i made a script where i attach an m4 gun to a car. Its working ,the only problem is that i cant rotate the weapon when its attached to the vehicle:/ Maybe the setElementRotation is not good for that? function attach(theElement) local x,y,z = getElementPosition ( vehicle ) local x,y,z = getElementPosition(localPlayer) local vehicle = getPedOccupiedVehicle (localPlayer) local rotX, rotY, rotZ = getElementRotation(weapon) if vehicle then weapon = createWeapon("m4", x, y, z+10) setElementRotation(weapon,rotX,rotY+4,rotZ+43) setWeaponState(weapon, "ready") attachElements ( weapon, vehicle, -0.4, 0.5, 1.5 ) outputChatBox ( "Machinegun attached!" ) end end addEvent( "attach", true ) addEventHandler( "attach", localPlayer, attach )
- 
	Hi now its working! I dont dont how, i didnt do anythink.. Thanks to all answers!
- 
	Hi everybody! I saw this video too and i decided that i will make that script. Im not a beginner in lua so it was not so difficult to make it. Everythink was good when i stuck with the minigun rotation. I used the camera rotation to rotate the minigun element. The only problem is that its not rotating up and down.. only left and right:/ can someone help me? this is a part of my script local test = createWeapon("m4", -2388.41,-581.15, 132.3)setWeaponState(test, "ready") function rotate () setElementRotation(test, 0, 3.2, 96.7 -getPedCameraRotation(localPlayer)) end addEventHandler ("onClientRender", root, rotate) function findRotation( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or tend

 
            
        