Jump to content

CameraMatrix 360°


Karuzo

Recommended Posts

  • Moderators
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
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
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
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

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

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
  • Moderators

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

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