GrubaS Posted June 17, 2015 Share Posted June 17, 2015 (edited) Hello, guys I have no idea how to fix it i want make on chatbox example. "Terrorist Died! (killed by Terrorist2)" its destruction derby script please help clinet side: function gowmo(name) killerss = getPlayerName(getElementData(getPlayerName(getLocalPlayer()),"lasthit")) alivePlayers = 0 for i ,v in ipairs (getElementsByType("player")) do if getElementData(v,"state") == "alive" then alivePlayers = alivePlayers + 1 end end if alivePlayers == 1 then setElementData(getPlayerFromPartialName(name),"lasthit",nil) end local team = getPlayerTeam(source) local r,g, b = getTeamColor(team) local hex = RGBToHex (r, g, b) outputChatBox("*"..hex..""..getPlayerName(source):gsub("#%x%x%x%x%x%x","").." #FF6060died!"..killerss, 255, 96, 96, true) end addEventHandler("onClientPlayerWasted",getRootElement(), gowmo) function RGBToHex(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return nil end if(alpha) then return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) else return string.format("#%.2X%.2X%.2X", red,green,blue) end end addEventHandler("onClientVehicleCollision",root, function(hitElement) if source == getPedOccupiedVehicle(localPlayer) then if hitElement and getElementType(hitElement) == 'vehicle' then local driver = getVehicleController(source) local hDriver = getVehicleController(hitElement) if hDriver and driver then setElementData(driver,"lasthit",hDriver) if isTimer(timer) then killTimer(timer) end timer = setTimer(setElementData,5000,1,driver,"lasthit",nil) end end end end ) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Debugscript 3 Lines,2:bad argument 'getelementdata' [Expecnted element at argument 1, got string 'Terrorist'] Lines,2: bad argument 'getelementdata' [Expected element at argument 1, got nil] Linse,10: bad argument 'getplayername'[Expected element at argument 1, got nil] Linse, 10: attempt to concatenate global 'killerss'(a boolean value) Edited June 17, 2015 by Guest Link to comment
mommytellme Posted June 17, 2015 Share Posted June 17, 2015 Name the functions better than "gówno" because otherwise in the end you start to get lost in your code Link to comment
ALw7sH Posted June 17, 2015 Share Posted June 17, 2015 you have to put an element on setElementData not player name Link to comment
GrubaS Posted June 18, 2015 Author Share Posted June 18, 2015 you have to put an element on setElementData not player name I tried that killerss = getPlayerName(getElementData(getPlayerFromPartialName(name),"lasthit")) but still doesnt work ;x Link to comment
ALw7sH Posted June 18, 2015 Share Posted June 18, 2015 Line 2 killerss = getPlayerName(getElementData(getLocalPlayer(),"lasthit")) also the first parameter isn't player name it's the player element itself you should think about rewrite your code and read the wiki page of any function or event you'll use 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