Jump to content

Arguments "source" in scripts


#RooTs

Recommended Posts

Hello, I've been noticing that. several scripts using as argument "source" are giving errors on the server and causing the fall.

error on the console before the fall ... servivor bad argument in several scripts at the same time

http://i.imgur.com/WSkhLZC.jpg

givecar, erro in line 22

http://i.imgur.com/wLqrILo.png

ejetar, erro in line 121

http://i.imgur.com/J1Ts1Bf.png

givearmas, erro in line 26

http://i.imgur.com/XXFqK9A.png

the doubt is. why these errors? and because they can cause the server crash

ahhh friends I do not know what to do more

Link to comment
  • Moderators

1. Elements can turn invalid(destroyed) during the timer delay. So check with the function isElement if the elements are valid after the timer end.

isElement 

2. Source elements must pas through parameters in order to use them properly. In some parts of your script you did that, but in other parts not.

And that crash might be caused by the terrible amount of timers you use. Vehicle respawning can be done with 1 timer, for ALL vehicles.

Link to comment
  • Moderators

no,

  
    setTimer( 
        function(p) 
            if isElement(p) then 
                setElementVelocity(p, ...) -- or whatever 
            end 
        end, 5000, 1, source 
    ) 

Link to comment
  • Moderators
Collision/command handler will always return element, therefore isElement check isn't needed.

As MrTasty says.

If the referention of a userdata is always correct, even when using a timer, the warnings in the console wouldn't be valid. Yet they(warnings) are there, at places where hé did exacly the same as your example.

#Roots wants to get rid of all those errors, this is how he can do that.

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