I have a jailbreak server and am trying to add a script so if a player kills somebody. They get points. Team wins a round, they get point. blah blah. So far I have this but it does't work. Please help and also I have put it in lua/autorun/server/ is that correct?
[CODE]
local amount = 10;
local hasWon = false
hook.Add( "PlayerDeath", "FeedMeMore", function( victim, weapon, killer )
if( IsValid( killer ) and IsValid( victim ) ) then
if( killer:IsPlayer() and victim:IsPlayer() ) then
if ( killer:Team() == TEAM_PRISONER and victim:Team() == TEAM_GUARD ) then
killer:PS_GivePoints( 20 );
killer:PS_Notify("You've been given '20' points for killing a guard!");
end;
end;
end;
end )
hook.Add("RoundEnd", "InComesTheAeroplane", function()
for k,v in pairs (team.GetPlayers(TEAM_PRISONER)) do
if(v:Alive) then
v:PS_GivePoints( 20 );
v:PS_Notify("You've been given '20' points for winning");
hasWon = true
end
end
if(hasWon) then
for k,v in pairs (team.GetPlayers(TEAM_PRISONER)) do
if(not v:Alive) then
v:PS_Notify("You fucking disgrace, your team won, but you died.");
v:PS_GivePoints( 10 );
end
end
end
end)
hook.Add("RoundEnd", "InComesTheAeroplane", function()
for k,v in pairs (team.GetPlayers(TEAM_GUARD)) do
if(v:Alive) then
v:PS_GivePoints( 30 );
v:PS_Notify("You've been given '30' points for winning");
end
end
end)[/CODE]
Ok so are you saying I should change it to something like RoundEnd2
[QUOTE=Moat;51618525]That's not the hook identifier. Take a look at [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/hook/Add]hook.Add[/url] if you're unsure.[/QUOTE]
Ok I see the aeroplane bit. Let me edit and get back to you if it works. Tell me if you notice any other problems
[editline]3rd January 2017[/editline]
Ok new script the prisoner kill works but the round win doesn't. You see anything wrong?
[CODE]local amount = 10;
local hasWon = false
hook.Add( "PlayerDeath", "GuardKiller", function( victim, weapon, killer )
if( IsValid( killer ) and IsValid( victim ) ) then
if( killer:IsPlayer() and victim:IsPlayer() ) then
if ( killer:Team() == TEAM_PRISONER and victim:Team() == TEAM_GUARD ) then
killer:PS_GivePoints( 20 );
killer:PS_Notify("You've been given '20' points for killing a guard!");
end;
end;
end;
end )
hook.Add("RoundEnd", "PrisonersWin", function()
for k,v in pairs (team.GetPlayers(TEAM_PRISONER)) do
if(v:Alive()) then
v:PS_GivePoints( 20 );
v:PS_Notify("You've been given '20' points for winning");
hasWon = true
end
end
if(hasWon) then
for k,v in pairs (team.GetPlayers(TEAM_PRISONER)) do
if(not v:Alive()) then
v:PS_Notify("You fucking disgrace, your team won, but you died.");
v:PS_GivePoints( 10 );
end
end
end
end)
hook.Add("RoundEnd", "GuardsWin", function()
for k,v in pairs (team.GetPlayers(TEAM_GUARD)) do
if(v:Alive()) then
v:PS_GivePoints( 30 );
v:PS_Notify("You've been given '30' points for winning");
end
end
end)[/CODE]
I haven't checked your current issue, but I see a new one.
You see your "hasWon" Variable. You haven't set it to go false again; thus in the later rounds people will inevitably gain 30 points per round this is a simple fix. Inside the if(hasWon) all you have to do is make it false again :)
[QUOTE=QuackDuck;51618773]I haven't checked your current issue, but I see a new one.
You see your "hasWon" Variable. You haven't set it to go false again; thus in the later rounds people will inevitably gain 30 points per round this is a simple fix. Inside the if(hasWon) all you have to do is make it false again :)[/QUOTE]
thanks, I won't be able to check until the problem is fixed but still thank you
Ok so I found out in the hook RoundEnd is no longer a thing on gmod wiki so i asume it is not a thing at all. Anyone know what it actually is?
I made a similar thread a few days ago but for TTT. The RoundEnd Hook does exist in my_hat_stinks' jailbreak addon. You'd have to do an if statement to see who won. From what I can see there is END_JAILOR, END_PRISONER and END_TIME. Here's a link to my thread, maybe it'll help with this. [url]https://facepunch.com/showthread.php?t=1547620[/url]
Sorry, you need to Log In to post a reply to this thread.