• SWEP has a strange delay that wasnt set.
    11 replies, posted
My SWEP will not even recognize left and right click for some time (About 10 seconds) after each time it is pulled out. I also have to edit the lua and re-upload it every time i want to use this weapon.
ahem, uh the code would be helpful.
-Snip- Also I didnt /just/ add the DMCA thing. That has always been there. I just removed it for FP.
I couldn't help but notice that there isn't a custom SWEP:Deploy function in there; have you tried finding out if its an issue with SetNextPrimaryFire? Perhaps you can just make it set it to the current time on deploy just to see what happens
For a simple SWEP, I wouldn't worry so much. Now, if you wrote a new net wrapper system and a bunch of other code, and it got stolen by your dedicated server host with them replacing your copyrights and all, as they did with me ( "Friend" allowed me to use his dedicated server for testing purposes of my code; he took audio, new net system, models and more; edited my copyright; taunts me in my own code and has been harassing me, cyber bullying me and spamming all of my friends whereby I need to defend myself every day to my friends because of his smear campaign ) then you have something to worry about. But, what you'd want to do it on SWEP:Deploy( ) reset the timers for when they can attack next. Later on, you may want want to set a draw sequence, get the current sequence, the sequence duration, and base the time off that. So the weapon becomes read to fire/use as soon as the draw animation is done playing. [lua]function SWEP:Deploy() self:SetNextPrimaryFire( CurTime() + 0.5 ) self:SetNextSecondaryFire( CurTime() + 0.5 ) end[/lua]
That did not fix the problem. This issue happens on both Primary and Secondary fire. Also I still need to open and resave the Lua file for the weapon to be spawnable.
I just tested the code. I put a 10 second delay on mine, and it delayed the weapon from working for 10 seconds. I reduced it to the sequence delay as I had it, and it works as soon as the weapon has been fully drawn. Edit: Did you alter your TTT weapon base? If you're calling the SetPrimary/Secondary somewhere else, you could wrap that code in Deploy( ) with a timer.Simple to ensure it's being set after other code is executing. Poor way to do it but at least if you have something changing it where it shouldn't this will be called next. [lua]function SWEP:Deploy() timer.Simple( 0.5, function( ) self:SetNextPrimaryFire( CurTime() ) self:SetNextSecondaryFire( CurTime() ) end ) end[/lua]
-snip- I just changed stuff anyway.
Your secondary delay is 10. Your primary relies on secondary being used first, right, although you do have a primary mag size? Also, I'd recommend avoiding == for comparing numbers that sway. There was an exploit in a plane that did that and the entire entertainment system could crash by getting to 254, then gaining 2 points because it checked for == 255 and because it didn't use a math.Clamp to ensure the INT type could not be overflowed.. So for Clip1, use > 0 CAN DO or < 1 CAN'T DO Try the timer.
I checked everything you said and it still doesnt work. Also I still have to reload (Load and save for it to reload on the server) the script or else it doesnt work.
I'm loading it up on my dev server, let me see if I can replicate the issues. Edit: I didn't have my TTT running in so long I didn't set all the debug vars in time so it changed map on me twice while still loading. Finally looked at it and after 5 minutes I have this: -Lua snipped per OP request...- Here's what was done for others having this issue: Fixed the delay: SWEP.DeploySpeed was missing, IsFirstTimePredicated( ) was missing from PrimaryAttack and SeconaryAttack, CanPrimary/Secondary calls missing in both attack functions, Don't need the deploy code because of the DeploySpeed not being set-up, it was taking the longest delay time, beautified what I touched.
Thanks so much!
Sorry, you need to Log In to post a reply to this thread.