Hi guys I have something which I have been interested in looking at. But unfortunately I am not very good at using frags. The wiki isn't the most detailed for explaining how to use these things.
So I am a little lost on where to start with this.
Perhaps someone could help me with this pseudo code I think would work well as a template.
function helpmeplease()
local frags == localplayers:frags <--- I don't know what it is exactly, its just a guess.
if player frags == 1 then
give the player a weapon/. pl:Give("something")
elseif player frags == 4 then
give the player a weapon/. pl:Give("something2")
end
end
If anyone know how to work with frags or could explain to me how I would get this to work then I would be very great full.
Please bare in mind this would have to work for lots of players on a server. They would all have different scores potentially etc.. So it wouldn't only be called once.
Thanks.
Duby
Try something like this;
[code]function give_for_frags(ply)
local frags = ply.Frags
if frags == 1 then
ply:Give("something")
elseif frags == 4 then
ply:Give("something2")
end
end[/code]
When do you want it to run?
Let me see, I'm assuming you want it to run when a player is killed and on the attacker to update their weapons (gun game)
Totally untested and on an ipad but:
[lua]
function weaponGiver( ply )
local frags = ply:Frags()
if (frags == 1) then
ply:Give( "weaponclassname" )
ElseIf (frags == 3) then
ply:Give( "weaponclassname" )
Else
ply:Give( "weaponclassname" )
End
end
function GM:PlayerDeath( victim, inflictor, attacker )
weaponGiver(attacker)
end
function GM:PlayerInitialSpawn( ply )
weaponGiver(ply)
end
[/lua]
[editline]10th July 2014[/editline]
Sigh, already noticed an error. PlayerInitialSpawn should be PlayerSpawn
[editline]10th July 2014[/editline]
[QUOTE=jackwilsdon;45347553]Try something like this;
[code]function give_for_frags(ply)
local frags = ply.Frags
if frags == 1 then
ply:Give("something")
elseif frags == 4 then
ply:Give("something2")
end
end[/code][/QUOTE]
ply is undefined, ply.frags is not a thing and give_for_frags is never called...
[QUOTE=Milkshaker;45347559]When do you want it to run?
Let me see, I'm assuming you want it to run when a player is killed and on the attacker to update their weapons (gun game)
Totally untested and on an ipad but:
[lua]
function weaponGiver( ply )
local frags = ply:Frags()
if (frags == 1) then
ply:Give( "weaponclassname" )
ElseIf (frags == 3) then
ply:Give( "weaponclassname" )
Else
ply:Give( "weaponclassname" )
End
end
function GM:PlayerDeath( victim, inflictor, attacker )
weaponGiver(attacker)
end
function GM:PlayerInitialSpawn( ply )
weaponGiver(ply)
end
[/lua]
[editline]10th July 2014[/editline]
Sigh, already noticed an error. PlayerInitialSpawn should be PlayerSpawn
[editline]10th July 2014[/editline]
ply is undefined, ply.frags is not a thing and give_for_frags is never called...[/QUOTE]
I see, well its meant to be called when the attacker kills someone. Then it checks your frags etc.. The only thing I was wondering about was, will this frag system be global to every player on the server or just one client at a time. If that makes sense.
[QUOTE=Milkshaker;45347559]ply is undefined, ply.frags is not a thing and give_for_frags is never called...[/QUOTE]
First of all, I'm providing OP with a function to be called whenever they want, so ply is defined when calling it as give_for_frags(ply), and yeah, it should be ply:Frags().
[QUOTE=jackwilsdon;45347700]First of all, I'm providing OP with a function to be called whenever they want, so ply is defined when calling it as give_for_frags(ply), and yeah, it should be ply:Frags().[/QUOTE]
Jesus dude, no need to act like a clock about it , simply pointing some stuff out for you to fix.
[editline]10th July 2014[/editline]
[QUOTE=DubyxD;45347616]I see, well its meant to be called when the attacker kills someone. Then it checks your frags etc.. The only thing I was wondering about was, will this frag system be global to every player on the server or just one client at a time. If that makes sense.[/QUOTE]
Yes, it'll be called on anyone who kills someone, and then when they spawn they'll get that gun too (the four kill gun instead of default)'to remove that then delete the player spawn function at the bottom.
[QUOTE=Milkshaker;45347742]Jesus dude, no need to act like a clock about it , simply pointing some stuff out for you to fix.
[editline]10th July 2014[/editline]
Yes, it'll be called on anyone who kills someone, and then when they spawn they'll get that gun too (the four kill gun instead of default)'to remove that then delete the player spawn function at the bottom.[/QUOTE]
Wait so are you saying this will first works when the player has got 3 frags? instead of 1>?
[editline]10th July 2014[/editline]
Oh great ok this works well, thanks Milkshacker!
Sorry, you need to Log In to post a reply to this thread.