Jump to content

[HELP]With PED


Hero192

Recommended Posts

Hello everybody im doing a simple shop i want the PEDs be in Two places LV / LS but i failed in attacking the PEDs table to client side

Here's the part of my code:

Client side:

addEventHandler ( 'onClientClick', root, 
    function ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        if  ( clickedElement ) and ( getElementType ( clickedElement )  == 'ped' ) then 
            if  ( clickedElement == peds[shop] ) then 
                if ( guiGetVisible ( window ) == false ) then 
                    guiSetVisible ( window,true ) 
                end 
            end 
        end 
    end 
) 

--Server side:

local pedPos = { 
    {1304.8, 1254.75, 10.82}; 
    {1844.0552978516, -2640.2033691406, 13}; 
} 
local skins = {287} 
local peds = {} 
  
addEventHandler("onResourceStart",resourceRoot, 
function () 
    for i,v in pairs(pedPos) do 
        local shop = #peds + 1 
        peds[shop] = createPed(skins[math.random(#skins)],v[1],v[2],v[3]) 
        if peds[shop] then 
            setElementData(peds[shop],"shop",true) 
            setElementFrozen(peds[shop],true) 
            if v[4] then 
                setPedRotation(peds[shop],v[4]) 
            end 
        end 
    end 
     
     
         
             
end)     

Link to comment

Client:

local pedPos = { 
    {1304.8, 1254.75, 10.82}; 
    {1844.0552978516, -2640.2033691406, 13}; 
} 
local skins = {287} 
local peds = {} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        for i=1, #pedPos do 
            peds[i] = createPed(skins[math.random(1, #skins)], pedPos[i][1], pedPos[i][2], pedPos[i][3]) 
            if peds[i] then 
                setElementData(peds[i], "shop", true) 
                setElementFrozen(peds[i], true) 
                if pedPos[i][4] then 
                    setPedRotation(peds[i], pedPos[i][4]) 
                end 
            end 
        end 
    end 
) 
  
addEventHandler ( 'onClientClick', root, 
    function ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        if  ( clickedElement ) and ( getElementType ( clickedElement )  == 'ped' ) then 
            for i=1, #peds do 
                if  ( clickedElement == peds[i] ) then 
                    if ( guiGetVisible ( window ) == false ) then 
                        guiSetVisible ( window,true ) 
                    end 
                end 
            end 
        end 
    end 
) 

Link to comment

EDIT: and how can i do Table for Blips

blip = createBlip( 1303.72, 1502.84, 10.82,23,2,0, 170, 15, 255) 
blipLS = createBlip(1304.8, 1254.75, 10.82, 23,2, 0, 170, 15, 255) 
setBlipVisibleDistance (blipLS,500) 
setBlipVisibleDistance (blip,500) 

Link to comment
local blipPos = { 
    {1303.72, 1502.84, 10.82}, 
    {1304.8, 1254.75, 10.82} 
} 
local blips = {} 
  
for i=1, #blipPos do 
    blips[i] = createBlip(blipPos[i][1], blipPos[i][2], blipPos[i][3], 23, 2, 0, 170, 15, 255) 
    setBlipVisibleDistance(blips[i], 500) 
end 

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