MAB Posted August 10, 2015 Posted August 10, 2015 (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 August 10, 2015 by Guest
iMr.SFA7 Posted August 10, 2015 Posted August 10, 2015 local marker = createMarker(0,0,0) addEventHandler("onMarkerHit",marker, function (hit) if getElementType(hit) ~= "player" then return end triggerClientEvent (hit,"show",hit) end )
MAB Posted August 10, 2015 Author Posted August 10, 2015 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
t3wz Posted August 10, 2015 Posted August 10, 2015 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.
MAB Posted August 10, 2015 Author Posted August 10, 2015 i still don't know what to replace source with.. do i replace it with localPlayer?!
t3wz Posted August 10, 2015 Posted August 10, 2015 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
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