Very frustrated.. DListView player list into variable
6 replies, posted
Ignore the title, that's a problem from earlier. Not letting me change it for some reaosn.
Hey - I have a big file of code with a big bug. It's too much for a FP thread, so I really need someone's help via Steam. Please let me know if you are experienced and can help me fix this bug.
Sorry if this isn't the right place, but I don't have any friends who know lua and I've been working on this one bug frustrated for over 2 hours now.
Post the error? Or at least give some idea of what's going on. Nobody's going to message you for this vague "big bug".
I guess so, lol. I have this inside another hook:
[CODE]hook.Add( 'PlayerDeath', 'playerdeathinDuel', function( ply, wep, killer )
if ply:GetNWBool( "isCurDueling" ) == true then
for k,v in pairs(player.GetAll()) do
v:ChatPrint( "The duel has ended." )
if v:GetNWBool( "isCurDueling" ) == true then
v:SetPos( v:GetNWVector( "b4DuelPlace" ) )
v:addMoney( curWager )
if ply:Nick() != v:Nick() then
local victorrr = v:Nick()
end
duelAvailable = true
duelAvailableText = "available"
if ply:canAfford( -curWager*2 ) then
ply:addMoney( -curWager*2 )
else
ply:setSelfDarkRPVar( "money", 0 )
end
end
v:ChatPrint( victorrr.." has just defeated "..ply:Nick().." in a duel!" )
v:SetNWBool( "isCurDueling", false )
end
dueler1:SetNWBool( "isCurDueling", false )
dueler2:SetNWBool( "isCurDueling", false )
end
end )[/CODE]
However, it's really buggy. Nothing happens after "The duel has ended", and even that only shows up for one person and I'm not sure which.
1) You don't need to compare things to true. You can just do if (ply:GetNWBool()) then .. end
2) You're defining victorrr inside of a statement, so you can't access it outside of your if statement. Set local victorrr before your for loop. Then, set it in your check, and what are dueler1 and dueler2?
3) setSelfDarkRPVar this isn't a thing.
4) The following should be inside the if statement.
v:ChatPrint( victorrr.." has just defeated "..ply:Nick().." in a duel!" )
v:SetNWBool( "isCurDueling", false )
5) AT the end of the if statement inside the loop, break it so it doesn't keep going. Since there's only one other option. Also, right after you initialize your loop, do if (ply == v) then continue end, so it doesn't run against itself.
Thats all I can tell from your code right now. Fix those and I'll take another look. Also, you need give us as much info as you can, including errors.
No errors. Just bugging out.
setSelfDarkRPVar is a thing, I used it before this bugged out and it worked fine.
[url]http://wiki.darkrp.com/index.php/Functions/Player/Server/setSelfDarkRPVar[/url]
What do you mean by break it? And, I want v to include ply, because it should set their position back as they die. Players drop money when they die, and I don't want the location they are teleported to to be flooded with packets of it.
dueler1 and dueler2 are the two players whose NWBool( "isCurDueling" ) are true.
Thanks for helping out, as you can tell I'm fairly new to lua and would be completely lost on my own :)
I thought setSelfDarkRPVar was a mistype.
Basically, and the end of your statement in your loop you put "break" to stop looping through the players.
With you wanting to include the player in your loop, don't do that. It will run the code on both them. Just set the location outside of the loop.
Alright that does sound better. Why would I be using continue instead of return though? Continue isn't changing color in Notepad++ which is worrying me, lol.
So the break will make it stop looping once it's found a v who IsCurDueling? Wouldn't I put it in the if statement then?
Sorry if my questions are dumb, I went in way over my head for this script
Edit: I did what you said and its tons less buggy! Thanks! However, only the Victor seems to be getting the duel ended message.
[editline]17th July 2015[/editline]
Uh oh.. The add-on isn't loading up at all now edit: the break broke that. Should be fine without it though
Sorry, you need to Log In to post a reply to this thread.