Script only works once

So I made a script and the first round of the game it works; it prints to chat to me “tttbeginround test” and then gives me my 200 hp. But the next round it still prints to chat “tttbeginround test” but does not give me my 200 hp. Help?

hook.Add( “TTTBeginRound”, “PointShop_RoundBegin”, function ( )
for k,v in pairs( player.GetAll() ) do
v:PrintMessage( HUD_PRINTTALK, “tttbeginround test” )
timer.Simple( 3, function()
if v:Has_Item( Health25 ) then
v:SetHealth( 125 )
v:Print( “health25” )
if v:Has_Item( Health50 ) then
v:SetHealth( 150 )
v:Print( “health50” )
if v:Has_Item( Health75 ) then
v:SetHealth( 175 )
v:Print( “health75” )
if v:Has_Item( Health100 ) then
v:SetHealth( 200 )
v:Print( “health100” )
if v:Has_Item( Armor25 ) then
v:SetArmor( 25 )
v:Print( “armor25” )
if v:Has_Item( Armor50 ) then
v:SetArmor( 50 )
v:Print( “armor50” )
end )
end )

[editline]15th January 2012[/editline]

Correction. I did some testing and it appears it only works if the player is already dead and has to be respawned.

You really should only post question threads when you’ve tested everything you think you can test. I mean, you literally edited this during the same hour you posted it.

Lol I have tested it all I can, so if you’re not going to help me fix this, you can just not post again…

No but really, the only things I can test is being alive during the round start, being dead during the round start, and the variation of those during different round start types ( the first round start of the map ). And I usually do test it as much as I can before I post but sometimes I continue to test and come up with different results.

It’s gotta suck when you literally write down the solution (or are atleast what’s necessary to get on the coattails of it) and you still think you need help.

You don’t understand what my problem is, do you? When the player is alive when the round starts, they don’t get the upgrade. But when they are dead and get respawned, they spawn with the upgrade…

  1. Then what can you do to fill the requirements of the hook?
  2. What other hooks are available that could be used if you don’t want to use this workaround?

Well, I dont know about the first one so I tried something else:
function plymeta:SpawnForRound(dead_only)
– wrong alive status and not a willing spec who unforced after prep started
– (and will therefore be “alive”)
if dead_only and self:Alive() and (not self:IsSpec()) then
– if the player does not need respawn, make sure he has full health
if self:Has_Item(Health100) then
self:Print( “health100” )
elseif self:Has_Item(Health75) then
self:Print( “health50” )
elseif self:Has_Item(Health50) then
self:Print( “health75” )
elseif self:Has_Item(Health25) then
self:Print( “health25” )
if self:Has_Item(Armor50) then
self:Print( “armor50” )
elseif self:Has_Item(Armor25) then
self:Print( “armor25” )
return false

if not self:ShouldSpawn() then return false end

– respawn anyone else
if self:Team() == TEAM_SPEC then


– tell caller that we spawned
return true

But for some reason when I add this code instead of the original it messes it up and won’t set the player to innocent/detective/traitor and just keeps saying Preparing…

you should print(v:Has_Item( Armor25 )) with all of your cases so make sure that it isn’t the has_item function that is fucking up.

Okay I’ll try that. But the actual function is PS_HasItem() so I fixed that. But it still doesn’t give the health/armor when the round starts. So let me go see if it prints that.

[editline]16th January 2012[/editline]

Oh and for the record, it doesn’t print the print( “health100” ) or w.e

If that fails then run a timer a second or two after the ttt_round_start hook is called (that’s not its name I know but you get what I mean)

Ok so I just tested it and apparently it doesn’t print the self:PS_HasItem( Health100 ) either. Give me a minute and I’m giong to check if it prints anything before the if statements.

[editline]16th January 2012[/editline]

TTTBeginRound ??? I’ve tried that. That was my original attempt.

[editline]16th January 2012[/editline]

self:PrintMessage(HUD_PRINTTALK, “test” )
if self:PS_HasItem(Health100) then
self:PrintMessage(HUD_PRINTTALK, self:PS_HasItem( Health100 ) )
self:PrintMessage(HUD_PRINTTALK, “test2” )

Okay so it DOES print before the if statements. But it never prints “test2” … So I’m assuming it’s because my function isn’t working.

[editline]16th January 2012[/editline]

I have another idea, using this:

[1] = {
Name = “Powerups”,
Icon = “add”,
Enabled = true,
Items = {
Health25 = {

how can I get the Health25 table?
Would it be: POINTSHOP.Items[1].Items.Health25