JuanM27 Posted November 5, 2012 Share Posted November 5, 2012 hola buenos dias. estoy haciendo un sistema de turf desde hace tiempo, y por varios meses lo use asi, pero me decidi en tratar de arreglarlo, pero me sigo trabando como antes. bueno le comento, en el sistema de turf que yo tengo, lo gana bien. pero tengo 2 problemas que talvez sea una pabada y yo no me dio cuenta... les cuentos los 2 problemas que tengo.... 1º no defiende. 2º si entran a defender, deja de contar el timer del atacante. le dejo el script de 1 turf de como lo tengo PD: uso un sistema de gans creado por mi mismo el cual anda bien. y uso MySQL para obtener todos los datos.... aca dejo el script es todo server-side ya que lo unico que hace el cliente-side es mostrar el texto de la probocacion, desafio de guerra etc.. link1 = dbConnect( "mysql", "dbname=CLGCommunity;host=127.0.0.1", "root", "", "share=0" ) local Turf2 = createColRectangle ( 1838.3730, 1464.1499, 200, 250 ) local Turfs2 = createRadarArea ( 1838.3730, 1464.1499, 200, 250, 0, 255, 0, 175 ) local Turf2Due = {} local Turf2Spawm = {1080.6954345703, 1036.0864257813, 10.5} local Turf2MinutosPro = 0 local Turf2MinutosDef = 0 local ProbocaTimer2 = {} local DefensaTimer2 = {} local robbersTable2 = {} local MinimoInTurf2 = 1 local Turf2PlayerEne = 0 local Turf2Defensa = 0 local EstaAtacando2 = false local GuildAtacante2 = {} local DefensaTable = {} local robbersTable = {} local C1 = 0 local C2 = 0 local C3 = 0 function Pinta() money0 = dbQuery(link1, "SELECT * FROM Turf") local queryResult0 = dbPoll ( money0 , -1 ) local Due2 = queryResult0[1]['Turf2'] local Color1 = dbQuery(link1, "SELECT Color1 FROM clanes WHERE NombreClan='".. Due2 .."'") local queryResultC1 = dbPoll ( Color1 , -1 ) C1 = queryResultC1[1]['Color1'] local Color2 = dbQuery(link1, "SELECT Color2 FROM clanes WHERE NombreClan='".. Due2 .."'") local queryResultC2 = dbPoll ( Color2 , -1 ) C2 = queryResultC2[1]['Color2'] local Color3 = dbQuery(link1, "SELECT Color3 FROM clanes WHERE NombreClan='".. Due2 .."'") local queryResultC3 = dbPoll ( Color3 , -1 ) C3 = queryResultC3[1]['Color3'] setRadarAreaColor ( Turfs2, C1, C2, C3, 175 ) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), Pinta) function EntraTurf2 ( thePlayer, matchingDimension ) local account = getPlayerAccount(thePlayer) local accountName = getAccountName(account) if (getElementType(thePlayer) == "player") then money0 = dbQuery(link1, "SELECT * FROM Turf") local queryResult0 = dbPoll ( money0 , -1 ) local Due1 = queryResult0[1]['Turf2'] Turf2Due = Due1 money = dbQuery(link1, "SELECT usuario FROM clanmiembros WHERE usuario='".. accountName .."'") local queryResult = dbPoll ( money , -1 ) if queryResult[1]['usuario'] == accountName then money1 = dbQuery(link1, "SELECT clan FROM clanmiembros WHERE usuario='".. accountName .."'") local queryResult1 = dbPoll ( money1 , -1 ) local Guild = queryResult1[1]['clan'] GuildAtacante2 = Guild if (Turf2Due ~= Guild) then triggerClientEvent(thePlayer,"Entraste",thePlayer,Turf2Due) ProbocaTimer2 = setTimer ( function ( ) csInRBM = getCriminalsInMarker2 ( source ) if #csInRBM >= tonumber(MinimoInTurf2) then if ( Turf2MinutosPro == 0 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 0 ) end elseif ( Turf2MinutosPro == 1 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 1 ) end elseif ( Turf2MinutosPro == 2 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 2 ) end elseif ( Turf2MinutosPro == 3 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 3 ) end elseif ( Turf2MinutosPro == 4 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 4 ) end elseif ( Turf2MinutosPro == 5 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 5 ) end elseif ( Turf2MinutosPro == 6 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 6 ) end elseif ( Turf2MinutosPro == 7 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 7 ) end elseif ( Turf2MinutosPro == 8 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 8 ) end elseif ( Turf2MinutosPro == 9 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 9 ) end elseif ( Turf2MinutosPro == 10 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Probocacion", cInRBM, 10 ) end elseif ( Turf2MinutosPro == 11 ) then for index, cInRBM in ipairs ( csInRBM ) do setRadarAreaFlashing ( Turfs2, true ) end elseif ( Turf2MinutosPro == 12 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Declara", cInRBM, Turf2Due ) end local master = dbQuery ( link1, "SELECT usuario FROM clanmiembros WHERE clan='".. Turf2Due .."'" ) local queryResult = dbPoll ( master , -1 ) if ( queryResult ~= nil ) then local players = getElementsByType("player") for i,v in ipairs(queryResult) do local Us = v [ "usuario" ] local test = getAccountPlayer(getAccount(Us)) triggerClientEvent(test,"TeLoRoban",test,Guild) EstaAtacando2 = true --ponemos que lo estan atacando! end end elseif ( Turf2MinutosPro == 13 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 0 ) end elseif ( Turf2MinutosPro == 14 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 1 ) end elseif ( Turf2MinutosPro == 15 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 2 ) end elseif ( Turf2MinutosPro == 16 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 3 ) end elseif ( Turf2MinutosPro == 17 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 4 ) end elseif ( Turf2MinutosPro == 18 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 5 ) end elseif ( Turf2MinutosPro == 19 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 6 ) end elseif ( Turf2MinutosPro == 20 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 7 ) end elseif ( Turf2MinutosPro == 21 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 8 ) end elseif ( Turf2MinutosPro == 22 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 9 ) end elseif ( Turf2MinutosPro == 23 ) then for index, cInRBM in ipairs ( csInRBM ) do triggerClientEvent ( cInRBM, "Guerra", cInRBM, 10 ) end elseif ( Turf2MinutosPro == 24 ) then local Color1 = dbQuery(link1, "SELECT Color1 FROM clanes WHERE NombreClan='".. Guild .."'") local queryResultC1 = dbPoll ( Color1 , -1 ) local C1 = queryResultC1[1]['Color1'] local Color2 = dbQuery(link1, "SELECT Color2 FROM clanes WHERE NombreClan='".. Guild .."'") local queryResultC2 = dbPoll ( Color2 , -1 ) local C2 = queryResultC2[1]['Color2'] local Color3 = dbQuery(link1, "SELECT Color3 FROM clanes WHERE NombreClan='".. Guild .."'") local queryResultC3 = dbPoll ( Color3 , -1 ) local C3 = queryResultC3[1]['Color3'] for index, cInRBM in ipairs ( csInRBM ) do givePlayerMoney ( cInRBM, 3000 )--aca le paga a los ganadores. EstaAtacando2 = false triggerClientEvent ( cInRBM, "GanasteTurf", cInRBM,C1,C2,C3 ) Turf2MinutosPro = 0 if (isTimer(ProbocaTimer2)) then killTimer (ProbocaTimer2) end end setRadarAreaColor ( Turfs2, C1, C2, C3, 175 ) setRadarAreaFlashing ( Turfs2, false ) local GuardaNuevoDue = dbQuery ( link1, "UPDATE turf SET Turf2 =?", Guild) end Turf2MinutosPro = Turf2MinutosPro + 1 end end ,10000, 25 --60000 ) else triggerClientEvent ( thePlayer, "MiTurf", thePlayer ) if EstaAtacando2 == true then --aca esta atacando! por lo que intentamos defender. DefensaTimer2 = setTimer ( function ( ) csInRBM = getCriminalsInMarkerDefensa2 ( source ) if #csInRBM >= tonumber(MinimoInTurf2) then if ( Turf2MinutosDef == 0 ) then outputChatBox ( "Congratulations, #FFFF00 defendiendo 0!", csInRBM, 0, 255, 0, true ) elseif ( Turf2MinutosDef == 1 ) then outputChatBox ( "Congratulations, #FFFF00 defendiendo 1!", csInRBM, 0, 255, 0, true ) elseif ( Turf2MinutosDef == 2 ) then outputChatBox ( "Congratulations, #FFFF00 defendiendo 2!", csInRBM, 0, 255, 0, true ) elseif ( Turf2MinutosDef == 3 ) then for index, cInRBM in ipairs ( csInRBM ) do if (isTimer(ProbocaTimer2)) then killTimer (ProbocaTimer2) end setRadarAreaFlashing ( Turfs2, false ) --ponemos el turf normal. for index, cInRBM in ipairs ( csInRBM ) do givePlayerMoney ( cInRBM, 2000 )--aca le pagamos por defender. Turf2MinutosPro = 0 --ponemos los minutos de probacacion en 0 Turf2MinutosDef = 0 --ponemos los minutos de defensa en 0 EstaAtacando2 = false --ponemos que no lo atacan mas. end end end Turf2MinutosDef = Turf2MinutosDef + 1 end end ,15000, 3 ) -- end end end end end end addEventHandler ( "onColShapeHit", Turf2, EntraTurf2 ) function SaleTurf2 ( thePlayer, matchingDimension ) local account = getPlayerAccount(thePlayer) local accountName = getAccountName(account) if getPlayerTeam ( thePlayer ) == getTeamFromName ( "Criminal" ) then --Aca que compruebe que sea del guild atacante.! money = dbQuery(link1, "SELECT usuario FROM clanmiembros WHERE usuario='".. accountName .."'") local queryResult = dbPoll ( money , -1 ) if queryResult[1]['usuario'] == accountName then money1 = dbQuery(link1, "SELECT clan FROM clanmiembros WHERE usuario='".. accountName .."'") local queryResult1 = dbPoll ( money1 , -1 ) local Guild = queryResult1[1]['clan'] if (Guild == GuildAtacante2 ) then csInRBM = getCriminalsInMarker2 Link to comment
Recommended Posts