Jump to content

[Help] Help With my code


Smirnoff

Recommended Posts

i had a idea for a radioactive zone script like Fallout 3 or Stalker

but actually i cant make this work

any help?

previously declared

hill_Enter

radx4

radn

radmaxx

This Line It is when the player enters the area

function hill_Enter ( player, matchingDimension ) 
        if (getElementType(player) == "player") then 
                radx4() playSound("sounds/rad.mp3") 
             elseif radn >= radmaxx then               
             setElementData(player,"blood",-666)  
        end 
end 
setTimer(hill_Enter,1000,0) 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 

Link to comment
function hill_Enter ( player, matchingDimension ) 
    if (player and getElementType(player) == "player" and matchingDimension) then 
    setTimer( 
        function (player) 
            radx4() 
            playSound("sounds/rad.mp3")      
            if radn and radn >= radmaxx then              
                setElementData(player,"blood",-666) 
            end 
        end,1000,0,player)       
    end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter) 

Link to comment
function hill_Enter ( player, matchingDimension ) 
    if (player and getElementType(player) == "player" and matchingDimension) then 
    setTimer( 
        function (player) 
            radx4() 
            playSound("sounds/rad.mp3")      
            if radn and radn >= radmaxx then              
                setElementData(player,"blood",-666) 
            end 
        end,1000,0,player)       
    end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter) 

actually with the change nothing happend xD

you wanna see all script?

Link to comment

well, I'm trying to create a radioactive area-zone(as in fallout 3 or Stalker game)

when you enter this area, the sound of a geiger counter Start

and start a count to 300

having passed the 300 the player will die or lose health

any idea?

local hillArea = createColRectangle ( -736.27728271484,909.60327148438, 150, 150 ) 
local hillRadar = createRadarArea ( -736.27728271484,909.60327148438, 100, 100, 0, 255, 0, 175 ) 
  
local radmax = 300 
local player = getLocalPlayer() 
  
function radx() 
local radn = getElementData(player,"Radiacion") 
    radi = guiCreateLabel(0.01, 0.31, 0.22, 0.03, "Radiacion:"..radn, true) 
    guiSetFont(radi, "default-bold-small") 
    guiLabelSetColor(radi, 255, 0, 0) 
end 
  
function radx2() 
local radn = getElementData(player,"Radiacion") 
    if not radn then 
        setElementData(player,"Radiacion",0) 
        destroyElement(radi) 
        setTimer(radx,500,1) 
    else 
    destroyElement(radi) 
    setTimer(radx,500,1) 
end 
  
 ---Jugador entrando al area  
function hill_Enter ( player, matchingDimension ) 
    if (player and getElementType(player) == "player" and matchingDimension) then 
    setTimer( 
        function (player) 
            radx4() 
            playSound("sounds/rad.mp3")     
            if radn and radn >= radmaxx then             
                setElementData(player,"blood",-666) 
            end 
        end,1000,0,player)      
    end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter) 
  
  
-- Jugador saliendo del Area 
function hill_Exit ( player, matchingDimension ) 
        if (getElementType(player) == "player") then 
                radx5() 
                end 
        end 
end 
addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) 
  
function radx4() 
setElementData(player,radn + 10) 
end 
  
function radx5() 
setElementData(player,radn - 10) 
end 

Link to comment

Yes he does mean health, he said previously that he wanted to lower health, or kill the player.

Any ways issues I see just from scanning :

  • radn is not defined as a global variable, you will have to redefine in it in each of the segments
    enter timer is never cancelled so even when he leaves he will still gain radioactive stuff
    function radx2 is missing an end
    function hill_Exit has 1 to many ends
    Any thing appearing in debugscript 3?

Link to comment
I will be glad to help,

Btw,

What do you mean by 'blood'? to make the player's health down when the timer become less than or equal to 0 ?

i want this script work with a "Dayz gamemode" and in this mode the health equal to blood

example a player had 20000 blood if he get a shot he lost a 356 from this 20000

when the number gets negative or 0 automatically the player dies

will be great if become down reaching the 300 maximum rads units

Link to comment
Yes he does mean health, he said previously that he wanted to lower health, or kill the player.

Any ways issues I see just from scanning :

  • radn is not defined as a global variable, you will have to redefine in it in each of the segments
    enter timer is never cancelled so even when he leaves he will still gain radioactive stuff
    function radx2 is missing an end
    function hill_Exit has 1 to many ends
    Any thing appearing in debugscript 3?

is there any log for debugscript 3?

Link to comment

Try this: (Viva DayZ :v)

local hillArea = createColRectangle ( -736.27728271484,909.60327148438, 150, 150 ) 
    local hillRadar = createRadarArea ( -736.27728271484,909.60327148438, 100, 100, 0, 255, 0, 175 ) 
      
    local radmax = 300 
    local player = getLocalPlayer() 
      
    function radx() 
    local radn = getElementData(player,"Radiacion") 
        radi = guiCreateLabel(0.01, 0.31, 0.22, 0.03, "Radiacion: "..radn, true) 
        guiSetFont(radi, "default-bold-small") 
        guiLabelSetColor(radi, 255, 0, 0) 
    end 
      
    function radx2() 
    local radn = getElementData(player,"Radiacion") 
        if not radn then 
            setElementData(player,"Radiacion",0) 
            destroyElement(radi) 
            setTimer(radx,500,1) 
        else 
        destroyElement(radi) 
        setTimer(radx,500,1) 
    end 
    end 
      
     ---Jugador entrando al area 
    function hill_Enter ( player, matchingDimension ) 
        if (player and getElementType(player) == "player" and matchingDimension) then 
            if radx5Timer then 
            killTimer(radx5Timer) 
            end 
            local radx4Timer = setTimer( 
            function (player) 
                radx4() 
                playSound("sounds/rad.mp3")     
                if radn and radn >= radmaxx then             
                    setElementData(player,"blood",-665) 
                end 
            end,1000,0,player)     
        end 
        end 
    addEventHandler ( "onColShapeHit", hillArea, hill_Enter) 
      
      
    -- Jugador saliendo del Area 
    function hill_Exit ( player, matchingDimension ) 
            if (player and getElementType(player) == "player" and matchingDimension) then 
                    if radx4Timer then 
                        killTimer(radx4Timer) 
                    end 
                    local radx5Timer = setTimer(radx5, 1000, 0, player) 
            end 
    end 
    addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) 
      
    function radx4() 
    setElementData(player,radn + 10) 
    end 
      
    function radx5() 
    setElementData(player,radn - 10) 
    end 

Link to comment
Try this: (Viva DayZ :v)
local hillArea = createColRectangle ( -736.27728271484,909.60327148438, 150, 150 ) 
    local hillRadar = createRadarArea ( -736.27728271484,909.60327148438, 100, 100, 0, 255, 0, 175 ) 
      
    local radmax = 300 
    local player = getLocalPlayer() 
      
    function radx() 
    local radn = getElementData(player,"Radiacion") 
        radi = guiCreateLabel(0.01, 0.31, 0.22, 0.03, "Radiacion: "..radn, true) 
        guiSetFont(radi, "default-bold-small") 
        guiLabelSetColor(radi, 255, 0, 0) 
    end 
      
    function radx2() 
    local radn = getElementData(player,"Radiacion") 
        if not radn then 
            setElementData(player,"Radiacion",0) 
            destroyElement(radi) 
            setTimer(radx,500,1) 
        else 
        destroyElement(radi) 
        setTimer(radx,500,1) 
    end 
    end 
      
     ---Jugador entrando al area 
    function hill_Enter ( player, matchingDimension ) 
        if (player and getElementType(player) == "player" and matchingDimension) then 
            if radx5Timer then 
            killTimer(radx5Timer) 
            end 
            local radx4Timer = setTimer( 
            function (player) 
                radx4() 
                playSound("sounds/rad.mp3")     
                if radn and radn >= radmaxx then             
                    setElementData(player,"blood",-665) 
                end 
            end,1000,0,player)     
        end 
        end 
    addEventHandler ( "onColShapeHit", hillArea, hill_Enter) 
      
      
    -- Jugador saliendo del Area 
    function hill_Exit ( player, matchingDimension ) 
            if (player and getElementType(player) == "player" and matchingDimension) then 
                    if radx4Timer then 
                        killTimer(radx4Timer) 
                    end 
                    local radx5Timer = setTimer(radx5, 1000, 0, player) 
            end 
    end 
    addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) 
      
    function radx4() 
    setElementData(player,radn + 10) 
    end 
      
    function radx5() 
    setElementData(player,radn - 10) 
    end 

Just the same

eB2Dmcm.png

ima getting mad with this idea xD but i really want this script

haha any idea? xD my knowledge is barely not much

a little bit of java and the mta wiki xdd

Link to comment
I'll take a look at it in a bit.

Thx ,but after a check with simple01 (he made everything jeje) i was using server side functions

and after a few rechecks y get this server side code (actually i dont know what put in the client side)

radcol = createColCuboid ( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) 
radZoneRadar = createRadarArea ( 95.974617004395, 1751.3895263672, 255, 255, 91, 127, 0, 100 ) 
  
  
local nonKillables = {[287]=true,[285]=true,[193]=true,[192]=true,[191]=true,[294]=true;} 
local radmax = 300 
local player = getLocalPlayer() 
local radiationLabel 
  
function radx() 
local radn = getElementData(player,"radiacion") 
local radiationLabel = guiCreateLabel(0.01, 0.31, 0.22, 0.03, "Radiacion:"..radn, true) 
    guiSetFont(radiationLabel, "default-bold-small") 
    guiLabelSetColor(radiationLabel, 255, 255, 91) 
end 
  
function radx2() 
local radn = getElementData(player,"radiacion") 
    if not radn then 
        setElementData(player,"radiacion",0) 
        guiSetVisible(radiationLabel, false) 
        setTimer(radx,500,1) 
    else 
    guiSetVisible(radiationLabel, false) 
    setTimer(radx,500,1) 
end 
end 
setTimer(radx2,500,0) 
  
function radx4() 
setElementData(player,radn + 10) 
end 
  
function radx5() 
setElementData(player,radn - 10) 
end  
  
addEventHandler( "onColShapeHit", radcol, function(hitPlayer,player) 
    if getElementType(hitPlayer)=="player" then 
        local skin = getElementModel (hitPlayer) 
        if nonKillables[skin] then 
             radx5()  
        elseif not 
             radx4() then 
             playSound("sounds/rad.mp3") 
        elseif radn >= radmaxx then 
             setElementData(player,"blood",-1000) 
        end 
    end 
    end) 

after getting server side the guilaber works and the colo on the radar too

but no the main script ( get rad lvl )

Link to comment
  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...