Jump to content

[UnSolved]Kill System


3B00DG4MER

Recommended Posts

Hello,I made today script which Show team Score On Any Player Die

But The Dx doesn't Show when Any one die

Please fix (I removed Some Codes[To Protect My Script])

    local team = getPlayerTeam(player) 
    local Bscrore = "0" 
    local Wscrore = "0" 
  
  
  
     
function onWasted(killer, weapon, bodypart) 
    if team == "WhiteTeam" or "BlackTeam" then 
    dxDrawText("Black Team:"..Bscore, 0, 500, 319, 426, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
    dxDrawText("White Team:"..Wscore, 0, 600, 319, 426, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
    end 
 local kteam = getPlayerTeam( killer ) 
 if kteam == "WhiteTeam" then 
     Wscore = Wscore+1 
     else 
     Bscore = Bscore+1 
     end 
     end 
      
addEventHandler("onClientPedWasted", getRootElement(), onWasted) 
  
  

Link to comment

Try something like this;

(Untested);

local team = getPlayerTeam(localPlayer) 
local Bscrore = "0" 
local Wscrore = "0" 
  
function onWasted(killer, weapon, bodypart) 
    -- You were trying to compare a team element to a string, get the team name instead. 
    if((getTeamName(team) == "WhiteTeam") or ("BlackTeam")) then 
    -- You were trying to concatenate Bscore and Wscore which would have been converted to an integer when a ped got wasted. Convert it to a string. 
        dxDrawText("Black Team:"..tostring(Bscore), 0, 500, 319, 426, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
        dxDrawText("White Team:"..tostring(Wscore), 0, 600, 319, 426, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
    end 
    local kteam = getPlayerTeam(killer) 
    -- You were trying to compare a team element to a string, get the team name instead. 
    if(getTeamName(kteam) == "WhiteTeam") then 
        Wscore = Wscore+1 
    else 
        Bscore = Bscore+1 
    end 
end 
addEventHandler("onClientPedWasted", getRootElement(), onWasted) 

Link to comment
  
local Bscrore = 0 
local Wscrore = 0 
  
function onWasted(killer, weapon, bodypart) 
    local kteam = getPlayerTeam(killer) 
     
    if(getTeamName(kteam) == "WhiteTeam")then 
        Wscore = Wscore + 1 
    elseif(getTeamName(kteam) == "BlackTeam") 
        Bscore = Bscore + 1 
    end 
end 
addEventHandler("onClientPedWasted", getRootElement(), onWasted) 
  
function onRender() 
    local team = getPlayerTeam(localPlayer) 
  
    if(getTeamName(team) == "WhiteTeam" or getTeamName(team) == "BlackTeam") then 
        dxDrawText("Black Team:"..tostring(Bscore), 0, 500, 319, 426, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
        dxDrawText("White Team:"..tostring(Wscore), 0, 600, 319, 426, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
    end 
end 
  
addEventHandler("onClientRender", root, onRender) 
  

It wont work well because of late joining.

Link to comment
  
local Bscrore = 0 
local Wscrore = 0 
  
function onWasted(killer, weapon, bodypart) 
    local kteam = getPlayerTeam(killer) 
     
    if(getTeamName(kteam) == "WhiteTeam")then 
        Wscore = Wscore + 1 
    elseif(getTeamName(kteam) == "BlackTeam") 
        Bscore = Bscore + 1 
    end 
end 
addEventHandler("onClientPedWasted", getRootElement(), onWasted) 
  
function onRender() 
    local team = getPlayerTeam(localPlayer) 
  
    if(getTeamName(team) == "WhiteTeam" or getTeamName(team) == "BlackTeam") then 
        dxDrawText("Black Team:"..tostring(Bscore), 0, 500, 319, 426, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
        dxDrawText("White Team:"..tostring(Wscore), 0, 600, 319, 426, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
    end 
end 
  
addEventHandler("onClientRender", root, onRender) 
  

It wont work well because of late joining.

Thank u,But when i kill someone doesn't change

please fix it

Link to comment
  • Moderators
local Bscore = 0 --typo: Bscrore 
local Wscore = 0 --typo: Wscrore 
  
function onWasted(killer, weapon, bodypart) 
    if killer and getElementType(killer) == "player" then 
        local kteam = getPlayerTeam(killer) 
         
        if kteam then -- < first check if he is in a team 
         
            if(getTeamName(kteam) == "WhiteTeam")then 
                Wscore = Wscore + 1 
            elseif(getTeamName(kteam) == "BlackTeam") then -- you forgot a "then" 
                Bscore = Bscore + 1 
            end 
        end 
    end 
end 
addEventHandler("onClientPedWasted", root, onWasted) 
  
function onRender() 
    local team = getPlayerTeam(localPlayer) 
     
    if team then -- < first check if you are in a team 
     
        if(getTeamName(team) == "WhiteTeam" or getTeamName(team) == "BlackTeam") then 
            dxDrawText("Black Team:".. Bscore, 0, 500, 319, 426, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
            dxDrawText("White Team:".. Wscore, 0, 600, 319, 426, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
        end 
    end 
end 
  
addEventHandler("onClientRender", root, onRender) 

Next time use /debugscript 3! :roll:

Also it is a bit stupid to calculate those score at clientside.

Edited by Guest
Link to comment
local Bscore = 0 
local Wscore = 0 
  
function onWasted(killer, weapon, bodypart) 
    local kteam = getPlayerTeam(killer) 
    
    if(getTeamName(kteam) == "WhiteTeam")then 
        Wscore = Wscore + 1 
    elseif(getTeamName(kteam) == "BlackTeam") 
        Bscore = Bscore + 1 
    end 
end 
addEventHandler("onClientPedWasted", getRootElement(), onWasted) 
  
function onRender() 
    local team = getPlayerTeam(localPlayer) 
  
    if(getTeamName(team) == "WhiteTeam" or getTeamName(team) == "BlackTeam") then 
        dxDrawText("Black Team:"..tostring(Bscore), 0, 500, 319, 426, tocolor(0, 0, 0, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
        dxDrawText("White Team:"..tostring(Wscore), 0, 600, 319, 426, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "center", true, true, true, true, false) 
    end 
end 
  
addEventHandler("onClientRender", root, onRender) 

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