3B00DG4MER Posted March 16, 2014 Share Posted March 16, 2014 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
Dealman Posted March 16, 2014 Share Posted March 16, 2014 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
3B00DG4MER Posted March 16, 2014 Author Share Posted March 16, 2014 Not Work ,Anyone Fix it ? Link to comment
Spajk Posted March 16, 2014 Share Posted March 16, 2014 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
3B00DG4MER Posted March 16, 2014 Author Share Posted March 16, 2014 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 IIYAMA Posted March 16, 2014 Moderators Share Posted March 16, 2014 (edited) 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! Also it is a bit stupid to calculate those score at clientside. Edited March 16, 2014 by Guest Link to comment
Moderators Citizen Posted March 16, 2014 Moderators Share Posted March 16, 2014 Thank u,But when i kill someone doesn't changeplease fix it You could have fixed it yourself if you had read the code: local Bscore = 0 local Wscore = 0 Link to comment
3B00DG4MER Posted March 16, 2014 Author Share Posted March 16, 2014 Can you Tell Me please, I can't fix it Link to comment
Spajk Posted March 16, 2014 Share Posted March 16, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now