kevenvz Posted March 31, 2011 Share Posted March 31, 2011 Hello I want to make this script but I don't know how. I tried this code but it don't work . function setTeams() if (getElementModel==78) then setPlayerTeam(source, teamWorkless) end end Link to comment
XFawkes Posted March 31, 2011 Share Posted March 31, 2011 function setTeams() if getElementModel(source) == 78 then setPlayerTeam ( source, teamWorkless) end end Link to comment
kevenvz Posted March 31, 2011 Author Share Posted March 31, 2011 I tried that but don't work. Link to comment
Wojak Posted March 31, 2011 Share Posted March 31, 2011 how is setTeams function called? (event, command, bind key?) Link to comment
kevenvz Posted March 31, 2011 Author Share Posted March 31, 2011 That is the only function no event etc. fullcode: function createTeams() teamCriminal = createTeam ( "Crimineel", 255, 0, 0 ) teamWorkless = createTeam ( "Werkloos", 255, 255, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeams ) function setTeams() if getElementModel(source) == 78 then setPlayerTeam ( source, teamWorkless) end end Link to comment
Kenix Posted March 31, 2011 Share Posted March 31, 2011 That is the only function no event etc.fullcode: function createTeams() teamCriminal = createTeam ( "Crimineel", 255, 0, 0 ) teamWorkless = createTeam ( "Werkloos", 255, 255, 255 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeams ) function setTeams() if getElementModel(source) == 78 then setPlayerTeam ( source, teamWorkless) end end how you use setTeams function? Link to comment
#Paper Posted March 31, 2011 Share Posted March 31, 2011 function setTeam() for id, player in ipairs(getElementsByType("player")) do if getElementModel(player ) == 78 then setPlayerTeam" class="kw6">setPlayerTeam ( player , teamWorkless) end end end setTimer(1000, setTeam,-1) Try this, i did not test it, but i think that it can be work... P.S: Set the player's team every 1 second... Link to comment
kevenvz Posted March 31, 2011 Author Share Posted March 31, 2011 That script got bugs but I changed a bit and this is teh code: function setTeam() for id, player in ipairs(getElementsByType("player")) do if getElementModel(player ) == 78 then setPlayerTeam ( player , teamWorkless) end end end setTimer(setTeam, 1000, -1) Link to comment
Kenix Posted March 31, 2011 Share Posted March 31, 2011 try this setTimer(function() for id, player in ipairs(getElementsByType("player")) do if getElementModel(player ) == 78 then setPlayerTeam ( player , teamWorkless) end end end,1000,0) please explain how you would like to receive getElementModel in which case Link to comment
Wojak Posted March 31, 2011 Share Posted March 31, 2011 try this setTimer(function() for id, player in ipairs(getElementsByType("player")) do if getElementModel(player ) == 78 then setPlayerTeam ( player , teamWorkless) end end end,1000,0) please explain how you would like to receive getElementModel in which case "getElementsByType("player")" returns a table with all players in the server "for id, player in ipairs(getElementsByType("player")) do" - this means "do it for all elements in table (all players)", id is a table index, "player" is some player in the cell with index "id" so " getElementModel(player )" is correct Link to comment
Castillo Posted April 1, 2011 Share Posted April 1, 2011 function setTeam() for id, player in ipairs(getElementsByType("player")) do if getElementModel(player ) == 78 then setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam ( player , teamWorkless) end end end setTimer(1000, setTeam,-1) Try this, i did not test it, but i think that it can be work... P.S: Set the player's team every 1 second... Your timer is wrong, it should be, setTimer(setTeam, 1000, 0) Link to comment
#Paper Posted April 1, 2011 Share Posted April 1, 2011 function setTeam() for id, player in ipairs(getElementsByType("player")) do if getElementModel(player ) == 78 then setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam ( player , teamWorkless) end end end setTimer(1000, setTeam,-1) Try this, i did not test it, but i think that it can be work... P.S: Set the player's team every 1 second... Your timer is wrong, it should be, setTimer(setTeam, 1000, 0) Oh i forgot ty 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