Jump to content

[Solved] Table,loop and render issue


Perfect

Recommended Posts

Posted (edited)

Hello Everyone, after a long time. :)

I just found my old script somewhere deep inside my computer.

I am trying to modify it such that it can create as many peds as i want.

but the problem is when i run it, my game almost froze and there are no errors/warnings debugscript.

Script:

  
--Table 
Pos =   {   {-1375.30627, -234.72827, 14.14844}, 
            {-1375.30627, -234.72827, 14.14844}, 
            {-1375.30627, -234.72827, 14.14844}, 
            {-1375.30627, -234.72827, 14.14844}, 
            ... 
        } 
... 
--Event 
addEventHandler("onClientRender", root, 
function() 
    ... 
    for i=...,... do 
        local _i = i*(math.pi/180) 
        for Ri=1,10 do --This thing is maybe calling on every frame, How to fix it ? 
            local myPed = createPed(23,Pos[Ri][1],Pos[Ri][2],Pos[Ri][3]) 
            setPedCameraRotation(myPed, ....+Pos[Ri][1], ...+Pos[Ri][2],Pos[Ri][1], Pos[Ri][2])) 
        end 
    end 
end) 
  

Can someone please help me ?

Edited by Guest
Posted

Just as ALw7sH asked, you need a starting point (i=1) and an ending point, so for example: for i=1, 10 do. This will execute the loop 10 times. In your case, you have an infinite loop and it will never stop executing.

Posted

That is code(function,variable, whatever you call it) in my script which i think is not necessary so i just replace it with '...' instead.

----------Edit----------

The problem is solved. Just have to put 'myPed' before the render event.

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