Jump to content

question


WASSIm.

Recommended Posts

hi guys how make this restart to 30 sec

"pick_rus,editor_main"> 
    "groundweapon (1)" weaponid="22" ammo="100" clip="0" posX="2195" posY="1685.59998" posZ="11.5" rotX="90" rotY="0" rotZ="0">
    "groundweapon (2)" weaponid="25" ammo="100" clip="0" posX="2195" posY="1683.40002" posZ="11.5" rotX="90" rotY="0" rotZ="0">
    "groundweapon (3)" weaponid="29" ammo="100" clip="0" posX="2195" posY="1681.19995" posZ="11.5" rotX="90" rotY="0" rotZ="0">

Link to comment

but this that like pickup and i have problem 2 to script

if restart script not working again (i can't take and hide pickups to xml)

CLIENT

screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution 
shrifteg = (0.015 * screenHeight) / 9
localPlayer = getLocalPlayer()
currentGround = nil
elementgg = {}
gta4markers = true
 
weaponmarkercolors = {
    [0] = {255,0,0},
    [1] = {0,255,0},
    [2] = {0,0,0},
}
 
slots = {
    [1] = 0,
    [2] = 0,[3] = 0,[4] = 0,[5] = 0,[6] = 0,[7] = 0,[8] = 0,[9] = 0,
    [24] = 0,[23] = 0,[22] = 0,
    [25] = 0,[26] = 0,[27] = 0,
    [29] = 0,[32] = 0,[28] = 0,
    [30] = 0,[31] = 0,
    [33] = 0,[34] = 0,
    [35] = 0,[36] = 0,[37] = 0,[38] = 0,
    [16] = 0,[17] = 0,[18] = 0,[39] = 0,
    [41] = 0,[42] = 0,[43] = 0,
    [10] = 0,[11] = 0,[12] = 0,[13] = 0,[14] = 0,[15] = 0,
    [44] = 0,[45] = 0,[46] = 0,
    [40] = 0
}
 
weaponsIDS = {
    --0
    [1] = 331,
    --1
    [2] = 333,
    [3] = 334,
    [4] = 335,
    [5] = 336,
    [6] = 337,
    [7] = 338,
    [8] = 339,
    [9] = 341,
    --2
    [22] = 346,
    [23] = 347,
    [24] = 348,
    --3
    [25] = 349,
    [26] = 350,
    [27] = 351,
    --4
    [28] = 352,
    [29] = 353,
    [32] = 372,
    --5
    [30] = 355,
    [31] = 356,
    --6
    [33] = 357,
    [34] = 358,
    --7
    [35] = 359,
    [36] = 360,
    [37] = 361,
    [38] = 362,
    --8
    [16] = 342,
    [17] = 343,
    [18] = 344,
    [39] = 363,
    --9
    [41] = 365,
    [42] = 366,
    [43] = 367,
    --10
    [10] = 321,
    [11] = 322,
    [12] = 323,
    [13] = 324,
    [14] = 325,
    [15] = 326,
    --11
    [44] = 368,
    [45] = 369,
    [46] = 371,
    --12
    [40] = 364
}
 
function client_createGroundWeapon(groundweapon)
    if(elementgg[groundweapon] == nil) then
        local temp = createColSphere(tonumber(getElementData(groundweapon, "posX")),tonumber(getElementData(groundweapon, "posY")),tonumber(getElementData(groundweapon, "posZ"))+0.5, 1)
        --[[local temp = createColCuboid(tonumber(getElementData(groundweapon, "posX"))-0.5,
        tonumber(getElementData(groundweapon, "posY"))-0.5,
        tonumber(getElementData(groundweapon, "posZ"))-1,
        1,1,2)]]
       
        setElementData(temp, "colshape.groundweapon", groundweapon)
        setElementData(temp, "colshape.weaponid", tonumber(getElementData(groundweapon, "weaponid")))
        setElementData(temp, "colshape.ammo", tonumber(getElementData(groundweapon, "ammo")))
        setElementData(temp, "colshape.clip", tonumber(getElementData(groundweapon, "clip")))
        elementgg[groundweapon] = temp
        local slot = slots[tonumber(getElementData(groundweapon, "weaponid"))]
 
        --createObject
        local object = createObject(weaponsIDS[tonumber(getElementData(groundweapon, "weaponid"))],
        tonumber(getElementData(groundweapon, "posX")),tonumber(getElementData(groundweapon, "posY")),tonumber(getElementData(groundweapon, "posZ")),
        tonumber(getElementData(groundweapon, "rotX")),tonumber(getElementData(groundweapon, "rotY")),tonumber(getElementData(groundweapon, "rotZ")))
        setObjectStatic(object, true)
        setElementCollisionsEnabled(object, false)
 
        setElementInterior(object, tonumber(getElementData(groundweapon, "interior")))
        setElementDimension(object, tonumber(getElementData(groundweapon, "dimension")))
       
        setElementData(temp, "colshape.object", object)
 
        --createMarker
        local marker = createMarker(tonumber(getElementData(groundweapon, "posX")),
        tonumber(getElementData(groundweapon, "posY")),
        tonumber(getElementData(groundweapon, "posZ")),
        "corona", 1, weaponmarkercolors[slot][1],weaponmarkercolors[slot][2], weaponmarkercolors[slot][3], 70)
 
        setElementInterior(marker, tonumber(getElementData(groundweapon, "interior")))
        setElementDimension(marker, tonumber(getElementData(groundweapon, "dimension")))
           
        setElementData(temp, "colshape.marker", marker)
 
        local x,y,z = getElementPosition(localPlayer)
        if(getDistanceBetweenPoints2D(x,y,tonumber(getElementData(groundweapon, "posX")),tonumber(getElementData(groundweapon, "posY"))) < 0.25) then local_activate(temp, localPlayer,true) end
    end
end
 
function client_destroyGroundWeapon(groundweapon)
    local col = elementgg[groundweapon]
    local object = getElementData(col, "colshape.object")
    local marker = getElementData(col, "colshape.marker")
    if(isElement(object)) then destroyElement(object) end
    if(isElement(marker)) then destroyElement(marker) end
    if(isElement(col)) then destroyElement(col) end
    elementgg[groundweapon] = nil
end
 
function pickupCurrentWeapon()
    if(isElement(currentGround)) then
        local weaponid = getElementData(currentGround, "colshape.weaponid")
        local ammo = getElementData(currentGround, "colshape.ammo")
        local clip = getElementData(currentGround, "colshape.clip")
 
        if(getPedWeapon(localPlayer, slots[weaponid]) ~= 0) then dropWeapon(slots[weaponid]) end
       
        if(ammo) then
            local groundweapon = getElementData(currentGround, "colshape.groundweapon")
            callServerFunction("destroyElement", groundweapon)
            callServerFunction("giveWeapon", localPlayer, weaponid, ammo, true)
            callServerFunction("setWeaponAmmo", localPlayer, weaponid, ammo, clip)
            for i,p in ipairs(getElementsByType("colshape")) do
                if(isElementWithinColShape(localPlayer, p) == true) then
                    local_activate(p, localPlayer,true)
                    break
                end
            end
        end
    end
end
 
function dropWeapon(slot)
    if(slot > 0) then
        local weaponid = getPedWeapon(localPlayer, slot)
        if(weaponid ~= 0) then
            callServerFunction("takeWeapon", localPlayer, weaponid)
            local x,y,z = getElementPosition(localPlayer)
            local hit, hitX, hitY, hitZ, as = processLineOfSight(x, y, z, x, y, -3000, true, false, false, true, false, false, false, false)
            if(hit) then z = hitZ
            else z = z - 0.95 end
            callServerFunction("createGroundWeapon", weaponid, getPedTotalAmmo(localPlayer), getPedAmmoInClip(localPlayer), x,y,z, 97.3,120,math.random(0,359),getElementInterior(localPlayer),getElementDimension(localPlayer))
        end
    end
end
 
function local_activate(shape, element,dimension)
    if(element == localPlayer) then
        --local groundweapon = getElementData(shape, "colshape.groundweapon")
        --local object = getElementData(shape, "colshape.object")
        --local marker = getElementData(shape, "colshape.marker")
        curreound = shape
    end
end
 
addEventHandler("onClientResourceStart", root,
    function(startedRes)
        if(startedRes == getThisResource()) then
            bindKey("tab", "down", "pickup/swap weapon")
            bindKey("b", "down", "drop weapon")
        else
            for i,p in pairs(getElementsByType("groundweapon")) do --getResourceRootElement(startedRes)
                client_createGroundWeapon(p)
            end
        end
    end
)
 
addEventHandler("onClientResourceStop", getResourceRootElement(),
    function(startedRes)
        for i,p in pairs(getElementsByType("groundweapon")) do
            client_destroyGroundWeapon(p)
        end
    end
)
 
addEventHandler("onClientPlayerWasted", localPlayer,
    function()
        dropWeapon(getPedWeaponSlot(localPlayer))
    end
)
 
addEventHandler("onClientElementDestroy", getRootElement(),
    function()
        if(getElementType(source) == "groundweapon") then
            client_destroyGroundWeapon(source)
        end
    end
)
 
addEventHandler("onClientColShapeHit", getResourceRootElement(),
    function(element,dimension)
        local_activate(source, element,dimension)
    end
)
 
addEventHandler("onClientColShapeLeave", getResourceRootElement(),
    function(element,dimension)
        if(element == localPlayer) then
            currentGround = nil
            for i,p in ipairs(getElementsByType("colshape")) do
                if(isElementWithinColShape(localPlayer, p) == true) then
                    local_activate(p, localPlayer,true)
                    break
                end
            end
        end
    end
)
 
addCommandHandler("pickup/swap weapon", function() pickupCurrentWeapon() end)
 
addCommandHandler("drop weapon", function() dropWeapon(slots[getPedWeapon(localPlayer)]) end)
 
function callServerFunction(funcname, ...)
    local arg = { ... }
    if (arg[1]) then
        for key, value in next, arg do
            if (
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...