OrbTanT Posted July 9, 2014 Share Posted July 9, 2014 (edited) We could have got help me as I turn the gang to dominate territory, and as soon as you start attack connect the progress bar showing how much time is left to start the attack, I can't connect them. gang script- GroveStreet = createRadarArea(2440.58, -1629.78, 150, -150, 0, 255, 0 , 225) createBlip(2495.32, -1691.06, 14.76,62) marker = createMarker(2495.20, -1685.94, 12.50,"cylinder", 2, 0, 255, 0, 255) local GroveTeam = createTeam("GroveStreet", 0, 255, 0) function JoinGroveStreet(player) if getPlayerTeam(player) ~= GroveTeam then if isElementWithinMarker(player, marker) then setPlayerTeam(player, GroveTeam) outputChatBox("#FF0000 [GANG] #FFF000 Bem vindo a gang #00FF00 GroveStreet !", player, 0, 0, 0, true) outputChatBox("#FF0000 [GANG] #FFF000 Digite #FF0000 /abandonargrove #FFF000 para sair da #00FF00 GroveStreet !", player, 0, 0, 0, true) end end end addCommandHandler("ingressargrove", JoinGroveStreet) function onSpawn() if getPlayerTeam(source) == GroveTeam then setElementPosition(source, 2512.46, -1671.85, 13.49) end end addEventHandler("onPlayerSpawn", root, onSpawn) addEventHandler("onMarkerHit", marker, function(player) if getElementType(player) == "player" then outputChatBox("#FF0000 [GANG] #FFF000 Para entra a gang GroveStreet digita #00FF00 /ingressargrove", player, 0, 0, 0, true) end end) function sairDaGangGrove(player) if getPlayerTeam(player) then setPlayerTeam(player, nil) outputChatBox("#FF0000[GANG]#FFF000 Você saiu da gang", player, 255, 255, 255, true) else outputChatBox("#FF0000[GANG]#FFF000 Você não tem gang", player, 255, 255, 255, true) end end addCommandHandler("abandonargrove", sairDaGangGrove) territorio local pArea = createRadarArea(2163.524169,2031.388061 , 150, 60, 255, 255, 255, 225 ) local pCuboid = createColCuboid (2163.524169,2031.388061 , 10, 197.5, 92, 30 ) addEventHandler("onResourceStart", resourceRoot, function() outputDebugString("Gz Banco", 3, 0, 255, 0) end ) addEventHandler( 'onColShapeHit', pCuboid, function( player ) if (getPlayerTeam( player )) then local pTeam = getPlayerTeam( player ) local iR, iG, iB = getTeamColor( pTeam ) local rR, gG, bB = getRadarAreaColor( pArea ) if ( iR == rR ) and ( iG == gG ) and ( iB == bB ) then triggerClientEvent(player, 'friendly', player) else setRadarAreaFlashing( pArea, true ) outputChatBox( "#F08080[GANGZONES] #F8F8FFA gang ".. getTeamName(getPlayerTeam(player)).." esta atacando a gang / na #ff0000 GangZone Banco!",getRootElement(),255,255,255,true); triggerClientEvent(player, 'time', player) triggerClientEvent(player, 'countdown', player) pArea1Timer = setTimer( function() setRadarAreaColor (pArea, iR, iG, iB, 999); givePlayerMoney( player, 4000 ); outputChatBox( "#F08080[GANGZONES] #F8F8FFA gang ".. getTeamName(getPlayerTeam(player)).." dominou o #ff0000 A GangZona Banco #F8F8FFA da gang / ! ",getRootElement(),255,255,255,true); setRadarAreaFlashing( pArea, false ) end, 5000, 1 ) end else triggerClientEvent(player, 'group', player) end end ) Gui-progressbar function clientResourceStart ( ) progressBar = guiCreateProgressBar ( 0.8 , 0.8 , 0.1 , 0.05 , true , nil ) end addEventHandler ( "onClientResourceStart" , getRootElement ( ) , clientResourceStart ) function clientResourceStop ( ) destroyElement ( progressBar ) end addEventHandler ( "onClientResourceStop" , getRootElement ( ) , clientResourceStop ) -- If the progressbar exsist then if ( somebar ) then -- set the progress guiProgressBarSetProgress(somebar, 80) -- get the progress progress = guiProgressBarGetProgress(somebar) -- output to the chatbox outputChatBox ( "Current progress:" .. progress .. "%" ) else --if the progressbar was not found outputChatBox ("progressbar not found!") -- output a message end I did this with the example of the wiki even the progress bar more I can't run. Edited July 9, 2014 by Guest Link to comment
Et-win Posted July 9, 2014 Share Posted July 9, 2014 setTimer --and/or onClientRender Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 I don't understand very well, where do I add the settimer? Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 Using just the script that I showed it appears the following errors when trying to dominate a territory Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 Et-win where should I add the settimer? You what I'm doing wrong to appear these errors. Link to comment
Et-win Posted July 9, 2014 Share Posted July 9, 2014 local yourmarker = createMarker(1, 1, 1, "cylinder", 5, 255, 255, 255, 255) function enter(tElement) if (tElement == getLocalPlayer()) then if (source == yourmarker) then thetimer = setTimer(function() outputChatBox("Time is over! Move on!") end, 5000, 1) end end end function leave(tElement) if (tElement == getLocalPlayer()) then if (source == yourmarker) then if (isTimer(thetimer)) then killTimer(thetimer) outputChatBox("You left the marker! Wait until the time is over! Get back in right now!") end end end end addEventHandler("onClientMarkerHit", getRootElement(), enter) addEventHandler("onClientMarkerLeave", getRootElement(), leave) A very fast-made example of a full white-marker which is randomly created by position 1, 1, 1. (Didn't test it either, but it's about letting you understand one of the ways to do something like this) If you entered the marker you still can move, but if you go out of it, you will need to reënter the marker in order to finish the time. (If you leave the marker the timer get killed) Try to understand it and continue. Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 More how do I connect the progress bar with the territory, when I try to dominate the progress does not fill and debugscript apareçe clintside event time and countdown, already tested and only when the progress ta online Link to comment
Et-win Posted July 9, 2014 Share Posted July 9, 2014 The script example I made is client-side. I believe you want to have it server-side. No problem, just use: onMarkerHit --Instead of onClientMarkerHit --and onMarkerLeave --Instead of onClientMarkerLeave Instead of checking 'tElement == getLocalPlayer()' you check in what team (If you work with teams?) the element (player) is. Make another function with: getTimerDetails And trigger the results to the players in the team where the timer belongs to. Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 I'll test thanks for the help Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 Sorry without wanting to abuse, if you could help me with this progress bar how do I make it recognize the territories Link to comment
Et-win Posted July 9, 2014 Share Posted July 9, 2014 What you want to do excactly? I can't follow it anymore to be honest. Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 What I am trying to do is as soon as the player of the team in case grove enters the territory , the progress bar starts to fill and when fills begins the attack of time grove in the territory. is complicated more I have no idea of how to do it. Link to comment
Et-win Posted July 9, 2014 Share Posted July 9, 2014 Someone else can maybe help you. I was thinking about triggering every second to the clients to fill the ProgressBar, but I'm not sure or that is really a good idea. Who know's maybe I will learn today too... Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 I believe, in every form thanks for the help Link to comment
_DrXenon Posted July 9, 2014 Share Posted July 9, 2014 If i can understand your latest reply, i might help.. So can you reply again? Be more clear. Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 good I wanted to do a bar of progress indicating the time to initiate an attack into a territory for example, I entered in the area that is in the script the top, that appears the bar of progress indicating that the player has to be inside the area to dominate, that is filling as the player stays inside the area, when it ends filling the bar of progress it begins the attack in order that he dominates the territory, the only way what I found it was the guiCreateProgressBar what I found in the wiki any more I did not understand very much as well as work, I managed to create the bar and such, any more I do not manage to add in the part of the clientside and of the serverside and do not manage to do with what the bar fills as the player stays inside the area. obs: Sorry my English, my native language is Portuguese, I have to use a translator, if someone calls me recommend a good. Link to comment
OrbTanT Posted July 9, 2014 Author Share Posted July 9, 2014 Supercroz and et-win could help me if possible? Link to comment
_DrXenon Posted July 10, 2014 Share Posted July 10, 2014 Google translator sucks, but anyway.. You want the progress bar to be filled as long as the player is in the territory ... ? What do you mean by 'attack'. If you can answer that i will help, else i will try to..help Link to comment
OrbTanT Posted July 11, 2014 Author Share Posted July 11, 2014 Yes I want the progress bar fills, while player is within the area, which I wanted to say with the attack, it would be, when the progress bar is full, the area begins to flash which means that the team is dominating this area. Link to comment
OrbTanT Posted July 12, 2014 Author Share Posted July 12, 2014 Will that someone could help? Link to comment
Et-win Posted July 13, 2014 Share Posted July 13, 2014 As soon as someone enters the marker, then set a timer with the time you want. Also use triggerClientEvent to send the time of the timer to the client. (1 time, 'onMarkerHit' only) Set a timer on the client again and then make another function with event 'onClientRender' which sets the progressbar with 'getTimerDetails' and 'guiProgressBarSetProgress'. As soon as someone leaves the marker (With 'onMarkerLeave') then check or someone is still in, if not, then stop the time ('killTimer') and trigger to the clients to do the same by them. (Remember to STOP event 'onClientRender'). Use the setTimer at SERVER-SIDE to start the attack/war/etc., not the client's. Link to comment
OrbTanT Posted July 14, 2014 Author Share Posted July 14, 2014 I didn't quite understand, could give me an example, I have to use a translator, my language is Brazilian. Link to comment
Et-win Posted July 15, 2014 Share Posted July 15, 2014 I'm crazy that I spend my time on doing this, but ow well, guess I was bored and being too nice. It's highly possible that I made some typos, wrong stuff, etc, etc, etc, because I didn't test it and typed this out of my head. But it was for example anyway. Try to understand it and add it/some stuff to your own code. --Server local marker1 = createMarker(1, 1, 1) local marker2 = createMarker(-1, -1, -1) local team1 = createTeam("Team1", 255, 0, 0) local team2 = createTeam("Team2", 0, 255, 0) function startWar(gType) if (gType == "Team1") then outputChatBox("'"..getTeamName(team1).."' is in the area of '"..getTeamName(team2).."' for too long, war time!") elseif (gType == "Team2") then outputChatBox("'"..getTeamName(team2).."' is in the area of '"..getTeamName(team1).."' for too long, war time!") end end function startWarTimer(tElement) if (source == marker1) then --Marker of Team1 was hitted if (getElementType(tElement) == "player") then --Check or the element is a player if (getPlayerTeam(tElement) == team2) then --Check or he is in the opposite team warTimer1 = setTimer(function() startWar("Team2") end, 10000, 1) --Start the timer (For Team2), if he is longer than 10 seconds in the marker, then start the war! triggerClientEvent("onStartWarTimer", getRootElement(), "timer1") --Start the time on the client's too (Will have more time than the timer on the server because of time between triggering) end end elseif (source == marker2) then if (getElementType(tElement) == "player") then --Check or the element is a player if (getPlayerTeam(tElement) == team1) then --Check or he is in the opposite team warTimer2 = setTimer(function() startWar("Team1") end, 10000, 1) --Start the timer (For Team1), if he is longer than 10 seconds in the marker, then start the war! triggerClientEvent("onStartWarTimer", getRootElement(), "timer2") --Start the time on the client's too (Will have more time than the timer on the server because of time between triggering) end end end end function stopWarTimer(tElement) if (source == marker1) then if (isTimer(warTimer1)) then --If the timer exists killTimer(warTimer1) --Kill it and kill it at the client's too triggerClientEvent("onKillWarTimer", getRootElement(), "timer1") end elseif (source == marker2) then if (isTimer(warTimer2)) then --If the timer exists killTimer(warTimer2) --Kill it and kill it at the client's too triggerClientEvent("onKillWarTimer", getRootElement(), "timer2") end end end addEventHandler("onMarkerHit", getRootElement(), startWarTimer) addEventHandler("onMarkerLeave", getRootElement(), stopWarTimer) --Client --Remember you need to have 2 progressbars, because both teams can go and enter opposites area's. For more teams add more of course. local cProgressBar1 = guiCreateProgressBar(1, 1, 250, 50, false) local cProgressBar2 = guiCreateProgressBar(1, 50, 250, 50, false) local isRendering1 = false local isRendering2 = false function startFilling() if (isRendering1 == true) then if (guiProgressBarGetProgress(cProgressBar1) < 100) then --If the progress is less than 100, then... local gTime, g2, g3 = getTimerDetails(warTimer1) local gFormattedProgress = math.abs(math.floor((100/10000*gTime))) --Get the correct progress. A progressbar can be from 0 to 100, so do some math. (Mine sucks so this can be wrong... (A)) guiProgressBarSetProgress(cProgressBar1, gFormattedProgress) --After doing some math, set the progress. end end if (isRendering2 == true) then if (guiProgressBarGetProgress(cProgressBar2) < 100) then --If the progress is less than 100, then... local gTime, g2, g3 = getTimerDetails(warTimer2) local gFormattedProgress = math.abs(math.floor((100/10000*gTime))) --Get the correct progress. A progressbar can be from 0 to 100, so do some math. (Mine sucks so this can be wrong... (A)) guiProgressBarSetProgress(cProgressBar2, gFormattedProgress) --After doing some math, set the progress. end end end addEventHandler("onClientRender", getRootElement(), startFilling) function startTimer(gType) if (gType == "timer1") then warTimer1 = setTimer(function() startWar("Team1") end, 10000, 1) --Start the timer, start filling the progressbar isRendering1 = true elseif (gType == "timer2") then warTimer2 = setTimer(function() startWar("Team1") end, 10000, 1) --Start the timer, start filling the progressbar isRendering2 = true end end addEvent("onStartWarTimer", true) addEventHandler("onStartWarTimer", getRootElement(), startTimer) function stopTimer(gType) if (gType == "timer1") then if (isTimer(warTimer1)) then killTimer(warTimer1) end isRendering1 = false elseif (gType == "timer2") then if (isTimer(warTimer2)) then killTimer(warTimer2) end isRendering2 = false end end addEvent("onKillWarTimer", true) addEventHandler("onKillWarTimer", getRootElement(), stopTimer) 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