myonlake Posted March 3, 2014 Share Posted March 3, 2014 Do not create the vehicle client-side if you're not nearby the vehicle. It will cause the vehicle to drop under the ground and it will bug out. Just create the vehicle server-side. Link to comment
Moderators Citizen Posted March 3, 2014 Moderators Share Posted March 3, 2014 Do not create the vehicle client-side if you're not nearby the vehicle. It will cause the vehicle to drop under the ground and it will bug out. Just create the vehicle server-side. There is no reason for the car to be out of the stream range because I guess he is using a marker to show up a gui. Doing it client side, make it easier since you can have multiple player using it at the same time. (ofc you can do it too in server-side but you will need to handle that possibility) Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 function ShowAutos() local row = guiGridListGetSelectedItem(vehicleList) local carget = guiGridListGetItemText(vehicleList, row, 1) local carshow = createVehicle(carget,544.74103, -1298.83533, 32.54056) addEventHandler ( "onClientPreRender", root, function ( ) renderCameraRotation ( carshow, 544.74103, -1298.83533, 32.54056 ) end ) end Just tested it. The Camera freaks out and there's still no car. Link to comment
Jesseunit Posted March 3, 2014 Share Posted March 3, 2014 function ShowAutos() local row = guiGridListGetSelectedItem(vehicleList) local carget = guiGridListGetItemText(vehicleList, row, 1) local carshow = createVehicle(carget,544.74103, -1298.83533, 32.54056) addEventHandler ( "onClientPreRender", root, function ( ) renderCameraRotation ( carshow, 544.74103, -1298.83533, 32.54056 ) end ) end Just tested it. The Camera freaks out and there's still no car. Hit me up on Skype, I'll help you out. Link to comment
Moderators Citizen Posted March 3, 2014 Moderators Share Posted March 3, 2014 Just tested it.The Camera freaks out and there's still no car. As I can see, for the camera problem, jesseunit will help you. But for the problem of the car, you have to do a tonumber on carget in the createVehicle function. It's weird that the addEventHandler is still added and working. Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 Ok so Jesseunit helped me very well with the Camera thing. So with the Car: I tried to put a outputChatBox so i can test if he gets the car. But he outputs Nothing. So he doesn't get the Car. And the gridlist would be probably the problem. I dunno what the problem with the gridlist could be. But i hope you could help me . @Citizen: I tried it with tonumber but it outputs "nil". Code : function showList() local table = {} vehicleList = guiCreateGridList(14, 30, 200, 367, false, Carwnd) vehicleList1 = guiGridListAddColumn( vehicleList, "Fahrzeug", 0.5 ) priceList = guiGridListAddColumn( vehicleList, "Preis", 0.3 ) node = xmlLoadFile("data/vehicles.xml") if ( node ) then local vNum = 0 while ( xmlFindChild ( node, "group", vNum ) ~= false ) do local group = xmlFindChild ( node, "group", vNum ) local gName = xmlNodeGetAttribute ( group, "id" ) guiGridListSetItemText( vehicleList, guiGridListAddRow ( vehicleList ), 1, ""..gName.."", false, false ) local vNum1 = 0 while ( xmlFindChild ( group, "vehicle", vNum1 ) ~= false ) do local aVehicle = xmlFindChild ( group, "vehicle", vNum1 ) local vId = xmlNodeGetAttribute ( aVehicle, "id" ) local vName = getVehicleNameFromModel ( vId ) local vPreis = xmlNodeGetAttribute ( aVehicle, "price" ) local row = guiGridListAddRow ( vehicleList ) guiGridListSetItemText( vehicleList, row, 1, ""..vName.."", false, false ) guiGridListSetItemText( vehicleList, row, 2, ""..vPreis.."", false, false ) vNum1 = vNum1 + 1 end vNum = vNum + 1 end xmlUnloadFile ( node ) end return table end function ShowAutos() local row = guiGridListGetSelectedItem( vehicleList ) local carget = guiGridListGetItemText( vehicleList, row, 1 ) outputChatBox(carget) if not isElement( carshow ) then carshow = createVehicle( carget,544.74103, -1298.83533, 32.54056 ) end renderCameraRotation ( carshow, 544.74103, -1298.83533, 32.54056 ) end Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 Well, you are getting vehicle's name not model. Try using getVehicleModelFromName. Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 Oh works now. But it stays always the car which i've chosen first. How can i update it ? function ShowAutos() local row = guiGridListGetSelectedItem( vehicleList ) local carget = guiGridListGetItemText( vehicleList, row, 1 ) local carput = getVehicleModelFromName(carget) outputChatBox(carget) if not isElement( carshow ) then carshow = createVehicle( carput,544.74103, -1298.83533, 32.54056 ) end renderCameraRotation ( carshow, 544.74103, -1298.83533, 32.54056 ) end Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 (edited) You can clear gridlist and load it again. Or guiGridListSetSelectedItem ( vehicleList, 0, 0 ) Edited March 3, 2014 by Guest Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 I mean , if he clicks on another car, the car which he first clicked stays there. I mean clear and load it again, wouldn't that lag ? Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 And where should i use that ? Link to comment
WhoAmI Posted March 3, 2014 Share Posted March 3, 2014 There, where you want to clear gridlist, I mean unselect row. Link to comment
Moderators Citizen Posted March 3, 2014 Moderators Share Posted March 3, 2014 Just add an else to that if: if not isElement( carshow ) then carshow = createVehicle( carput,544.74103, -1298.83533, 32.54056 ) end To: if not isElement( carshow ) then carshow = createVehicle( carput, 544.74103, -1298.83533, 32.54056 ) else setElementModel( carshow, carput ) --change the model of the vehicle end Link to comment
Karuzo Posted March 3, 2014 Author Share Posted March 3, 2014 Works perfectly! I think i have it now! Thank you all for your effort and your help! 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