Jump to content

[TUT] 3 scripts in 1


K4stic

Recommended Posts

addCommandHandler('kill', 
        function ( player ) 
                setTimer(killPed,5000,1, player) -- then player type /kill timer start and he must wait 5 seconds to die 
                setElementFrozen( player, true) -- freeze player 
                outputChatBox(" You'll die in 5 seconds!", player, 255, 255, 255, false) 
        end 
) 
  
function unfroze(player) 
        serElementFrozen( player, false) -- unfroze player after spawn 
end 
addEventHandler("onPlayerRespawn", player, unfroze) 

Give credits to their real owners, the last part won't work ;) and you got it from Scripting subforums

Link to comment

It won't work

addCommandHandler('kill', 
        function ( player ) 
                setTimer(killPed,5000,1, player) -- then player type /kill timer start and he must wait 5 seconds to die 
                setElementFrozen( player, true) -- freeze player 
                outputChatBox(" You'll die in 5 seconds!", player, 255, 255, 255, false) 
        end 
) 
  
function unfroze() 
        setElementFrozen( source, false) 
end 
addEventHandler("onPlayerSpawn", root, unfroze) 

Link to comment
  • 2 weeks later...

Nice, I really like these scripts.

Simple and quite easy to make.

Thanks. The first 2 work fine. A few errors, but most of them still worked. I wasn't able to test the 3rd one because I didn't have a friend with me.

Also, with the drop wep script, I found it really annoying because when it creates, it creates right where you are, so I modified it so it creates 3 steps in front of you.

function drop( player, cmd, amount) 
        local x,y,z = getElementPosition( player) -- Get player pozition 
        local weapon = getPedWeapon( player ) -- get player weapon 
        local ammo = getPedTotalAmmo( player ) -- get amount of ammo who you have 
        local amount = tonumber(amount) -- get the amount 
        if ammo > amount then -- it look's if player have more ammo of that who he won drop 
                takeWeapon( player, weapon, amount) --take's the ammo for player to create pickup 
                setElementID(createPickup(x,y+3,z,2,weapon,5000,amount),"weaponpickup") -- create's pickup with element id 
                outputChatBox(" You have Droped "..amount.." Ammo for weapon : "..getWeaponNameFromID(weapid).."", player, 200, 100, 0, true) 
        else 
                outputChatBox(" You Don't Have enough Ammo in that weapon to Drop", player, 255, 0, 0, true) 
        end 
end     
addCommandHandler("drop",drop) 
  
addEventHandler("onPickupHit", root, 
function ( player ) 
        if getElementID ( source ) == "weaponpickup" then 
                local weapid = getPickupWeapon ( source ) -- get the weapon id after hit on pickup 
                local wepammo = getPickupAmmo ( source ) -- get the weapon ammo after hit on pickup 
                setTimer(destroyElement,50,1,source) -- destroy the pickup after hit 
                outputChatBox(" You pickedup "..wepammo.." Ammo for Weapon ID: "..getWeaponNameFromID(weapid).."", player, 200, 100, 0, true) 
        end 
end)    

FYI, the modification was made here:

setElementID(createPickup(x,y+3,z,2,weapon,5000,amount),"weaponpickup") -- create's pickup with element id 

So as you can see, I just added +3 to the y co-ordinate.

Also, the outputChatBox where it says how much you have dropped to the player who has dropped the ammo. That didn't work. So I fixed it and here is the fix.

outputChatBox(" You have Droped "..amount.." Ammo for weapon : "..getWeaponNameFromID(weapon).."", player, 200, 100, 0, true) 

The problem was, where I have put weapon in getWeaponNameFromID, you put weapid which is in the next function. Where as in this function, it was named weapon.

Thanks and good work.

Link to comment
  • Recently Browsing   0 members

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