Jump to content

[REL]Kewizzles Fun Panel


kewizzle

Recommended Posts

This script is really really bad, it's even worse than the scripts i made when i was a noob.

 

 

addEvent ("carBuy", true) 
addEventHandler ("carBuy", getRootElement(),  
function(id2, cost2, name2,x, y, z, sRz) 
local x,y,z = getElementPosition (source) 
destroyElement(vehicle, true) 
vehicle = createVehicle (id2, x, y, z, 0, 0, sRz ) 
warpPedIntoVehicle(source, vehicle) 
outputChatBox("You Successfully Spawned a Vehicle!", client, math.random(255), math.random(255), math.random(255)) 
end 
) 

You actually just destroyed the last vehicle bought, which means, only one vehicle can be bought, IN THE WHOLE SERVER.

Also, you didn't check if the vehicle exists before you destroyed it, that's why you have many errors, you didn't actually bother yourself and fix them.

NOTE: these are the errors in only one file, reading the others now.

 

 

function cursorToggle() 
if isCursorShowing(true) then 
showCursor(false) 
else 
showCursor(true) 
end 
end 
  
bindKey('m', 'down', cursorToggle) 
  

this can be done in an easier way, like this:

function cursorToggle() 
showCursor(not isCursorShowing()) 
end 
  
bindKey('m', 'down', cursorToggle) 
  

reading other files, will edit as soon as i see other errors.

now, gui.lua

You were adding

local admin = getLocalPlayer() 
  

in every single function.

This is horribly bad.

First of all, MTA has localPlayer variable which is always a replace of getLocalPlayer() in every single case, same goes for root with getRootElement(), and resourceRoot with getResourceRootElement(getThisResource())

also, you could just write at the top of the script admin = getLocalPlayer() without actually adding it in every function.

reading the last file.

The last file is HORRIBLE SHIT.

You were adding an event handler, a function, a variable for every single Marker/vehicle, you could just do this:

  
markersPositionsTable= { 
--{x, y, z} 
} 
markersElement = createElement("markers") 
for i,v in ipairs(markersPositionsTable) do 
x,y,z = unpack(v) 
local marker = createMarker(x,y,z) 
setElementParent(marker,markersElement) 
end 
  
addEventHandler("onMarkerHit", markersElement,  
function () 
--some piece of code. 
end 
) 
  

Same goes to vehicles.

I just want to tell you that i'm not trying to let you look bad, i'm just showing you your mistakes.

Link to comment
stuff

Welcome at the free scripting section.

First of all, MTA has localPlayer variable which is always a replace of getLocalPlayer() in every single case, same goes for root with getRootElement(), and resourceRoot with getResourceRootElement(getThisResource())

I use this too. What is wrong with it? It doesn't matter a ****.

Atleast he is trying and getting better with scripting.

Link to comment
That makes no sense, et-win.

...How exactly doesn't it make sense?

I also write getRootElement instead of root. Simply because it's what I'm used to and it has absolutely no performance impact whatsoever.

His other statement is also true that he made a resource and is trying to get better at it. So in all honesty, your reply made no sense. :P

Link to comment

I'd think again if I were you.

There is a very tiny performance impact.

for i = 1,10000 do 
    local Variable = getRootElement(); 
end; 
-- EXECUTION TIME: 13 ms (average) 

for i = 1,10000 do 
    local Variable = root; 
end; 
-- EXECUTION TIME: 1 ms 

local Root = root; 
for i = 1,10000 do 
    local Variable = Root; 
end; 
-- EXECUTION TIME: 0 ms (almost instantly) 

Link to comment
Keep thinking like that and you'll surely end up on the top.

How about explaining why it does matter instead of just throwing an argument like this?

i never thought it may need that much of thinking to understand it.

i actually can't stop laughing after i read Spajk's reply.

Ofcourse you will end up on top if you say that small things doesn't matter (sarcasm)

A real scripter always try to make his script more perfect, not just say 13 ms doesn't matter....

Link to comment
Keep thinking like that and you'll surely end up on the top.

How about explaining why it does matter instead of just throwing an argument like this?

i never thought it may need that much of thinking to understand it.

i actually can't stop laughing after i read Spajk's reply.

Ofcourse you will end up on top if you say that small things doesn't matter (sarcasm)

A real scripter always try to make his script more perfect, not just say 13 ms doesn't matter....

As long as script works perfectly, in my eyes is nothing wrong.

Link to comment
I'd think again if I were you.

There is a very tiny performance impact.

for i = 1,10000 do 
    local Variable = getRootElement(); 
end; 
-- EXECUTION TIME: 13 ms (average) 

for i = 1,10000 do 
    local Variable = root; 
end; 
-- EXECUTION TIME: 1 ms 

local Root = root; 
for i = 1,10000 do 
    local Variable = Root; 
end; 
-- EXECUTION TIME: 0 ms (almost instantly) 

The problem of the last one is that when the root element has got any change, it won't be taken into consideration... that's why it takes a little less than 1ms. I'd rather use second example tho

Link to comment

i never thought it may need that much of thinking to understand it.

i actually can't stop laughing after i read Spajk's reply.

Ofcourse you will end up on top if you say that small things doesn't matter (sarcasm)

A real scripter always try to make his script more perfect, not just say 13 ms doesn't matter....

Of course a good programmer always work to further optimize their creations, but in what circumstance would you make a for loop, that executes 10 000 times - doing nothing of importance? Other than to solely check the time to execute.

His example was to prove that there IS a difference, but the point is - it's no-where near a noticable difference of any sort.

If you honestly think that using root instead of getRootElement is better, you're just a try-hard. As I mentioned, I'm used to writing getRootElement and I will keep doing so because I know that it won't ever impact the performance of my scripts.

It's like if you were trying to engulf the entire world in water by pouring a glass of water into the ocean. :roll:

Link to comment
Can't explain it better than Dealman.

Anyway, after some thinking: Maybe you are right and it does matter. I guess I just can't face the truth. :roll:

Yes, every human does so, we like to not face the truth if it is not what we thought is true.

Dear Dealman, Putting a glass of water into ocean has nothing to do with what i'm saying.

Putting a glass of water into ocean wont make it more perfect, and not doing so will also not make it less perfect.

Which means: no logic was found in your reply.

Ofcourse no one would loop getRootElement 10k times in his script.

But what i want you to understand is, that getRootElement will actually get the root element (it will do something), while root, wont "get" root element, the root is stored inside it, this is why it is better.

Also, why would you write all of that, i really like it when i write root only, it's just....easy, i mean really, what is easier to write, resourceRoot or getResourceRootElement(getThisResource()) ? i mean really this is 23 more letters.

Link to comment

I do use resourceRoot instead, but I do write getRootElement. And if it bothers you, I really don't care - every programmer has their own way of doing things.

A frame at 60 FPS is ~16.6ms. 13ms isn't even the duration of a frame. That's how small of in impact it is after looping it 10 000 times.

Regarding the glass of water, it's a proverb. Look up what that means, albeit I'll admit it was a poor one. :P Also, I'd rather stop arguing about this since we're just hi-jacking the poor guy's thread and we might just end up getting a moderator to lock it.

But if you honestly think it's ever-so important to use root instead, by all means. :thumbright:

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