Hutchpe Posted November 1, 2012 Share Posted November 1, 2012 Thanks to the help of some wonderful members I got team spawning working nicely. Now I have come across another problem. Whenever someone on a team dies they don't respawn and the camera just stays hovering above their body until they either reconnect or change teams. Here is the current team spawn scripts. addCommandHandler("joinmexicans", function(thePlayer, commandName) spawnPlayer(thePlayer, -1502,-146,14.1484375, 0,173,0,0,teamMexicans) outputChatBox("You are a Mexican.",thePlayer) end ) addCommandHandler("joinbordercontrol", function(thePlayer, commandName) spawnPlayer(thePlayer, -1346,-213,14.1484375, 0,71,0,0,teamBorderControl) outputChatBox("You are the Border Control.",thePlayer) end ) I've had a shot at writing a respawn script but my very limited knowledge in Lua has meant that it's a failure addEventHandler("onPlayerWasted", root, function playerWasted () local team = getPlayerTeam (source) if (team == teamBorderControl) then spawnPlayer(thePlayer, -1346,-213,14.1484375, 0,71,0,0,teamBorderControl) end end ) Can anyone point me in the right direction? Also my last questions are is it possible to write a script that checks to see if anyone on a team is alive and if no one is then reload the resource? and Is it possible to have players show up on the radar in the MTA:SA game mode? Sorry if some questions are a bit of topic. Any help is much appreciated. Link to comment
myonlake Posted November 1, 2012 Share Posted November 1, 2012 'thePlayer' isn't defined, you must use 'source'. It looks like you just missed it, happens often to me as well addEventHandler("onPlayerWasted", root, function playerWasted(ammo, killer, weapon, bodypart, stealth) local team = getPlayerTeam (source) if (team == teamBorderControl) then spawnPlayer(source, -1346, -213, 14.1484375, 0, 71, 0, 0, teamBorderControl) end end ) -- For the alive team members, try this. This is just an example by the way. Commands /teammates - Outputs alive team members, if none found, outputs none Server-side function getAlivePlayersInTeam(player) result = false outputChatBox("Alive players in your team:", player, 255, 180, 0, false) for i,v in ipairs(getPlayersInTeam(getPlayerTeam(player))) do if not isPedDead(v) then outputChatBox(" " .. getPlayerName(v), player, 255, 180, 0, false) result = true end end if result == false then outputChatBox(" No alive players in your team.", player, 255, 0, 0, false) end end addCommandHandler("teammates", function(player, cmd) if getPlayerTeam(player) then getAlivePlayersInTeam(player) end end ) For the check only, use this: Server-side for i,v in ipairs(getPlayersInTeam(teamPolice)) do -- Get the players from team 'teamPolice' if not isPedDead(v) then return true -- Is the player alive? else return false -- Is the player dead? end end -- For the players to show on radar, as in, blips. You could use the 'playerblips' resource, which comes from the default resource package (download the latest package here »). Link to comment
Hutchpe Posted November 1, 2012 Author Share Posted November 1, 2012 Ok I this is what used the code you helped me fix but whenever I start the server I get a message saying WARNING: Loading script failed: Mexihunt\script.lua:88: '(' expected near 'playerWasted' This is what the code currently looks like addEventHandler("onPlayerWasted", root, function playerWasted(ammo, killer, weapon, bodypart, stealth) local team = getPlayerTeam (source) if (team == teamBorderControl) then spawnPlayer(source, -1602.9626464844, 660.72479248047, 7.1875, 0, 71, 0, 0, teamBorderControl) end end ) addEventHandler("onPlayerWasted", root, function playerWasted(ammo, killer, weapon, bodypart, stealth) local team = getPlayerTeam (source) if (team == teamMexicans) then spawnPlayer(source, 364.96685791016, 2507.6645507813, 16.496768951416, 0, 71, 0, 0, teamMexicans) end end ) Can anyone see what's wrong with the code? Link to comment
TAPL Posted November 1, 2012 Share Posted November 1, 2012 addEventHandler("onPlayerWasted", root, function (ammo, killer, weapon, bodypart, stealth) local team = getPlayerTeam(source) if (team == teamBorderControl) then spawnPlayer(source, -1602.9626464844, 660.72479248047, 7.1875, 0, 71, 0, 0, teamBorderControl) elseif (team == teamMexicans) then spawnPlayer(source, 364.96685791016, 2507.6645507813, 16.496768951416, 0, 71, 0, 0, teamMexicans) end end ) Link to comment
Hutchpe Posted November 1, 2012 Author Share Posted November 1, 2012 Thanks so much myonlake and TAPL. It's all working great now. Link to comment
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