Jump to content

Need Help


Recommended Posts

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

try this:
addEventHandler("onClientGUIClick"GridlOwnerCar,function(button) 
    if(button)then 
        local rowindex, columnindex = guiGridListGetSelectedItem ( GridlOwnerCar ) 
        local carname = guiGridListGetItemText ( GridlOwnerCar, rowindex, columnindex) 
        triggerServerEvent("PCar", localPlayer, carname) 
    end 
end,false) 
  
addEvent("Pincar",true) 
addEventHandler("PinCar",root,function(carname) 
    if(carname=="")then 
        for i,cars in ipairs(getElementsByType("vehicle")) do 
            for c,vehicle in ipairs(getVehicleModelFromName(carname)) do 
                createBlipAttachedTo(vehicle,0,3,0,0,0,0,0,65535,client) 
            end 
        end 
    end 
end 

This makes no-sense equal to mine. But mine isn't too bad :D

Link to comment
ok, can you tell us what you want specifically?

try this:

addEventHandler("onClientGUIClick",GridlOwnerCar,function(button) 
    if(button=="left")then 
        local rowindex, columnindex = guiGridListGetSelectedItem ( GridlOwnerCar ) 
        local carname = guiGridListGetItemText ( GridlOwnerCar, rowindex, columnindex) 
        triggerServerEvent("PCar", localPlayer, carname) 
    end 
end,false) 
  
addEvent("PCar",true) 
addEventHandler("PCar",root,function(carname) 
    if(carname=="")then 
        for i,cars in ipairs(getElementsByType("vehicle")) do 
            for c,vehicle in ipairs(getVehicleModelFromName(carname)) do 
                createBlipAttachedTo(vehicle,0,3,0,0,0,0,0,65535,client) 
            end 
        end 
    end 
end 

Edited by Guest
Link to comment

srry, about the other code, try this:

-- Client-side 
addEventHandler("onClientGUIClick",GridlOwnerCar,function(button) 
    if(button=="left")then 
        local rowindex, columnindex = guiGridListGetSelectedItem ( GridlOwnerCar ) 
        local carname = guiGridListGetItemText ( GridlOwnerCar, rowindex, columnindex) 
        triggerServerEvent("PCar", localPlayer, carname) 
    end 
end,false) 
  
-- Server-side 
addEvent("PCar",true) 
addEventHandler("PCar",root,function(carname) 
    if(carname=="")then 
        for i,cars in ipairs(getElementsByType("vehicle")) do 
            if(getVehicleName(cars)==carname)then 
                createBlipAttachedTo(cars,0,3,0,0,0,0,0,65535,client) 
            end 
        end 
    end 
end) 

Edited by Guest
Link to comment
srry, about the other code, try this:
addEventHandler("onClientGUIClick",GridlOwnerCar,function(button) 
    if(button=="left")then 
        local rowindex, columnindex = guiGridListGetSelectedItem ( GridlOwnerCar ) 
        local carname = guiGridListGetItemText ( GridlOwnerCar, rowindex, columnindex) 
        triggerServerEvent("PCar", localPlayer, carname) 
    end 
end,false) 
  
addEvent("PCar",true) 
addEventHandler("PCar",root,function(carname) 
    if(carname=="")then 
        for i,cars in ipairs(getElementsByType("vehicle")) do 
            if(getVehicleName(cars)==carname)then 
                createBlipAttachedTo(cars,0,3,0,0,0,0,0,65535,client) 
            end 
        end 
    end 
end) 

lol

if(carname=="")then 

should be

if(carname ~= "")then 

Link to comment
source used in events ( client side and server side ). client used only in server side events and
client: the client that triggered the event using triggerServerEvent. Not set if the event was not triggered from a client.

https://wiki.multitheftauto.com/wiki/AddEventHandler

https://wiki.multitheftauto.com/wiki/Event_system

https://wiki.multitheftauto.com/wiki/Client

so for example if we attach the trigger to root there will be no source and to know who was the client trigger we use client variable

addCommandHandler("name", 
function() 
    triggerServerEvent("onGreeting",root)  
end) 

addEvent("onGreeting", true) 
addEventHandler("onGreeting", root 
function() 
    outputChatBox("The client name is: "..getPlayerName(client)) 
end) 

also if we use localPlayer Instead of root the source will be the localPlayer and client will be the same as localPlayer

and here source is the same client (source == client)

so we can use source and we can use client no difference

addEventHandler("onClientGUIClick",GridlOwnerCar,function(button) 
    if(button=="left")then 
        local rowindex, columnindex = guiGridListGetSelectedItem ( GridlOwnerCar ) 
        local carname = guiGridListGetItemText ( GridlOwnerCar, rowindex, columnindex) 
        triggerServerEvent("PCar", localPlayer, carname) 
    end 
end,false) 
  
addEvent("PCar",true) 
addEventHandler("PCar",root,function(carname) 
    if(carname ~= "")then 
        for i,cars in ipairs(getElementsByType("vehicle")) do 
            if(getVehicleName(cars)==carname)then 
                createBlipAttachedTo(cars,0,3,0,0,0,0,0,65535,client) 
            end 
        end 
    end 
end) 

Link to comment
yes i add it but still don't work :(:(

what is not work?

does the vehicle exist?

yes it exist when i buy a car it show in gridlist i want when i go to ather player and open gui and select my car from grid and click on Blip button it show on the radar that what i want .

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