DarkLink Posted July 13, 2011 Share Posted July 13, 2011 Okay this is a function to put a color on a name of a player right? I added this to my script just for test: function nametagColorChange ( thePlayer, commandName, r, g, b ) -- Apply the new color mix of RGB to the command handler activator setPlayerNametagColor ( thePlayer, r, g, b ) end -- This is a command handler that activates on text "nametagcolor" in the console. It also asks -- the player to provide values for the extra parameters r, g, b after the command name. These will -- be the new color mix of RGB to apply to the player's name tag. addCommandHandler ( "nametagcolor", nametagColorChange ) and then I get error on server console saying that its a bad argument, and I dont see my color get changed.. keeps white. thanks guys Link to comment
Castillo Posted July 13, 2011 Share Posted July 13, 2011 (edited) function nametagColorChange ( thePlayer, commandName, r, g, b ) -- Apply the new color mix of RGB to the command handler activator setPlayerNametagColor ( thePlayer, tonumber(r), tonumber(g), tonumber(b) ) end -- This is a command handler that activates on text "nametagcolor" in the console. It also asks -- the player to provide values for the extra parameters r, g, b after the command name. These will -- be the new color mix of RGB to apply to the player's name tag. addCommandHandler ( "nametagcolor", nametagColorChange ) Try that. Edited July 13, 2011 by Guest Link to comment
DarkLink Posted July 13, 2011 Author Share Posted July 13, 2011 Thanks for ur reply, no errors now, but I dont get any color modified on my name.. tryed /nametagcolor 100, 100, 100 and /nametagcolor 100 100 100 nothing.. thanks in advance Link to comment
Castillo Posted July 13, 2011 Share Posted July 13, 2011 Maybe your game mode is messing with this? Link to comment
qaisjp Posted July 13, 2011 Share Posted July 13, 2011 Instead of using the tostring.. use tonumber Link to comment
DarkLink Posted July 13, 2011 Author Share Posted July 13, 2011 (edited) thanks both. I already tryed that quaispj , didnt work too Maybe your game mode is messing with this? Well I have using the function setTeamColor, it sets for all the team members, but I am using setNametagcolor before the setTeamColor, so no problem I guess.. Thanks guys! Instead of using the tostring.. use tonumber Tryed your solution now again, and now I have bad argument on fuction setPlayerNametagColor. Bahh, thePlayer is fine I guess.. Thanks guys. Edited July 13, 2011 by Guest Link to comment
qaisjp Posted July 13, 2011 Share Posted July 13, 2011 Use nametag color after the team color. offtopic-And people would normally say quaisjp, but quaispj? LMFAO, just call be quisBJ lmao. Link to comment
DarkLink Posted July 13, 2011 Author Share Posted July 13, 2011 Use nametag color after the team color.offtopic-And people would normally say quaisjp, but quaispj? LMFAO, just call be quisBJ lmao. Bahh stil not working, tonumber fives me bad argument, changed to tostring, no error, but no color changed I keep talking on char and my name didnt change color What the hell..? offtopic- ROFL! Aahah I am sorry bro my mistake quisBJ, was late Link to comment
DarkLink Posted July 13, 2011 Author Share Posted July 13, 2011 anyone? cant fix this Link to comment
Buffalo Posted July 13, 2011 Share Posted July 13, 2011 function nametagColorChange ( thePlayer, commandName, r, g, b ) -- Apply the new color mix of RGB to the command handler activator setPlayerNametagColor ( thePlayer, tonumber(r), tonumber(g), tonumber(b) ) end -- This is a command handler that activates on text "nametagcolor" in the console. It also asks -- the player to provide values for the extra parameters r, g, b after the command name. These will -- be the new color mix of RGB to apply to the player's name tag. addCommandHandler ( "nametagcolor", nametagColorChange ) Try that. Can't help more than Solidsnake did. This should work and if it doesn't then something is wrong elsewhere in your script. Link to comment
DarkLink Posted July 13, 2011 Author Share Posted July 13, 2011 function nametagColorChange ( thePlayer, commandName, r, g, b ) -- Apply the new color mix of RGB to the command handler activator setPlayerNametagColor ( thePlayer, tonumber(r), tonumber(g), tonumber(b) ) end -- This is a command handler that activates on text "nametagcolor" in the console. It also asks -- the player to provide values for the extra parameters r, g, b after the command name. These will -- be the new color mix of RGB to apply to the player's name tag. addCommandHandler ( "nametagcolor", nametagColorChange ) Try that. Can't help more than Solidsnake did. This should work and if it doesn't then something is wrong elsewhere in your script. Hm thanks bro. When a color is setted to a team using setTeamColor, this function doesnt work? Link to comment
Buffalo Posted July 13, 2011 Share Posted July 13, 2011 Try to remove team color code and test without it. Link to comment
DarkLink Posted July 13, 2011 Author Share Posted July 13, 2011 Try to remove team color code and test without it. didnt work bro, I tested on another resource and the function is working perfect.. I dont know where is the problem when I add it to my script What might block this function? do you know? thanks. Link to comment
JR10 Posted July 14, 2011 Share Posted July 14, 2011 Well, in that case, i'm positive that the problem is in the resource not the function. Post all the script then. Link to comment
DarkLink Posted July 14, 2011 Author Share Posted July 14, 2011 Well, in that case, i'm positive that the problem is in the resource not the function.Post all the script then. Really? But all the files that I use for the resource? They are already many If you have any guess of which problems can make this function not to work, I can search on the script. Thanks jacob Link to comment
JR10 Posted July 14, 2011 Share Posted July 14, 2011 Just the script file, that contains the command. Link to comment
DarkLink Posted July 14, 2011 Author Share Posted July 14, 2011 Just the script file, that contains the command. lol its so much jacob 400 lines lol the command handler is the function called by onplayerjoin event local skinsForEMI = {183,158,159,160,162,132,136} addEvent("buttonClicked",true) gamemodeStarted = false playersForIMI = {} playersForPOL = {} function setcolor(playerSource) outputChatBox("cona") setPlayerNametagColor(playerSource, 255, 10, 40) end function joinHandler(equipa) if (gamemodeStarted == false) then if(equipa == 'imigrante') then table.insert(playersForIMI, source) --setPlayerNametagColor(source, tonumber(205), tonumber(133), tonumber(63)) elseif(equipa == 'police') then table.insert(playersForPOL, source) --setPlayerNametagColor(source, 30, 144, 255) else local numberOfTeam = math.random(2) if numberOfTeam == 1 then table.insert(playersForIMI, source) else table.insert(playersForPOL, source) end end end end addEventHandler("buttonClicked", root, joinHandler) function playerJoin () local name = getPlayerName(source) for i, v in ipairs(getElementsByType("player")) do if (v ~= source) then outputChatBox("[" .. name .. "] has joined the server", v, 255, 64, 64) addCommandHandler("nametagcolor", setcolor) end end end addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) function destroyBlipsWhenPlayerLeavesServer ( quitType) local name = getPlayerName(source) outputChatBox("[" .. name .. "] has left the server [" .. quitType .."]", getRootElement(), 255, 64, 64) if source then local attacheds = getAttachedElements ( source ) if ( attacheds ) then for k,element in ipairs(attacheds) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end end addEventHandler ( "onPlayerQuit", getRootElement(), destroyBlipsWhenPlayerLeavesServer ) function colocarDeNoite () setTime ( 1, 0) --setWeather ( 22 ) end addEventHandler ( "onResourceStart", getRootElement(), colocarDeNoite) segundos = 30 timerEnabled = false gamemodeStarted = false local mostrou = false addEvent("checkTwoPlayersOnMode", true) function checkTwoAndNotStartedRunIT () if gamemodeStarted == false then if timerEnabled == false then if(getPlayerCount() >= 1) then setTimer(escreve, 200, 1) triggerClientEvent("canShowGUISPAWN",getRootElement()) mostrou = true else outputChatBox("NOTE: This gamemode need at least 2 players online to start!", source) end else setElementData(source,"secondsRemaining",tostring(segundos)) triggerClientEvent ( source, "showDX", source ) triggerClientEvent(source,"canShowGUISPAWN",source) end else outputChatBox("You will need to wait the gamemode to finish, sorry", source) end end addEventHandler("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT) function escreve () timerEnabled = true for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) triggerClientEvent ( v, "showDX", v ) if(mostrou ~= true) then triggerClientEvent(v,"canShowGUISPAWN",v) end end setTimer(countDown,1000,30) end function countDown() segundos = segundos -1 for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) end if segundos == 3 then triggerClientEvent("hadChosenTeam", getRootElement()) end if segundos == 0 then triggerClientEvent ( "hideDX", getRootElement() ) triggerClientEvent("hideSpawnGUI", getRootElement()) timerEnabled = false gamemodeStarted = true if(#playersForIMI==#playersForPOL or #playersForIMI == #playersForPOL + 1 or #playersForPOL == #playersForIMI + 1) then spawn() else outputChatBox("---Gamemode will run auto-balance---", getRootElement(), 255, 64, 64) autobalance() end end end function onStart () timerEnabled = false if(getPlayerCount() >= 2) then removeEventHandler ("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT ) setTimer(escreve, 1500, 1) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart ) function autobalance() if(#playersForIMI - #playersForPOL >= 2) then local sync = false local dif = #playersForIMI - #playersForPOL if(dif % 2 == 0) then while(sync ~= true) do if(#playersForIMI ~= #playersForPOL) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForIMI ~= #playersForPOL + 1) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() end elseif(#playersForPOL - #playersForIMI >= 2) then local sync = false local dif = #playersForPOL - #playersForIMI if(dif % 2 == 0) then while(sync ~= true) do if(#playersForPOL ~= #playersForIMI) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) table.remove(playersForPOL, #playersForPOL) setPlayerTeam ( playersForIMI[#playersForIMI], team_immigrantsSP ) outputChatBox(">>Auto-balance system changed your team!", playersForIMI[#playersForIMI], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForPOL ~= #playersForIMI + 1) then Link to comment
JR10 Posted July 14, 2011 Share Posted July 14, 2011 Why you are doing addCommandHandler inside onPlayerJoin. here try this: (not sure it will make a diffrence at all) local skinsForEMI = {183,158,159,160,162,132,136} addEvent("buttonClicked",true) gamemodeStarted = false playersForIMI = {} playersForPOL = {} function setcolor(playerSource) outputChatBox("cona") setPlayerNametagColor(playerSource, 255, 10, 40) end addCommandHandler("nametagcolor", setcolor) function joinHandler(equipa) if (gamemodeStarted == false) then if(equipa == 'imigrante') then table.insert(playersForIMI, source) --setPlayerNametagColor(source, tonumber(205), tonumber(133), tonumber(63)) elseif(equipa == 'police') then table.insert(playersForPOL, source) --setPlayerNametagColor(source, 30, 144, 255) else local numberOfTeam = math.random(2) if numberOfTeam == 1 then table.insert(playersForIMI, source) else table.insert(playersForPOL, source) end end end end addEventHandler("buttonClicked", root, joinHandler) function playerJoin () local name = getPlayerName(source) for i, v in ipairs(getElementsByType("player")) do if (v ~= source) then outputChatBox("[" .. name .. "] has joined the server", v, 255, 64, 64) end end end addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) function destroyBlipsWhenPlayerLeavesServer ( quitType) local name = getPlayerName(source) outputChatBox("[" .. name .. "] has left the server [" .. quitType .."]", getRootElement(), 255, 64, 64) if source then local attacheds = getAttachedElements ( source ) if ( attacheds ) then for k,element in ipairs(attacheds) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end end addEventHandler ( "onPlayerQuit", getRootElement(), destroyBlipsWhenPlayerLeavesServer ) function colocarDeNoite () setTime ( 1, 0) --setWeather ( 22 ) end addEventHandler ( "onResourceStart", getRootElement(), colocarDeNoite) segundos = 30 timerEnabled = false gamemodeStarted = false local mostrou = false addEvent("checkTwoPlayersOnMode", true) function checkTwoAndNotStartedRunIT () if gamemodeStarted == false then if timerEnabled == false then if(getPlayerCount() >= 1) then setTimer(escreve, 200, 1) triggerClientEvent("canShowGUISPAWN",getRootElement()) mostrou = true else outputChatBox("NOTE: This gamemode need at least 2 players online to start!", source) end else setElementData(source,"secondsRemaining",tostring(segundos)) triggerClientEvent ( source, "showDX", source ) triggerClientEvent(source,"canShowGUISPAWN",source) end else outputChatBox("You will need to wait the gamemode to finish, sorry", source) end end addEventHandler("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT) function escreve () timerEnabled = true for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) triggerClientEvent ( v, "showDX", v ) if(mostrou ~= true) then triggerClientEvent(v,"canShowGUISPAWN",v) end end setTimer(countDown,1000,30) end function countDown() segundos = segundos -1 for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) end if segundos == 3 then triggerClientEvent("hadChosenTeam", getRootElement()) end if segundos == 0 then triggerClientEvent ( "hideDX", getRootElement() ) triggerClientEvent("hideSpawnGUI", getRootElement()) timerEnabled = false gamemodeStarted = true if(#playersForIMI==#playersForPOL or #playersForIMI == #playersForPOL + 1 or #playersForPOL == #playersForIMI + 1) then spawn() else outputChatBox("---Gamemode will run auto-balance---", getRootElement(), 255, 64, 64) autobalance() end end end function onStart () timerEnabled = false if(getPlayerCount() >= 2) then removeEventHandler ("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT ) setTimer(escreve, 1500, 1) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart ) function autobalance() if(#playersForIMI - #playersForPOL >= 2) then local sync = false local dif = #playersForIMI - #playersForPOL if(dif % 2 == 0) then while(sync ~= true) do if(#playersForIMI ~= #playersForPOL) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForIMI ~= #playersForPOL + 1) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() end elseif(#playersForPOL - #playersForIMI >= 2) then local sync = false local dif = #playersForPOL - #playersForIMI if(dif % 2 == 0) then while(sync ~= true) do if(#playersForPOL ~= #playersForIMI) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) table.remove(playersForPOL, #playersForPOL) setPlayerTeam ( playersForIMI[#playersForIMI], team_immigrantsSP ) outputChatBox(">>Auto-balance system changed your team!", playersForIMI[#playersForIMI], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForPOL ~= #playersForIMI + 1) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) table.remove(playersForPOL, #playersForPOL) Link to comment
DarkLink Posted July 14, 2011 Author Share Posted July 14, 2011 Why you are doing addCommandHandler inside onPlayerJoin.here try this: (not sure it will make a diffrence at all) local skinsForEMI = {183,158,159,160,162,132,136} addEvent("buttonClicked",true) gamemodeStarted = false playersForIMI = {} playersForPOL = {} function setcolor(playerSource) outputChatBox("cona") setPlayerNametagColor(playerSource, 255, 10, 40) end addCommandHandler("nametagcolor", setcolor) function joinHandler(equipa) if (gamemodeStarted == false) then if(equipa == 'imigrante') then table.insert(playersForIMI, source) --setPlayerNametagColor(source, tonumber(205), tonumber(133), tonumber(63)) elseif(equipa == 'police') then table.insert(playersForPOL, source) --setPlayerNametagColor(source, 30, 144, 255) else local numberOfTeam = math.random(2) if numberOfTeam == 1 then table.insert(playersForIMI, source) else table.insert(playersForPOL, source) end end end end addEventHandler("buttonClicked", root, joinHandler) function playerJoin () local name = getPlayerName(source) for i, v in ipairs(getElementsByType("player")) do if (v ~= source) then outputChatBox("[" .. name .. "] has joined the server", v, 255, 64, 64) end end end addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) function destroyBlipsWhenPlayerLeavesServer ( quitType) local name = getPlayerName(source) outputChatBox("[" .. name .. "] has left the server [" .. quitType .."]", getRootElement(), 255, 64, 64) if source then local attacheds = getAttachedElements ( source ) if ( attacheds ) then for k,element in ipairs(attacheds) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end end addEventHandler ( "onPlayerQuit", getRootElement(), destroyBlipsWhenPlayerLeavesServer ) function colocarDeNoite () setTime ( 1, 0) --setWeather ( 22 ) end addEventHandler ( "onResourceStart", getRootElement(), colocarDeNoite) segundos = 30 timerEnabled = false gamemodeStarted = false local mostrou = false addEvent("checkTwoPlayersOnMode", true) function checkTwoAndNotStartedRunIT () if gamemodeStarted == false then if timerEnabled == false then if(getPlayerCount() >= 1) then setTimer(escreve, 200, 1) triggerClientEvent("canShowGUISPAWN",getRootElement()) mostrou = true else outputChatBox("NOTE: This gamemode need at least 2 players online to start!", source) end else setElementData(source,"secondsRemaining",tostring(segundos)) triggerClientEvent ( source, "showDX", source ) triggerClientEvent(source,"canShowGUISPAWN",source) end else outputChatBox("You will need to wait the gamemode to finish, sorry", source) end end addEventHandler("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT) function escreve () timerEnabled = true for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) triggerClientEvent ( v, "showDX", v ) if(mostrou ~= true) then triggerClientEvent(v,"canShowGUISPAWN",v) end end setTimer(countDown,1000,30) end function countDown() segundos = segundos -1 for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) end if segundos == 3 then triggerClientEvent("hadChosenTeam", getRootElement()) end if segundos == 0 then triggerClientEvent ( "hideDX", getRootElement() ) triggerClientEvent("hideSpawnGUI", getRootElement()) timerEnabled = false gamemodeStarted = true if(#playersForIMI==#playersForPOL or #playersForIMI == #playersForPOL + 1 or #playersForPOL == #playersForIMI + 1) then spawn() else outputChatBox("---Gamemode will run auto-balance---", getRootElement(), 255, 64, 64) autobalance() end end end function onStart () timerEnabled = false if(getPlayerCount() >= 2) then removeEventHandler ("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT ) setTimer(escreve, 1500, 1) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart ) function autobalance() if(#playersForIMI - #playersForPOL >= 2) then local sync = false local dif = #playersForIMI - #playersForPOL if(dif % 2 == 0) then while(sync ~= true) do if(#playersForIMI ~= #playersForPOL) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForIMI ~= #playersForPOL + 1) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() end elseif(#playersForPOL - #playersForIMI >= 2) then local sync = false local dif = #playersForPOL - #playersForIMI if(dif % 2 == 0) then while(sync ~= true) do if(#playersForPOL ~= #playersForIMI) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) table.remove(playersForPOL, #playersForPOL) setPlayerTeam ( playersForIMI[#playersForIMI], team_immigrantsSP ) outputChatBox(">>Auto-balance system changed your team!", playersForIMI[#playersForIMI], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForPOL ~= #playersForIMI + 1) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) Link to comment
JR10 Posted July 14, 2011 Share Posted July 14, 2011 I tested the whole script, and it worked, i don't understand it's not even in the script you posted, because i just tested it and it worked. Here that's what i tested: local skinsForEMI = {183,158,159,160,162,132,136} addEvent("buttonClicked",true) gamemodeStarted = false playersForIMI = {} playersForPOL = {} function setcolor(playerSource) outputChatBox("cona") setPlayerNametagColor(playerSource, 255, 10, 40) end addCommandHandler("nametagcolor", setcolor) function joinHandler(equipa) if (gamemodeStarted == false) then if(equipa == 'imigrante') then table.insert(playersForIMI, source) --setPlayerNametagColor(source, tonumber(205), tonumber(133), tonumber(63)) elseif(equipa == 'police') then table.insert(playersForPOL, source) --setPlayerNametagColor(source, 30, 144, 255) else local numberOfTeam = math.random(2) if numberOfTeam == 1 then table.insert(playersForIMI, source) else table.insert(playersForPOL, source) end end end end addEventHandler("buttonClicked", root, joinHandler) function playerJoin () local name = getPlayerName(source) for i, v in ipairs(getElementsByType("player")) do if (v ~= source) then outputChatBox("[" .. name .. "] has joined the server", v, 255, 64, 64) end end end addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) function destroyBlipsWhenPlayerLeavesServer ( quitType) local name = getPlayerName(source) outputChatBox("[" .. name .. "] has left the server [" .. quitType .."]", getRootElement(), 255, 64, 64) if source then local attacheds = getAttachedElements ( source ) if ( attacheds ) then for k,element in ipairs(attacheds) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end end addEventHandler ( "onPlayerQuit", getRootElement(), destroyBlipsWhenPlayerLeavesServer ) function colocarDeNoite () setTime ( 1, 0) --setWeather ( 22 ) end addEventHandler ( "onResourceStart", getRootElement(), colocarDeNoite) segundos = 30 timerEnabled = false gamemodeStarted = false local mostrou = false addEvent("checkTwoPlayersOnMode", true) function checkTwoAndNotStartedRunIT () if gamemodeStarted == false then if timerEnabled == false then if(getPlayerCount() >= 1) then setTimer(escreve, 200, 1) triggerClientEvent("canShowGUISPAWN",getRootElement()) mostrou = true else outputChatBox("NOTE: This gamemode need at least 2 players online to start!", source) end else setElementData(source,"secondsRemaining",tostring(segundos)) triggerClientEvent ( source, "showDX", source ) triggerClientEvent(source,"canShowGUISPAWN",source) end else outputChatBox("You will need to wait the gamemode to finish, sorry", source) end end addEventHandler("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT) function escreve () timerEnabled = true for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) triggerClientEvent ( v, "showDX", v ) if(mostrou ~= true) then triggerClientEvent(v,"canShowGUISPAWN",v) end end setTimer(countDown,1000,30) end function countDown() segundos = segundos -1 for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) end if segundos == 3 then triggerClientEvent("hadChosenTeam", getRootElement()) end if segundos == 0 then triggerClientEvent ( "hideDX", getRootElement() ) triggerClientEvent("hideSpawnGUI", getRootElement()) timerEnabled = false gamemodeStarted = true if(#playersForIMI==#playersForPOL or #playersForIMI == #playersForPOL + 1 or #playersForPOL == #playersForIMI + 1) then spawn() else outputChatBox("---Gamemode will run auto-balance---", getRootElement(), 255, 64, 64) autobalance() end end end function onStart () timerEnabled = false if(getPlayerCount() >= 2) then removeEventHandler ("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT ) setTimer(escreve, 1500, 1) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart ) function autobalance() if(#playersForIMI - #playersForPOL >= 2) then local sync = false local dif = #playersForIMI - #playersForPOL if(dif % 2 == 0) then while(sync ~= true) do if(#playersForIMI ~= #playersForPOL) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForIMI ~= #playersForPOL + 1) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() end elseif(#playersForPOL - #playersForIMI >= 2) then local sync = false local dif = #playersForPOL - #playersForIMI if(dif % 2 == 0) then while(sync ~= true) do if(#playersForPOL ~= #playersForIMI) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) table.remove(playersForPOL, #playersForPOL) setPlayerTeam ( playersForIMI[#playersForIMI], team_immigrantsSP ) outputChatBox(">>Auto-balance system changed your team!", playersForIMI[#playersForIMI], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForPOL ~= #playersForIMI + 1) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) table.remove(playersForPOL, #playersForPOL) Link to comment
DarkLink Posted July 14, 2011 Author Share Posted July 14, 2011 I tested the whole script, and it worked, i don't understand it's not even in the script you posted, because i just tested it and it worked.Here that's what i tested: local skinsForEMI = {183,158,159,160,162,132,136} addEvent("buttonClicked",true) gamemodeStarted = false playersForIMI = {} playersForPOL = {} function setcolor(playerSource) outputChatBox("cona") setPlayerNametagColor(playerSource, 255, 10, 40) end addCommandHandler("nametagcolor", setcolor) function joinHandler(equipa) if (gamemodeStarted == false) then if(equipa == 'imigrante') then table.insert(playersForIMI, source) --setPlayerNametagColor(source, tonumber(205), tonumber(133), tonumber(63)) elseif(equipa == 'police') then table.insert(playersForPOL, source) --setPlayerNametagColor(source, 30, 144, 255) else local numberOfTeam = math.random(2) if numberOfTeam == 1 then table.insert(playersForIMI, source) else table.insert(playersForPOL, source) end end end end addEventHandler("buttonClicked", root, joinHandler) function playerJoin () local name = getPlayerName(source) for i, v in ipairs(getElementsByType("player")) do if (v ~= source) then outputChatBox("[" .. name .. "] has joined the server", v, 255, 64, 64) end end end addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) function destroyBlipsWhenPlayerLeavesServer ( quitType) local name = getPlayerName(source) outputChatBox("[" .. name .. "] has left the server [" .. quitType .."]", getRootElement(), 255, 64, 64) if source then local attacheds = getAttachedElements ( source ) if ( attacheds ) then for k,element in ipairs(attacheds) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end end addEventHandler ( "onPlayerQuit", getRootElement(), destroyBlipsWhenPlayerLeavesServer ) function colocarDeNoite () setTime ( 1, 0) --setWeather ( 22 ) end addEventHandler ( "onResourceStart", getRootElement(), colocarDeNoite) segundos = 30 timerEnabled = false gamemodeStarted = false local mostrou = false addEvent("checkTwoPlayersOnMode", true) function checkTwoAndNotStartedRunIT () if gamemodeStarted == false then if timerEnabled == false then if(getPlayerCount() >= 1) then setTimer(escreve, 200, 1) triggerClientEvent("canShowGUISPAWN",getRootElement()) mostrou = true else outputChatBox("NOTE: This gamemode need at least 2 players online to start!", source) end else setElementData(source,"secondsRemaining",tostring(segundos)) triggerClientEvent ( source, "showDX", source ) triggerClientEvent(source,"canShowGUISPAWN",source) end else outputChatBox("You will need to wait the gamemode to finish, sorry", source) end end addEventHandler("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT) function escreve () timerEnabled = true for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) triggerClientEvent ( v, "showDX", v ) if(mostrou ~= true) then triggerClientEvent(v,"canShowGUISPAWN",v) end end setTimer(countDown,1000,30) end function countDown() segundos = segundos -1 for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) end if segundos == 3 then triggerClientEvent("hadChosenTeam", getRootElement()) end if segundos == 0 then triggerClientEvent ( "hideDX", getRootElement() ) triggerClientEvent("hideSpawnGUI", getRootElement()) timerEnabled = false gamemodeStarted = true if(#playersForIMI==#playersForPOL or #playersForIMI == #playersForPOL + 1 or #playersForPOL == #playersForIMI + 1) then spawn() else outputChatBox("---Gamemode will run auto-balance---", getRootElement(), 255, 64, 64) autobalance() end end end function onStart () timerEnabled = false if(getPlayerCount() >= 2) then removeEventHandler ("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT ) setTimer(escreve, 1500, 1) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart ) function autobalance() if(#playersForIMI - #playersForPOL >= 2) then local sync = false local dif = #playersForIMI - #playersForPOL if(dif % 2 == 0) then while(sync ~= true) do if(#playersForIMI ~= #playersForPOL) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForIMI ~= #playersForPOL + 1) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() end elseif(#playersForPOL - #playersForIMI >= 2) then local sync = false local dif = #playersForPOL - #playersForIMI if(dif % 2 == 0) then while(sync ~= true) do if(#playersForPOL ~= #playersForIMI) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) table.remove(playersForPOL, #playersForPOL) setPlayerTeam ( playersForIMI[#playersForIMI], team_immigrantsSP ) outputChatBox(">>Auto-balance system changed your team!", playersForIMI[#playersForIMI], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForPOL ~= #playersForIMI + 1) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) Link to comment
DarkLink Posted July 14, 2011 Author Share Posted July 14, 2011 Didnt work, I guess I will give up, not possible Thanks all anyway. Link to comment
[DemoN] Posted July 15, 2011 Share Posted July 15, 2011 That works fine for me: function nametagColorChange ( thePlayer, commandName, r, g, b ) setPlayerNametagColor ( thePlayer, r, g, b ) end addCommandHandler ( "nametagcolor", nametagColorChange ) ^ Example from Wiki Link to comment
JR10 Posted July 15, 2011 Share Posted July 15, 2011 This will work, but, there is something wrong with the resource, idk what's wrong, because i tested that too, and i tested his whole script file, and it still worked, so i guess it's something in another script file. 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