Jump to content

[HELP] dxdrawtext client


Wisam

Recommended Posts

I got here a script which if a player kills anyone he get extra ammo for the weapon he killed with it wokrs perfectly, and i wanted to add a small thing which is when the ammo increase a dxtext message will appear on the screen for a few seconds,

This is server side, i know i need a client side for the dxtext so i tryed to complete the function but because im new at lua i couldn't complete it:

Script:

Server

local weaponA = {  
    [22] = 17, -- Pistol 
    [23] = 17, -- Silinced Pistol 
    [24] = 7, -- Desert Eagle 
    [25] = 10, -- Shotgun 
    [27] = 7, --  SPAZ-12 Combat Shotgun 
    [29] = 30,-- MP5 
    [30] = 50, -- AK-47 
    [31] = 50, -- M4 
    [33] = 10, -- Country Rifle 
    [34] = 7 -- Sniper Rifle 
} 
  
  
function playerWasted(_, attacker, weapon) 
    if attacker and attacker ~= source and getElementType(attacker) == "player" then 
        if weaponA[weapon] then 
            giveWeapon(attacker, weapon, weaponA[weapon]) 
        end 
    end 
end 
  
addEventHandler("onPlayerWasted", root, playerWasted) 

Client:

   setTimer(  
function weaponA( ) 
    if isElement (attacker) then 
        dxDrawText("+Ammo", 823, 198, 1015, 242, tocolor(0, 0, 0, 255), 0.80, "bankgothic", "left", "top", false, false, true, false, false) 
    end 
end 
  ,3000, 1 
            ) 
  
addEventHandler("onPlayerWasted", root, playerWasted) 
  

Link to comment

You have to make it for the player who attacked, not the player who was killed:

server:

  
local weaponA = { 
    [22] = 17, -- Pistol 
    [23] = 17, -- Silinced Pistol 
    [24] = 7, -- Desert Eagle 
    [25] = 10, -- Shotgun 
    [27] = 7, --  SPAZ-12 Combat Shotgun 
    [29] = 30,-- MP5 
    [30] = 50, -- AK-47 
    [31] = 50, -- M4 
    [33] = 10, -- Country Rifle 
    [34] = 7 -- Sniper Rifle 
} 
  
  
function playerWasted(_, attacker, weapon) 
    if attacker and attacker ~= source and getElementType(attacker) == "player" then 
        if weaponA[weapon] then 
            triggerClientEvent("onAmmoTake",attacker) 
            giveWeapon(attacker, weapon, weaponA[weapon]) 
        end 
    end 
end 
  
addEventHandler("onPlayerWasted", root, playerWasted) 
  

client:

  
function weaponA( ) 
        dxDrawText("+Ammo", 823, 198, 1015, 242, tocolor(0, 0, 0, 255), 0.80, "bankgothic", "left", "top", false, false, true, false, false) 
    end 
addEvent("onAmmoTake",true) 
addEventHandler("onAmmoTake",root,weaponA) 
  

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