Optimize Plugin
Hey friends, I make a plugin. It has 3951 lines so I want to make it optimized for server.
In menus, what I should use? Code:
static data[6], name[32], access, callback, key; |
Re: Optimize Plugin
It doesn't matter.
|
Re: Optimize Plugin
So what should I do for optimizing plugin?
Example commands; PHP Code:
|
Re: Optimize Plugin
For starters, using get_players() to loop all players.
|
Re: Optimize Plugin
Quote:
|
Re: Optimize Plugin
Do they have all 32 players online 24/7? Probably not.
The only right way to loop all players is by using get_players(). |
Re: Optimize Plugin
Quote:
|
Re: Optimize Plugin
Quote:
|
Re: Optimize Plugin
My english is not good enough as you all. My bad.
I guess you understand my question, so there is no problem :D. "Is using get_players more optimized than using for(new Uid = 1 ; Uid <= 32 ; Uid++)" |
Re: Optimize Plugin
If it wasn't, would I be writing this in a thread that says "OPTIMIZE PLUGIN"?
|
Re: Optimize Plugin
What about increasing heap size by #pragma dynamic ? (default value = 4096)
|
Re: Optimize Plugin
Quote:
For example; First; there is anything tag of command. What if I add a tag (stock or public) Second; there is stock and bool. What if I delete stock or bool? Code:
rg_set_user_rendering(index, fx = kRenderFxNone, {Float,_}:color[3] = {0.0,0.0,0.0}, render = kRenderNormal, Float:amount = 0.0) |
Re: Optimize Plugin
You shouldn't be using "stock" in the .sma files. This tag is used only if there is a possibility that the function will not be used at all. Since this is your code and you added the function, you're probably going to use it as well, so remove the "stock" tag. Only use "stock" in include files where not all functions must be used in the code when included.
"bool" is pretty self-explainatory. If the variable is tagged with "bool", then the return value of the function should also be "bool". Bools can be only true or false. |
Re: Optimize Plugin
Quote:
I guess it is not wrong? :) |
Re: Optimize Plugin
Bool limits the variable to true or false (or 1 and 0). You don't need any tag if you don't need this.
|
Re: Optimize Plugin
Okay, One question about is_user_alive.
I know is_user_alive checks is_user_connected. But I don't know something. Which I should use? PHP Code:
|
Re: Optimize Plugin
Quote:
|
Re: Optimize Plugin
So I must check if user connected while checking !is_user_alive
|
Re: Optimize Plugin
if(is_user_alive(id)) - if true, player is connected and alive.
if(is_user_connected(id) && !is_user_alive(id)) - if true, player is connected but not alive. |
Re: Optimize Plugin
Okay, got it thanks :)
|
Re: Optimize Plugin
Quote:
is_user_alive itself checks if player is connected. Code:
|
Re: Optimize Plugin
I know I don't need check connected with is_user_alive.
My question is: !is_user_alive && is_user_connected |
Re: Optimize Plugin
Quote:
PHP Code:
Code:
So in your case: !is_user_alive would return true if either player is not connected or not alive. What you're doing: !is_user_alive(id) && is_user_connected(id) What happens in the module: Code:
So basically you're calling a native for nothing. |
Re: Optimize Plugin
I have thought like this.
Code:
is_user_alive = pPlayer->ingame && pPlayer->IsAlive() ? |
Re: Optimize Plugin
Quote:
is_user_alive, the game will return true - if player is in game (connected) and alive. false - if either player is not connected or not alive. !is_user_alive, will return the same as is_user_alive just that now you're checking for the negative value. This if(!is_user_alive(id)) will return the same but you'll be checking (!) not So: if(!is_user_alive(id)) Player not alive or not connected. |
Re: Optimize Plugin
I want to revive all dead people. If not connected, how I will revive?
Code:
Player not alive or not connected. |
Re: Optimize Plugin
Quote:
PHP Code:
|
Re: Optimize Plugin
So, how can I optimize this plugin?
Spoiler
|
Re: Optimize Plugin
Quote:
So I need it. |
Re: Optimize Plugin
Quote:
|
Re: Optimize Plugin
Okay I will use it :)
The revive plugin I use; Revive Dead CTs
Spoiler
|
Re: Optimize Plugin
Quote:
|
Re: Optimize Plugin
Yeah I am listening. I am just trying to learn. If you will not help, do not post please.
|
Re: Optimize Plugin
So, while hudmessage plugin is working, server is lagging. What is the reason?
|
Re: Optimize Plugin
Quote:
|
Re: Optimize Plugin
Quote:
|
Re: Optimize Plugin
Quote:
Only if(!is_user_alive(id)) doesn't ensure than the player is dead AND connected. This check will fail if the player isn't connected. This means, this way you can't know if the player is dead OR he is simply disconnected. |
Re: Optimize Plugin
Quote:
Why would you check/do something on a player that isn't connected? Using is_user_alive is enough, you're just mis-informing him. Quote:
PHP Code:
PHP Code:
|
Re: Optimize Plugin
edon1337, something wrong happens with you? Read again my first post:
Quote:
|
Re: Optimize Plugin
Quote:
Quote:
Edon you are wrong Code:
pPlayer->ingame && pPlayer->IsAlive() so you can not determine player is connected & dead or not connected & dead(huh?). :idea: !ALIVE & !INGAME = FALSE !ALIVE & INGAME = FALSE ALIVE & !INGAME = FALSE ALIVE & INGAME = TRUE |
All times are GMT -4. The time now is 01:15. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.