Jump to content

problem with DX functions


MAB

Recommended Posts

Posted (edited)

problem is that it is changing the clothes of all peds in the server :

server ;

local marker = createMarker(0,0,0) 
  
function hitmarker(hit) 
if getElementType(hit) ~= "player" then return end 
triggerClientEvent (hit,"show",hit) 
end 
addEventHandler("onMarkerHit",marker,hitmarke 

client :

  
torso = { 
{ t = "Black-Vest", x = sw*293, y = sh*136, w = sw*403, h = sh*160, c = tocolor(255,255,255,255), tex = "vestblack", mod = "vest", si = sw*0.9  } 
} 
  
addEvent("show",true) 
addEventHandler("show",root, 
function() 
addEventHandler("onClientRender",root,draw) 
addEventHandler("onClientClick",root,change) 
end 
  
function draw() 
for i = 1, #torso do 
        dxDrawText(torso[i].t, torso[i].x, torso[i].y, torso[i].w, torso[i].h, torso[i].c, torso[i].si, 'pricedown', 'left', 'top', false, false, false, false, false) 
    end 
end 
end 
  
function change (b, s, x2, y2) 
if (b == 'left' and s == 'up') then 
        for i = 1, #torso do 
            if (x >= torso[i].x and x <= torso[i].w) and (y >= torso[i].y and y <= torso[i].h) then 
                if (torso[i].tex and torso[i].mod) then 
                    addPedClothes ( source, torso[i].tex, torso[i].mod, 0 ) 
                end 
            end 
        end 
    end 
end 
  

Edited by Guest
Posted

local marker = createMarker(0,0,0) 
  
addEventHandler("onMarkerHit",marker, 
function (hit) 
if getElementType(hit) ~= "player" then return end 
triggerClientEvent (hit,"show",hit) 
end 
) 
Posted

that is making it visible to the player who hit the marker only and yes ik about it but this doesn't prevent the gui from changing all the peds clothes when one player click

Posted
that is making it visible to the player who hit the marker only and yes ik about it but this doesn't prevent the gui from changing all the peds clothes when one player click

That's because you're using source (in addPedClothes) when it is the "client's root element" and not a specific ped.

see the wiki.

Posted
i still don't know what to replace source with.. do i replace it with localPlayer?!

you can use the clickedWorld parameter, something like this:

function change ( b, s, x2, y2, _, _, _, clickedWorld ) 
if (b == 'left' and s == 'up') then 
        for i = 1, #torso do 
            if (x >= torso[i].x and x <= torso[i].w) and (y >= torso[i].y and y <= torso[i].h) then 
                if (torso[i].tex and torso[i].mod) then 
                    if clickedWorld and isElement ( clickedWorld ) and getElementType ( clickedWorld ) == "ped" then 
                        addPedClothes ( clickedWorld, torso[i].tex, torso[i].mod, 0 ) 
                    end 
                end 
            end 
        end 
    end 
end 

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