TorNix~|nR Posted December 18, 2017 Posted December 18, 2017 Hello guys, I have a draw text when a player wasted, it's like GTA V but I have a little problem, it shows only when a player dead or someone (player) killed him, but the ped no (like zombies) it doesn't show the text, I tried so many attempts, please help --- Script local TIME_TO_WAIT = 9000 --The milliseconds to wait before spectating the person --who killed us, the :O local KILLER_TEXT_COLOR = tocolor(255, 255, 255, 200) local KILL_TEXT_X = 0.5 --Where the text starts to the left of the screen local KILL_TEXT_Y = 0.535 --How far down the screen comes before we have text local KILL_TEXT_COLOR = tocolor(255, 255, 255, 200) --The color of the text local KILL_TEXT_SIZE = 1.5 --The size of our text local KILL_TEXT_FONT = "font/ARLRDBD.ttf" --The font face of our text local KILL_TEXT_ALIGN_X = "center" --The font alignment on the x axis local KILL_TEXT_ALIGN_Y = "center" --The font alignment on the y axis local KILL_TEXT_CLIP = false --Clip text outside of box local KILL_TEXT_WRAP = false --Wrap text if it reaches end of box local KILL_TEXT_ONTOP = true --Render on top of the gui local WASTED_TEXT_X = 0.5 --Where the text starts to the left of the screen local WASTED_TEXT_Y = 0.5 --How far down the screen comes before we have text local WASTED_TEXT_COLOR = tocolor(255, 0, 0, 200) --The color of the text local WASTED_TEXT_SIZE = 2.5 --The size of our text local WASTED_TEXT_FONT = "pricedown" --The font face of our text local WASTED_TEXT_ALIGN_X = "center" --The font alignment on the x axis local WASTED_TEXT_ALIGN_Y = "center" --The font alignment on the y axis local WASTED_TEXT_CLIP = false --Clip text outside of box local WASTED_TEXT_WRAP = false --Wrap text if it reaches end of box local WASTED_TEXT_ONTOP = true --Render on top of the gui function playerDied(killer, weapon, bodypart) wastedSound() local playerX, playerY, playerZ = getElementPosition(source) displayKillText(getKillString(source, killer, weapon, bodypart)) local spectate if killer then local killerX, killerY, killerZ = getElementPosition(killer) spectate = killer else end end addEventHandler("onClientPlayerWasted", getLocalPlayer(), playerDied) function getKillString(player, killer, ped, weapon, bodypart) local killText = "" if player then killText = killText .. "" end --if if killer then killText = getPlayerName(killer) .. " killed you" else killText = killText .. " commit suicide " end if weapon then local weapName = getWeaponNameFromID(weapon) if weapname ~= false then end end return killText end local killText = "" function displayKillText(text) killText = text addEventHandler("onClientRender", getRootElement(), drawKillText) setTimer(stopDisplayDrawKillText, TIME_TO_WAIT, 1) end function stopDisplayDrawKillText() removeEventHandler("onClientRender", getRootElement(), drawKillText) end function drawKillText() local sX, sY = guiGetScreenSize() local left, top left = KILL_TEXT_X * sX top = KILL_TEXT_Y * sY dxDrawText(killText, left, top, left, top, KILL_TEXT_COLOR, KILL_TEXT_SIZE, KILL_TEXT_FONT, KILL_TEXT_ALIGN_X, KILL_TEXT_ALIGN_Y, KILL_TEXT_CLIP, KILL_TEXT_WRAP, KILL_TEXT_ONTOP) left = WASTED_TEXT_X * sX top = WASTED_TEXT_Y * sY dxDrawBorderedText("You are dead", left, top, left, top, WASTED_TEXT_COLOR, WASTED_TEXT_SIZE, WASTED_TEXT_FONT, WASTED_TEXT_ALIGN_X, WASTED_TEXT_ALIGN_Y, WASTED_TEXT_CLIP, WASTED_TEXT_WRAP, WASTED_TEXT_ONTOP) end function dxDrawBorderedText( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) dxDrawText ( text, x - 1, y - 1, w - 1, h - 1, tocolor ( 0, 0, 0, 155 ), scale, font, alignX, alignY, clip, wordBreak, false ) -- black dxDrawText ( text, x + 1, y - 1, w + 1, h - 1, tocolor ( 0, 0, 0, 155 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x - 1, y + 1, w - 1, h + 1, tocolor ( 0, 0, 0, 155 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + 1, y + 1, w + 1, h + 1, tocolor ( 0, 0, 0, 155 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x - 2, y, w - 2, h, tocolor ( 0, 0, 0, 155 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + 2, y, w + 2, h, tocolor ( 0, 0, 0, 155 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y - 2, w, h - 2, tocolor ( 0, 0, 0, 155 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y + 2, w, h + 2, tocolor ( 0, 0, 0, 155 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) end function wastedSound() if true then local wasted = playSound("wasted.mp3"); setSoundVolume(sound, 0.1); end end -- OLD Film local screenWidth, screenHeight = guiGetScreenSize() local myScreenSource = dxCreateScreenSource(screenWidth, screenHeight) local flickerStrength = 0 addEventHandler("onClientPlayerWasted", getLocalPlayer(), function() if getVersion ().sortable < "1.1.0" then return else createShader() end end) function createShader() oldFilmShader, oldFilmTec = dxCreateShader("shaders/old_film.fx") setTimer(function() destroyElement(oldFilmShader) end, 9000, 1) if (not oldFilmShader) then else end end function updateShader() upDateScreenSource() if (oldFilmShader) then local flickering = math.random(100 - flickerStrength, 100)/100 dxSetShaderValue(oldFilmShader, "ScreenSource", myScreenSource); dxSetShaderValue(oldFilmShader, "Flickering", flickering); dxDrawImage(0, 0, screenWidth, screenHeight, oldFilmShader) end end addEventHandler("onClientPreRender", root, updateShader) function upDateScreenSource() dxUpdateScreenSource(myScreenSource) end -- Tarja function showClientImage() local img = guiCreateStaticImage( 0, 0, 1921, 221, "starja.png", true ) setTimer(function() destroyElement(img) end, 9000, 1) local img = guiCreateStaticImage( 0, 0, 1920, 1080, "images/vignette1.dds", true ) setTimer(function() destroyElement(img) end, 9000, 1) end addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), showClientImage) ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003
DRW Posted December 19, 2017 Posted December 19, 2017 (edited) if killer then killText = getPlayerName(killer) .. " killed you" else killText = killText .. " commit suicide " end Here, you're trying to get the player name of the killer, you can't get the player name of a ped, obviously. Try using this: if killer and isElement (killer) then if getElementType(killer)=="player" then killText = getPlayerName(killer) .. " killed you" elseif getElementType (killer)=="ped" and getElementData (killer,"zombie") then killText = "A zombie killed you" elseif killer == localPlayer then killText = "You've committed suicide." else killText = "You've died." end else killText = "You've died." end And by the way, that sure had given you a debugscript error, next time, try to analyze those errors and post something related to it so people shouldn't have to read your entire script just to get into context. Edited December 19, 2017 by MadnessReloaded 1 Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
TorNix~|nR Posted December 19, 2017 Author Posted December 19, 2017 Thank you so much, it's working fine ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003
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