Jump to content

[ASK]Informations


Guty

Recommended Posts

Hi, Im new in scripting. I would know how to count how many players in a marker (if its possible)..

And I have a taser script, i want it when i hit someone with tazer, it doesn't make damage to him..

Thanks for help.

Server Side:

local time = 1 
  
addEvent("onShot", true) 
addEventHandler("onShot", root, 
function(hitElement) 
    setElementFrozen(hitElement, true) 
    setPedAnimation(hitElement, "ped", "KO_shot_stom") 
    setTimer(setElementFrozen, time*3000, 1, hitElement, false) 
    setTimer(setPedAnimation, time*3000, 1, hitElement) 
end) 

Client Side

local eTeams = { 
    ["Police Officers"] = true, 
    ["SWAT"] = true, 
    ["FBI"] = true, 
    ["SAAF"] = true 
} 
  
addEventHandler("onClientPlayerWeaponFire", root, 
function(weapon, _, _, _, _, _, hitElement) 
    if (hitElement) and (getElementType(hitElement) == "player") and (weapon == 23) then 
        local Team = getPlayerTeam(source) 
        local TeamName = Team and getTeamName(Team) or "" 
        if (eTeams[TeamName]) then 
            outputChatBox("You have tazed "..getPlayerName(hitElement), 255, 0, 0) 
            triggerServerEvent("onShot", localPlayer, hitElement) 
        end 
    end 
end) 

Link to comment

Try this:

local eTeams = { 
    ["Police Officers"] = true, 
    ["SWAT"] = true, 
    ["FBI"] = true, 
    ["SAAF"] = true 
} 
  
addEventHandler("onClientPlayerWeaponFire", localPlayer, 
function(weapon, _, _, _, _, _, hitElement) 
    if (hitElement) and (getElementType(hitElement) == "player") and (weapon == 23) then 
        local Team = getPlayerTeam(source) 
        local TeamName = Team and getTeamName(Team) or "" 
        if (eTeams[TeamName]) then 
            outputChatBox("You have tazed "..getPlayerName(hitElement), 255, 0, 0) 
            triggerServerEvent("onShot", localPlayer, hitElement) 
        end 
    end 
end) 
  
addEventHandler("onClientPlayerDamage", localPlayer, 
function(attacker, weapon) 
    if (weapon == 23) then 
        local Team = getPlayerTeam(attacker) 
        if (Team) and (eTeams[getTeamName(Team)]) then 
            cancelEvent() 
        end 
    end 
end) 

I would know how to count how many players in a marker

Try using this function:

function getPlayerCountWithinMarker(theMarker) 
    if (theMarker) then 
        local totalPlayers = 0 
        for _, player in ipairs(getElementsByType("player")) do 
            if isElementWithinMarker(player, theMarker) then 
                totalPlayers = totalPlayers + 1 
            end 
        end 
        return totalPlayers 
    end 
    return false 
end 

Link to comment
I would know how to count how many players in a marker

Try using this function:

function getPlayerCountWithinMarker(theMarker) 
    if (theMarker) then 
        local totalPlayers = 0 
        for _, player in ipairs(getElementsByType("player")) do 
            if isElementWithinMarker(player, theMarker) then 
                totalPlayers = totalPlayers + 1 
            end 
        end 
        return totalPlayers 
    end 
    return false 
end 

This can be done in one line.

local count = #getElementsWithinColShape(getElementColShape(theMarker), "player") 

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