Jump to content

What is the problem ?


Sky

Recommended Posts

i want to use the ion canon on my server, but when i press "g" , i have :

"Cannot activate ion cannon and nuke at the same time"

why ?

i have download this script for the canon ion :

--============================================================================================================== 
--Start defining varibles, including a players array 
--============================================================================================================== 
root = getRootElement () 
players = {} 
  
outputChatBox ( "Nulear Bomb by Ransom" ) 
--nuke_rotX = 0 
nuke_loops = 0 
nuke_explosionTimer = 0 
nuke_cloudRotationAngle = 0     
nuke_explosionLimiter = false 
nuke_cannonActivated = false 
nuke_cancelActivation = false 
players = getElementsByType ( "player" ) 
  
--============================================================================================================== 
--Give all players on the server access to the weapons 
--==============================================================================================================    
function ResourceStartNuke ( name, root ) 
if name ~= getThisResource() then return end 
    for k,v in ipairs ( players ) do 
    -- for all players in the "players" array 
    bindKey ( v, "g", "down", placeNukeBeacon ) 
    -- bind the key g for triggering the nuke 
    end 
end 
addEventHandler ( "onResourceStart", root, ResourceStartNuke ) 
  
function nukePlayerJoin () 
    bindKey ( source, "g", "down", placeNukeBeacon ) 
    --if a player joins after the resource loaded, bind their g key to trigger the nuke also 
end 
addEventHandler ( "onPlayerJoin", root, nukePlayerJoin ) 
  
--==================================================================================================================== 
--When the nuke key (g) is pressed, show the mouse cursor that will allow the triggering of the onPlayerClick function 
--==================================================================================================================== 
function placeNukeBeacon ( player, key, state )                                                                       
    if ( nuke_cannonActivated == false ) and ( nuke_cancelActivation == false ) and ( ion_cancelActivation == false ) and ( ion_cannonActivated == false ) then 
    --These conditions prevent triggering the same weapon twice or triggering the other weapon at the same time. 
    --Both weapons cannot be triggered because explosions are stretched to the limit, explosions would be random. 
    defineLaunchType = key 
    --This is used later on the onPlayerClick function to tell it what weapon to launch 
    showCursor ( player, true ) 
    nuke_cancelActivation = true 
    else 
        if nuke_cancelActivation == true then 
        showCursor ( player, false ) 
        end 
        --Prevents cursor from getting messed up if cursor is show for f or g and the opposite key is hit 
    nuke_cancelActivation = false 
    --nuke_cancelactivation is true when the cursor is showing. This is necessary along with asking if the actual 
    --weapon is active to prevent problems with the cursor and weapon activation between both weapons and themselves.   
            if nuke_cannonActivated == true then 
            outputChatBox ( "Nuke has already been activated", activator ) 
            else 
            outputChatBox ( "Cannot activate ion cannon and nuke at the same time", activator ) 
            end 
            --This statement says that if the nuke is already in use, display a meassage about it being in use on g press. 
            --else, if the above conditions were not satisifed and the nuke is not active, it meant the ioncannon was 
            --active. Therefore, display the other message that both weapons cannot be used at the same time. 
    end 
end 
  
--==================================================================================================================== 
--When the player clicks the mouse cursor, decide if the nuke is supposed to be launched and if so, set up the launch 
--==================================================================================================================== 
function playerClickNuke ( button, state, clickedElement, x, y, z ) 
    if defineLaunchType == "g" then 
    --If the player clicked, we check if the key is equal to f or g. This will dictate which onPlayerClick function 
    --commences between the ion cannon and nuke scripts 
    nuke_cancelActivation = false 
    --Since the weapon is now in use, you have no chance to abort by pressing the key again, therefore this is false 
    defineLaunchType = nil 
    --This must be reset to nil so it will not fire the nuke next time on click if f was pressed instead of g (which triggers ion) 
    nuke_beaconx = x 
    nuke_beacony = y 
    nuke_beaconz = z 
    --Set the nuke beacon (detonation spot) coordinates to the spot the mouse cursor clicked on the game map 
    local playerz, playerz, playerz = getElementPosition ( source ) 
    --I put a z height limit on the nuke, because the visual image of the bomb dropping can be broken if it is set 
    --to start an explosion/visually show object deletion in a mid-air point. To prevent this, I have assigned a max 
    --nuke height that is a little bit more than the z height of the player who activated it. There is a function to 
    --grab the actual z height at an X,Y position that I will implement later. For the above line, getElementPosition 
    --outputs 3 varibles, but I only want z so I overwrote 1 varible called playerz as the function went through and 
    --assigned the XYZ values to varible x, varible y, and varible z respectively. 
    nuke_maxBeamHeight = playerz + 2 
            if nuke_beaconz > nuke_maxBeamHeight then 
            nuke_beaconz = playerz + 3 
            end 
            --resets the nuke beacon z height if it is more than +3 above player z height 
                if ( button == "left" ) and ( state == "down" ) and ( nuke_cannonActivated == false ) then 
                --When the left mouse button is pressed down (not when released), if nuke is not active then 
                nuke_cannonActivated = true 
                --Set this varible to true, which will be used to avoid double launches & double weapon usage 
                showCursor ( source, false ) 
                --Weapon beacon was chosen and the launch is initiating to that point. Hide cursor. 
                setTimer ( nukeExplosion, 2700, 1 ) 
                setTimer ( nukeShot, 500, 1 ) 
                --Trigger these two functions that will drop and explode the nuke. Nuke drop triggers in 500ms, 
                --1 time only. The explosion is triggered at 2700ms which is when the nuke should be hitting 
                --the ground on the game map, it is also triggered 1 time. 
                else 
                activator = getPlayerFromNick ( source ) 
                showCursor ( source, false ) 
                --Makes sure the cursor will not show again for detonation unless the nuke is not active. Activator 
                --is used to display output messages in the other functions that activations/launches arent possible. 
                end 
    end 
end 
addEventHandler ( "onPlayerClick", root, playerClickNuke ) 
  
--============================================================================================================================= 
--Move 3 objects according to the beacon/detonation point to give the appearance of a falling nuclear bomb to the desired point 
--============================================================================================================================= 
function nukeShot () 
    nuke1 = createObject ( 16340, nuke_beaconx, nuke_beacony, nuke_beaconz + 200 ) 
    nuke2 = createObject ( 3865, nuke_beaconx + 0.072265, nuke_beacony + 0.013731, nuke_beaconz + 196.153122 ) 
    nuke3 = createObject ( 1243, nuke_beaconx + 0.060547, nuke_beacony - 0.017578, nuke_beaconz + 189.075554 ) 
    --The 3 objects that make the nucelar bomb are called nuke1, nuke2, and nuke3. Math is done to piece the 
    --bomb together correctly at any given XYZ detonation coordinates. 
    setObjectRotation ( nuke1, math.deg(3.150001), math.deg(0), math.deg(0.245437) ) 
    setObjectRotation ( nuke2, math.deg(-1.575), math.deg(0), math.deg(1.938950) ) 
    setObjectRotation ( nuke3, math.deg(0), math.deg(0), math.deg(-1.767145) ) 
    --The objects must also be rotated after they are placed in the correct XYZ positions to get the bomb shape 
    --I created in the map editor at any given XYZ beacon/detonation point. 
    shotpath = nuke_beaconz - 200 
    moveObject ( nuke1, 5000, nuke_beaconx, nuke_beacony, shotpath, 0, 0, 259.9 ) --, 259 
    moveObject ( nuke2, 5000, nuke_beaconx + 0.072265, nuke_beacony + 0.013731, shotpath - 3.846878, 0, 0, 259.9 ) 
    moveObject ( nuke3, 5000, nuke_beaconx + 0.060547, nuke_beacony - 0.017578, shotpath - 10.924446, 0, 0, 259.9 ) 
    --To make all 3 pieces of the bomb stay together in the exact same shape, they must descend directly down. 
    --nuke2 and nuke3 drop paths are altered slightly to be directly below their created positions in the air. 
end 
  
--============================================================================================================== 
--Create the imitation of a nuclear explosion 
--==============================================================================================================       
function nukeExplosion () 
    if nuke_explosionTimer == 0 then 
    --We set this value when the script started. I do so I can keep looping through this function without 
    --resetting it. 
    setTimer ( nukeExplosion, 170, 35 ) 
    --Trigger this function to initiate 35 times in 170ms intervals. 
    nuke_explosionTimer = 1 
    --Set the explosion timer flag to 1 so it is not done again with the looping (could have been true/false) 
    else 
    nuke_loops = nuke_loops + 1 
    --tells us how many times this function as been run through, which will be 35 in total. 
    r = randInt(1.5, 4.5) 
    --r will serve as our explosion radius. It can be a random value between 1.5 and 4.5 from the center of 
    --the circle. The math for this is below. 
    angleup = randInt(0, 35999)/100 
    --Choose a random angle. A value between 0 and 35999 is divided by 100 because we want 
    --to have 2 random decimal places for as well, rather than just a whole integer. 
    Explosionxcoord = r*math.cos(math.rad(angleup)) + nuke_beaconx 
    Explosionycoord = r*math.sin(math.rad(angleup)) + nuke_beacony 
    --The x and y coordinates of the explosion will occur at a max radius of 4.5 away from the nuke beacon, 
    --in a circular shape. This is a fundamental, simple circle geometry formula. 
        if nuke_loops == 1 then 
        nuke_nukeCloud = nuke_beaconz 
        createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 ) 
        elseif nuke_loops == 2 then 
        nuke_nukeCloud = nuke_beaconz + 4 
        createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 ) 
        --Up until 20 loops, a pillar of explosions is created with the above. 7 is the explosion type, 
        --which is tied with a couple others as the largest. 7 is a aircraft explosion. 
        elseif nuke_loops > 20 then 
        nuke_cloudRotationAngle = nuke_cloudRotationAngle + 22.5   
            if nuke_explosionLimiter == false then 
            nuke_cloudRadius = 7 
            Explosionxcoord = nuke_cloudRadius*math.cos(math.rad(nuke_cloudRotationAngle)) + nuke_beaconx --recalculate 
            Explosionycoord = nuke_cloudRadius*math.sin(math.rad(nuke_cloudRotationAngle)) + nuke_beacony --recalculate     
            createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 ) 
            nuke_explosionLimiter = true 
            elseif nuke_explosionLimiter == true then 
            nuke_explosionLimiter = false 
            end     
        nuke_cloudRadius2 = 16   
        Explosionxcoord2 = nuke_cloudRadius2*math.cos(math.rad(nuke_cloudRotationAngle)) + nuke_beaconx 
        Explosionycoord2 = nuke_cloudRadius2*math.sin(math.rad(nuke_cloudRotationAngle)) + nuke_beacony             
        createExplosion ( Explosionxcoord2, Explosionycoord2, nuke_nukeCloud, 7 ) 
        else 
        nuke_nukeCloud = nuke_nukeCloud + 4 
        createExplosion ( Explosionxcoord, Explosionycoord, nuke_nukeCloud, 7 ) 
        end  
        --Since explosions are pushed to the limit, I have to make sure I can use the maximum amount without 
        --having explosions not appear. This required me to have the above explosions run every other time 
        --to create a mushroom cloud inner part (a circular area defined above), while at the same time creating 
        --an outter circle that also gave the look of a "full" mushroom cloud that won't have obvious visual holes. 
            if nuke_loops == 1 then 
            --On the first loop, the bright flare (as I call it, actually a corona marker), is created and increases in size.   
            nukeExplosionFlare = createMarker ( nuke_beaconx, nuke_beacony, nuke_beaconz, "corona", 0, 255, 255, 255, 255 ) 
            --The flare has an inital size of 0, and the R, G, B colors are 255, making it white.       
            nuke_flareSize = 0 
            setTimer ( nukeFlareGrow, 1, 200 ) 
            --On the first loop, set the nuke_flareSize varible to 0, which will dictate the flare (corona) size 
            --in the nukeFlareGrow function below as it is looped. The timer initiates the function 200 times, 
            --every 1ms (so it takes 1/5 of a second to loop 200 times, thus making the bright flare). 
            elseif nuke_loops == 35 then 
            nuke_explosionTimer = 0 
            setTimer ( nukeFlareFade, 1, 200 ) 
            nuke_loops = 0              
            end 
                --When this function has looped 35 times, the nuke has finished exploding and the flare must begin 
                --fading to look like it disappears naturally. Nuke loops is reset for the next nuke launch. 
    end 
end 
  
function nukeFlareGrow () 
        setMarkerSize ( nukeExplosionFlare, nuke_flareSize ) 
        nuke_flareSize = nuke_flareSize + 1 
            if nuke_flareSize == 200 then 
            destroyElement ( nuke1 ) 
            destroyElement ( nuke2 ) 
            destroyElement ( nuke3 ) 
            end 
            --The flare becomes +1 larger on each loop, and the nuke is destroyed when the flare reaches maximum 
            --size. It is triggered here as this is the point where it is safest to assume the objects are out of site. 
end 
  
function nukeFlareFade () 
    nuke_flareSize = nuke_flareSize - 1 
    setMarkerSize ( nukeExplosionFlare, nuke_flareSize ) 
    if nuke_flareSize == 0 then 
    destroyElement ( nukeExplosionFlare ) 
    nuke_cannonActivated = false 
    end 
    --Each time the function loops, the flare gets -1 smaller. When it has a size of 0 and becomes invisible, it needs 
    --to be deleted for the next nuke launch. No elements should stay created as they will pile up and eventually 
    --crash you or the server. Finally, nuke_cannonActivated is false, meaning the nuke is inactive and another weapon 
    --use can be performed. 
end 

what is the problem ?

Thx .

Link to comment

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...