Jaysds1 Posted April 6, 2012 Share Posted April 6, 2012 Sorry, you can't, you can only attach blips to elements that are already on the map/server. I thought you wanted to make a blip for every vehicle that has that name, srry. Link to comment
drk Posted April 6, 2012 Share Posted April 6, 2012 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 Link to comment
sckatchof Posted April 6, 2012 Author Share Posted April 6, 2012 thanks for help but still don't work Link to comment
Jaysds1 Posted April 6, 2012 Share Posted April 6, 2012 ok, can you tell us what you want specifically? Link to comment
sckatchof Posted April 6, 2012 Author Share Posted April 6, 2012 ok, can you tell us what you want specifically? i want when i select a car from grid list and i press on button 'Blip' it show on the radar Link to comment
Jaysds1 Posted April 6, 2012 Share Posted April 6, 2012 (edited) 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 April 6, 2012 by Guest Link to comment
sckatchof Posted April 6, 2012 Author Share Posted April 6, 2012 i tested it your code and you have some errors in your code Link to comment
Jaysds1 Posted April 6, 2012 Share Posted April 6, 2012 i tested it your code and you have some errors in your code Can you tell me the errors please. Link to comment
drk Posted April 6, 2012 Share Posted April 6, 2012 Jaysds1, getVehicleFromName don't return a table. You're checking if 'carname' is ' ' and not if isn't ' ' and you're checking 'if ( button ) then' unecessarely. Link to comment
Jaysds1 Posted April 6, 2012 Share Posted April 6, 2012 (edited) 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 April 7, 2012 by Guest Link to comment
TAPL Posted April 7, 2012 Share Posted April 7, 2012 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
Jaysds1 Posted April 7, 2012 Share Posted April 7, 2012 oh, ya, cause if the "" has nothing, then it could still go through, thanks TAPL Link to comment
Kenix Posted April 7, 2012 Share Posted April 7, 2012 Predefined variable client only in server side! viewtopic.php?f=91&t=39678 Link to comment
TAPL Posted April 7, 2012 Share Posted April 7, 2012 Predefined variable client only in server side!viewtopic.php?f=91&t=39678 What is the difference between client and source? Link to comment
Kenix Posted April 7, 2012 Share Posted April 7, 2012 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 Link to comment
TAPL Posted April 7, 2012 Share Posted April 7, 2012 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
sckatchof Posted April 7, 2012 Author Share Posted April 7, 2012 thanks guys for help but still don't work Link to comment
Jaysds1 Posted April 7, 2012 Share Posted April 7, 2012 thanks guys for help but still don't work Did you copy the code and put it in the same script file? Link to comment
sckatchof Posted April 7, 2012 Author Share Posted April 7, 2012 thanks guys for help but still don't work Did you copy the code and put it in the same script file? of course i put it. Link to comment
Jaysds1 Posted April 7, 2012 Share Posted April 7, 2012 thanks guys for help but still don't work Did you copy the code and put it in the same script file? of course i put it. Parts of the code is server-sided and client-sided, your going to need to add it in different files. Link to comment
sckatchof Posted April 7, 2012 Author Share Posted April 7, 2012 yes i add it but still don't work Link to comment
TAPL Posted April 8, 2012 Share Posted April 8, 2012 yes i add it but still don't work what is not work? does the vehicle exist? Link to comment
sckatchof Posted April 8, 2012 Author Share Posted April 8, 2012 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
Jaysds1 Posted April 8, 2012 Share Posted April 8, 2012 So, basically you want a garage spawner? but instead it shows the blip of where the car is? Link to comment
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