Raised This Month: $51 Target: $400
 12% 

Question about register_plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-08-2018 , 15:35   Question about register_plugin
Reply With Quote #1

Hello friends,
I want to know what is different about these codes and also which one is the best I should use.
Thanks for helping.

1st
PHP Code:
public plugin_init() {
    
register_plugin("Plugin""1.0""PurposeLess");

2nd
PHP Code:
#define PLUGIN "Plugin"
#define VERSION "1.0"
#define AUTHOR "PurposeLess" 
3rd
PHP Code:
new const PLUGIN[] = "Plugin";
new const 
VERSION[] = "1.0";
new const 
AUTHOR[] = "PurposeLess"
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }

PurposeLessx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-08-2018 , 15:37   Re: Question about register_plugin
Reply With Quote #2

Short version: doesn't matter.
__________________
HamletEagle is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-08-2018 , 15:43   Re: Question about register_plugin
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Short version: doesn't matter.
That's mean there is no any different about these in plugins have long or short lines, isn't that?
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }

PurposeLessx is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 08-08-2018 , 15:53   Re: Question about register_plugin
Reply With Quote #4

2nd and 3rd version use more lines, that's the difference.
__________________
Relaxing is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-08-2018 , 15:58   Re: Question about register_plugin
Reply With Quote #5

Quote:
Originally Posted by Relaxing View Post
2nd and 3rd version use more lines, that's the difference.
When should I use new const & static const and #define?

For example;
create_entity("info_target");
and
entity classname

Why people use this code?
PHP Code:
new const entity[] = "info_target";
new const 
classname[] = "parachute" example

create_entity
(entity);
entity_set_string(para_ent[id],EV_SZ_classname,classname); 
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }


Last edited by PurposeLessx; 08-08-2018 at 16:00.
PurposeLessx is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 08-08-2018 , 16:08   Re: Question about register_plugin
Reply With Quote #6

Code:
new const String[] = "string";

function(String)
And


Code:
function("string");
Are same afaik from C++, in 2nd, "string" is another const variable that's only inside that native.
About #define, it will replace everything with ur value and compiles code

Code:
#define A "string"

function(A);
is same as

Code:
function("string");
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 08-08-2018 at 16:09.
Ghosted is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-08-2018 , 16:12   Re: Question about register_plugin
Reply With Quote #7

Quote:
Originally Posted by PurposeLessx View Post
That's mean there is no any different about these in plugins have long or short lines, isn't that?
Why do you even worry about something that is going to be called ONCE per map?
__________________
HamletEagle is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-08-2018 , 16:17   Re: Question about register_plugin
Reply With Quote #8

I know they do same things but must be different. I heard that we should use new const instead of define because of server cache. I have to know lots of information about these, I guess.

I am not worry about that. I just wondered. I am worry about entity classname problem because of I don't know which one is the best to use.
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }

PurposeLessx is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-08-2018 , 18:05   Re: Question about register_plugin
Reply With Quote #9

new const means initialize variables that will never be changed, this mean, keep with a permanent value, then, let's suppose you will create 40 entities with classname info_target. To not occupy much memory I believe it would be best to create a variable with the string info_target instead of define each one.


Code:

new const g_pszNameInfoTarget[] = "info_target";

something()
{
	create_entity(g_pszNameInfoTarget);
	create_entity(g_pszNameInfoTarget);
	create_entity(g_pszNameInfoTarget);
	create_entity(g_pszNameInfoTarget);
	create_entity(g_pszNameInfoTarget);
}
instead of

Code:
something()
{
	create_entity("info_target");
	create_entity("info_target");
	create_entity("info_target");
	create_entity("info_target");
	create_entity("info_target");
}
__________________









Last edited by CrazY.; 08-08-2018 at 18:07.
CrazY. is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-09-2018 , 15:49   Re: Question about register_plugin
Reply With Quote #10

So, for this?

PHP Code:
set_pev(idpev_healthFloat:pev(idpev_health) + 10.0);

// or 

new Float:health pev(idpev_health);
set_pev(idpev_healthhealth 10.0);

// or

new Float:health pev(idpev_health);
health += 10.0;
set_pev(idpev_healthhealth); 
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }


Last edited by PurposeLessx; 08-09-2018 at 15:49.
PurposeLessx is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode