Xwad Posted November 18, 2017 Share Posted November 18, 2017 (edited) I found a really interesting bug, and i can not fix it. Well, i created a script that creates and fires a custom wepon when a bind is pressed. It's just working fine, but when i use it on the middle of my map, then the createWeapon function is not working without debugscript. The map contains 1200 Elements. When i reduced the maps objects to ca. 300-400 objects then it worked. I really dont understand why is that happening. Is there any way to make createWepon work beside 1200 elements? Thanks Edited November 18, 2017 by Xwad Link to comment
Moderators IIYAMA Posted November 18, 2017 Moderators Share Posted November 18, 2017 Not sure, maybe you can disable the streamer for it. https://wiki.multitheftauto.com/wiki/SetElementStreamable Check the output of the function to validate if it is actually doing something. Link to comment
Xwad Posted November 18, 2017 Author Share Posted November 18, 2017 (edited) Already tried By the way now i realised that the weapon is created but its not shooting somewhy. I did an outputDebugString and it said: Attempt to concatenate local "gun" (a userdata value) my code client function create_gun() if isPedInVehicle (localPlayer) then local veh = getPedOccupiedVehicle(localPlayer) if getElementModel(veh) == id then fire_gun() end end end bindKey("mouse1", "down", create_gun) function fire_gun() if isPedInVehicle (localPlayer) then if getKeyState( "mouse1" ) == true then local veh = getPedOccupiedVehicle(localPlayer) triggerServerEvent ( "update_gun_s", localPlayer, veh ) setTimer ( fire_gun, 180, 1) end end end function update_gun_c(veh) local x,y,z = getElementPosition (veh) local base = createWeapon("sniper", 0,0,0) local gun = createWeapon("sniper", 0,0,0,0,0,0,0) local sound_gun = playSound3D ( "files/gun.wav", x,y,z, false ) setSoundMaxDistance ( sound_gun, 500 ) setSoundVolume(sound_gun, 1) setElementCollisionsEnabled(gun, false) setElementStreamable ( gun, false ) outputChatBox("1",255,255,255) setWeaponProperty ( gun, "fire_rotation", 0, 0, -5 ) setWeaponProperty ( gun, "weapon_range", 10000 ) setWeaponProperty ( gun, "target_range", 10000 ) setWeaponProperty( gun, "damage", 38) attachElements(base,veh,0,0,0,0,0,95) attachElements(gun,base,1.18, 0.24, 0.2, 0, 0, 0) attachElements(sound_gun,gun,0,0,0) fireWeapon(gun) destroyElement(base) destroyElement(gun) end addEvent( "update_gun_c", true ) addEventHandler( "update_gun_c", localPlayer, update_gun_c ) server function update_gun_s(veh) triggerClientEvent ("update_gun_c", getRootElement(), veh) end addEvent("update_gun_s", true) addEventHandler("update_gun_s", root, update_gun_s) Edited November 18, 2017 by Xwad Link to comment
Moderators IIYAMA Posted November 18, 2017 Moderators Share Posted November 18, 2017 (edited) I am well aware that attaching custom weapons are a bit buggy outside of the gta boundary. You have to drive/move the vehicle in order to attach them correctly. A small velocity push to the vehicle might do the trick. About that code. You are creating and destroy the weapons at the same time. Shouldn't you wait for the next frame? Also you might want to create the weapon near the player. With an offset of ~0, 0, 40. Edited November 18, 2017 by IIYAMA Link to comment
Xwad Posted November 18, 2017 Author Share Posted November 18, 2017 yes but it's perfectly working when i stop the map Link to comment
Moderators IIYAMA Posted November 18, 2017 Moderators Share Posted November 18, 2017 One of the possibility is that it takes longer to load the model, when there are a lot of objects around. Which means it takes more time to create and stream it in. So try to give it some time. Link to comment
Xwad Posted November 18, 2017 Author Share Posted November 18, 2017 (edited) Still not working. Any idea?? Edited November 18, 2017 by Xwad 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