Lalalu Posted November 20, 2016 Share Posted November 20, 2016 (edited) Holaaa, paso por aca para ver si me pueden ayudar con algo, como puedo hacer para que el headshot que es el resource que pondré a continuación, funcione solo en un area determinada del radar? osea por ejemplo en un rectángulo rojo donde yo escoja la posición? por favor SERVER: function MakePlayerHeadshot( attacker, weapon, bodypart, loss ) if getElementType ( attacker ) == "ped" then if bodypart == 9 then triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss ) setPedHeadless ( source, true ) killPed( source, attacker, weapon, bodypart ) setTimer( BackUp, 900, 1, source ) end end end function MakeHeadshot( source, attacker, weapon, loss ) triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss ) killPed( source, attacker, weapon, 9 ) setPedHeadless ( source, true ) setTimer( BackUp, 900, 1, source ) end function BackUp( source ) if getElementType ( source ) == "player" then setPedHeadless ( source, false ) end end function outputHeadshotIcon (killer, weapon, bodypart) if bodypart == 9 then cancelEvent() local r2,g2,b2 = getTeamColor ( getPlayerTeam( killer ) ) local r1,g1,b1 = getTeamColor ( getPlayerTeam( source ) ) exports.killmessages:outputMessage ( {getPlayerName(killer),{"padding",width=3},{"icon",id=weapon},{"padding",width=3},{"icon",id=256},{"padding",width=3},{"color",r=r1,g=g1,b=b1},getPlayerName(source) }, getRootElement(),r2,g2,b2) end end addEvent ( "onServerHeadshot", true ) addEventHandler( "onPlayerDamage", getRootElement(), MakePlayerHeadshot ) addEventHandler( "onPlayerKillMessage", getRootElement(), outputHeadshotIcon ) addEventHandler( "onServerHeadshot", getRootElement(), MakeHeadshot ) CLIENT: function sendHeadshot ( attacker, weapon, bodypart, loss ) if attacker == getLocalPlayer() then if bodypart == 9 then triggerServerEvent( "onServerHeadshot", getRootElement(), source, attacker, weapon, loss ) setElementHealth ( source, 0 ) setPedHeadless( source, true ) end end end addEventHandler ( "onClientPedDamage", getRootElement(), sendHeadshot ) addEventHandler ( "onClientPlayerDamage", getRootElement(), sendHeadshot ) También para no iniciar otro topic aprovechare y preguntare otra cosa, hay algunas zonas verdes (spawns) que no estén bug? o como se puede arreglar el bug de las zonas verdes? el bug consiste en que por ejemplo te das kill como 3 veces y vas apareciendo en los spawns, y entonces puedes matar en ellos :/, esto pasa cuando se cambian de spawn muy rápido, espero que me puedan ayudar por favor, o indicarme lo qué debo hacer Edited November 20, 2016 by Lalalu Link to comment
Anzo Posted November 21, 2016 Share Posted November 21, 2016 Prueba con esto, no lo he probado (tampoco sé si funciona) local x,y,_ = getElementPosition(localPlayer) local radar = createRadarArea(x, y, 60,60) local colp = createColRectangle(x, y, 60,60) function onHit(hit) if (getElementType(hit) == "player") then addEventHandler ( "onClientPedDamage", getRootElement(), sendHeadshot ) addEventHandler ( "onClientPlayerDamage", getRootElement(), sendHeadshot ) end end addEventHandler("onClientColShapeHit", colp, onHit) function onLeave(leave) if (getElementType(leave) == "player") then removeEventHandler ( "onClientPedDamage", getRootElement(), sendHeadshot ) removeEventHandler ( "onClientPlayerDamage", getRootElement(), sendHeadshot ) end end addEventHandler("onClientColShapeLeave", colp, onLeave) function sendHeadshot ( attacker, weapon, bodypart, loss ) if attacker == getLocalPlayer() then if bodypart == 9 then triggerServerEvent( "onServerHeadshot", getRootElement(), source, attacker, weapon, loss ) setElementHealth ( source, 0 ) setPedHeadless( source, true ) end end end Link to comment
#Dv^ Posted November 21, 2016 Share Posted November 21, 2016 Puedes utilizar isInsideRadarArea para comprobar que esté en el área, sería algo así Client: local radar = createRadarArea ( 3164, -2022, 140,140 , 255, 0, 0, 150 ) -- Esto es un ejemplo function sendHeadshot ( attacker, weapon, bodypart, loss ) local x,y,z = getElementPosition(source) if isInsideRadarArea ( radar, x, y ) then if attacker == getLocalPlayer() then if bodypart == 9 then triggerServerEvent( "onServerHeadshot", getRootElement(), source, attacker, weapon, loss ) setElementHealth ( source, 0 ) setPedHeadless( source, true ) end end end end addEventHandler ( "onClientPedDamage", getRootElement(), sendHeadshot ) addEventHandler ( "onClientPlayerDamage", getRootElement(), sendHeadshot ) Y del lado del servidor sería de la misma manera; local radar = createRadarArea ( 3164, -2022, 140,140 , 255, 0, 0, 150 ) -- Este es otro ejemplo function MakePlayerHeadshot( attacker, weapon, bodypart, loss ) local x,y,z = getElementPosition(source) if isInsideRadarArea ( radar, x, y ) then if bodypart == 9 then triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss ) setPedHeadless ( source, true ) killPed( source, attacker, weapon, bodypart ) setTimer( BackUp, 900, 1, source ) end end end function MakeHeadshot( source, attacker, weapon, loss ) triggerEvent( "onPlayerHeadshot", source, attacker, weapon, loss ) killPed( source, attacker, weapon, 9 ) setPedHeadless ( source, true ) setTimer( BackUp, 900, 1, source ) end function BackUp( source ) if getElementType ( source ) == "player" then setPedHeadless ( source, false ) end end addEvent ( "onServerHeadshot", true ) addEventHandler( "onPlayerDamage", getRootElement(), MakePlayerHeadshot ) addEventHandler( "onServerHeadshot", getRootElement(), MakeHeadshot ) Link to comment
Recommended Posts