• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua OnPush Function

Way20

Well-Known Member
Joined
Sep 29, 2014
Messages
205
Solutions
3
Reaction score
79
I have a script with a function OnPush in it, my problem is, it will run the script everytime some player push/move another player and inside the script I have a loop, so Im afraid that it lags the server. Is there a way to check the player storage before it runs the function?

Something like this?

Im very noob with LUA.
Lua:
if getPlayerStorageValue(cid, storage) >= 1 then

function onPush(cid, target, ground, position)
    Script goes here
    return true
end
end
 
Code:
function onPush(cid, target, ground, position)
if getPlayerStorageValue(cid, storage) >= 1 then
return false
end
    Script goes here
    return true
end
 
it wont lag your server since lua is fast
running onPush would likely take less than a millisecond to run depending on your script/loop
@jestem pro please properly indent
Lua:
function onPush(cid, target, ground, position)
    if getPlayerStorageValue(cid, storage) >= 1 then
        return false
    end
    Script goes here
    return true
end
 
it wont lag your server since lua is fast
running onPush would likely take less than a millisecond to run depending on your script/loop
@jestem pro please properly indent
Lua:
function onPush(cid, target, ground, position)
    if getPlayerStorageValue(cid, storage) >= 1 then
        return false
    end
    Script goes here
    return true
end

Yes, I will have something like this on my script, so the script will check players storage everytime some players push another. My server is enforced/war, theres people pushing each other everywhere, you're sure this wont cause lag on my server?
 
Yes, I will have something like this on my script, so the script will check players storage everytime some players push another. My server is enforced/war, theres people pushing each other everywhere, you're sure this wont cause lag on my server?
that wont cause lag lol
if you dont believe me you can check yourself
right below your function, when it starts
local now = os.mtime()
then before your function ends
print(os.mtime() - now)
that will print how many milliseconds passed from the beginning to the end when executing the function
 
Back
Top