Azzmunch Posted April 9, 2016 Share Posted April 9, 2016 Hey there, I've been working on a mod that grabs the player before death, teleports and heals them. The problem I keep experiencing is that sometimes when the player is teleported back to their headquarters, the whole HUD disappears (except the little icons on the top left stay, but unusable) and the escape key stops working etc. Please help. I have no idea what could be happening. respawnMod = respawnMod or {}; local i = 0; function respawnMod.chooseTeam(_keyPressed) -- This function allows the player to choose their team. local key = _keyPressed; if i == 0 then if key == 67 then -- F9 to choose team getPlayer():Say("Press F5 to join POLICE or F6 to join ROBBERS") end end if i == 0 then if key == 63 then -- F5 Teleports the player to the POLICE Headquarters getPlayer():Say("Team chosen - POLICE"); i = i + 1; if i == 1 then local player = getPlayer(); player:getX(); player:getY(); player:setX(11883); player:setY(6910); player:setLx(player:getX()); player:setLy(player:getY()); end end end if i == 0 then if key == 64 then -- F6 Teleports player to ROBBERS Headquarters getPlayer():Say("Team chosen - ROBBERS"); i = i + 2; if i == 2 then local player = getPlayer(); player:getX(); player:getY(); player:setX(11827); player:setY(6869); player:setLx(player:getX()); player:setLy(player:getY()); end end end if i == 2 then if key == 64 then -- F6 getPlayer():Say("To quit, press F8"); end end if i == 1 then if key == 63 then -- F5 getPlayer():Say("To quit, press F8"); end end if i == 1 then if key == 66 then -- F8 i = i + 2; getPlayer():getBodyDamage():RestoreToFullHealth(); getPlayer():Say("CopsNRobbers mode off - careful, you can die now."); end end if i == 2 then if key == 66 then -- F8 i = i + 1; getPlayer():getBodyDamage():RestoreToFullHealth(); getPlayer():Say("CopsNRobbers mode off - careful, you can die now."); end end if key == 38 then local positionX = getPlayer():getX(); local positionY = getPlayer():getY(); print("X = " .. positionX .. " Y = " .. positionY); end end function respawnMod.teleportBase()--POLICE local player = getPlayer(); if i == 0 or i == 1 or i == 3 then local positionX = player:getX(); local positionY = player:getY(); if positionX == 11886.5 then if positionY == 6912.5 then player:setX(11913); player:setY(6948); player:setLx(player:getX()); player:setLy(player:getY()); end end end if i == 0 or i == 2 or i == 3 then local positionX = player:getX(); local positionY = player:getY(); if positionX == 11822.5 then if positionY == 6870.5 then player:setX(11797); player:setY(6877); player:setLx(player:getX()); player:setLy(player:getY()); end end end end function respawnMod.playerHealth() local player = getPlayer(); local bodyDamage = player:getBodyDamage(); local health = bodyDamage:getHealth(); if i == 1 then -- POLICE if health <= 10 then getPlayer():getBodyDamage():RestoreToFullHealth(); player:setX(11883); player:setY(6910); player:setLx(player:getX()); player:setLy(player:getY()); end end if i == 2 then -- ROBBERS if health <= 10 then getPlayer():getBodyDamage():RestoreToFullHealth(); player:setX(11827); player:setY(6869); player:setLx(player:getX()); player:setLy(player:getY()); end end end Events.OnKeyPressed.Add(respawnMod.chooseTeam); Events.OnPlayerUpdate.Add(respawnMod.teleportBase); Events.OnPlayerUpdate.Add(respawnMod.playerHealth); ShuiYin 1 Link to comment Share on other sites More sharing options...
Azzmunch Posted April 9, 2016 Author Share Posted April 9, 2016 oh nevermind, i know what it is now Critical hits are taking player health past the trigger of <= 10 health, but the game is still managing to somehow transport the player back with full health but also having triggered the removal of the UI. Is there any better trigger to catch the player, or prevent death? Thanks Link to comment Share on other sites More sharing options...
Azzmunch Posted April 10, 2016 Author Share Posted April 10, 2016 ok nevermind again. Changed the event trigger from OnPlayerUpdate to OnTick and it works flawlessly. Link to comment Share on other sites More sharing options...
ShuiYin Posted April 10, 2016 Share Posted April 10, 2016 On 4/9/2016 at 2:42 PM, Azzmunch said: Hey there, I've been working on a mod that grabs the player before death, teleports and heals them. The problem I keep experiencing is that sometimes when the player is teleported back to their headquarters, the whole HUD disappears (except the little icons on the top left stay, but unusable) and the escape key stops working etc. Please help. I have no idea what could be happening. respawnMod = respawnMod or {}; local i = 0; function respawnMod.chooseTeam(_keyPressed) -- This function allows the player to choose their team. local key = _keyPressed; if i == 0 then if key == 67 then -- F9 to choose team getPlayer():Say("Press F5 to join POLICE or F6 to join ROBBERS") end end if i == 0 then if key == 63 then -- F5 Teleports the player to the POLICE Headquarters getPlayer():Say("Team chosen - POLICE"); i = i + 1; if i == 1 then local player = getPlayer(); player:getX(); player:getY(); player:setX(11883); player:setY(6910); player:setLx(player:getX()); player:setLy(player:getY()); end end end if i == 0 then if key == 64 then -- F6 Teleports player to ROBBERS Headquarters getPlayer():Say("Team chosen - ROBBERS"); i = i + 2; if i == 2 then local player = getPlayer(); player:getX(); player:getY(); player:setX(11827); player:setY(6869); player:setLx(player:getX()); player:setLy(player:getY()); end end end if i == 2 then if key == 64 then -- F6 getPlayer():Say("To quit, press F8"); end end if i == 1 then if key == 63 then -- F5 getPlayer():Say("To quit, press F8"); end end if i == 1 then if key == 66 then -- F8 i = i + 2; getPlayer():getBodyDamage():RestoreToFullHealth(); getPlayer():Say("CopsNRobbers mode off - careful, you can die now."); end end if i == 2 then if key == 66 then -- F8 i = i + 1; getPlayer():getBodyDamage():RestoreToFullHealth(); getPlayer():Say("CopsNRobbers mode off - careful, you can die now."); end end if key == 38 then local positionX = getPlayer():getX(); local positionY = getPlayer():getY(); print("X = " .. positionX .. " Y = " .. positionY); end end function respawnMod.teleportBase()--POLICE local player = getPlayer(); if i == 0 or i == 1 or i == 3 then local positionX = player:getX(); local positionY = player:getY(); if positionX == 11886.5 then if positionY == 6912.5 then player:setX(11913); player:setY(6948); player:setLx(player:getX()); player:setLy(player:getY()); end end end if i == 0 or i == 2 or i == 3 then local positionX = player:getX(); local positionY = player:getY(); if positionX == 11822.5 then if positionY == 6870.5 then player:setX(11797); player:setY(6877); player:setLx(player:getX()); player:setLy(player:getY()); end end end end function respawnMod.playerHealth() local player = getPlayer(); local bodyDamage = player:getBodyDamage(); local health = bodyDamage:getHealth(); if i == 1 then -- POLICE if health <= 10 then getPlayer():getBodyDamage():RestoreToFullHealth(); player:setX(11883); player:setY(6910); player:setLx(player:getX()); player:setLy(player:getY()); end end if i == 2 then -- ROBBERS if health <= 10 then getPlayer():getBodyDamage():RestoreToFullHealth(); player:setX(11827); player:setY(6869); player:setLx(player:getX()); player:setLy(player:getY()); end end end Events.OnKeyPressed.Add(respawnMod.chooseTeam); Events.OnPlayerUpdate.Add(respawnMod.teleportBase); Events.OnPlayerUpdate.Add(respawnMod.playerHealth); This is PZ Halflife Counter Strike Link to comment Share on other sites More sharing options...
Azzmunch Posted April 12, 2016 Author Share Posted April 12, 2016 Somewhat Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now