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

Plugin Commands


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-13-2017 , 03:42   Re: Plugin Commands
Reply With Quote #21

Don't use static on this arrays, use new. With big arrays I mean over 1000 cells or so(or when it gives a stack error).
__________________

Last edited by HamletEagle; 08-13-2017 at 03:42.
HamletEagle is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-13-2017 , 06:47   Re: Plugin Commands
Reply With Quote #22

Oh okey. I understand perfectly.
I'd like to say something. I don't like using "fun include". I don't know why.
I usually use "fakemeta" instead. Fakemeta is better than fun or they are same?
In my server, there are lots of plugins. And our pings are always between 30,50.
Every plugin are necessary. So, I am changing the codes of plugins. I deleted every fun includes in all plugins. Which includes I should use?

For example; [I deleted cstrike include too]

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
//#include <cstrike>
//#include <fun>

public plugin_init() {
        
register_plugin("","","")

        
RegisterHam(Ham_Spawn"player""player_spawn"1)
}

public 
player_spawn(id)
{
    if(
get_user_team(id) != || !is_user_alive(id)) return

    
//strip_user_weapons(id)
    
strip_user_weaponsx(id)
    
give_itemx(id"weapon_knife")

    
//cs_set_weapon_ammo(give_item(id, "weapon_deagle", 1)
    //cs_set_user_bpammo(id, CSW_DEAGLE, 0)
    
static item;
    if((
item give_itemx(id"weapon_deagle")) != -1)
    {
        
set_pdata_int(item5114)
    }
}

stock strip_user_weaponsx(index)
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"))
    if(!
pev_valid(ent)) return 0

    dllfunc
(DLLFunc_Spawnent);
    
dllfunc(DLLFunc_Useentindex);
    
engfunc(EngFunc_RemoveEntityent);
    
set_pdata_int(index1160)
    return 
1;
}

stock give_itemx(index, const item[])
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
    if (!
pev_valid(ent))
        return 
0;
    
    new 
Float:origin[3];
    
pev(indexpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);

    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentindex);
    if (
pev(entpev_solid) != save)
        return 
ent;

    
engfunc(EngFunc_RemoveEntityent);
    return -
1;


Last edited by PurposeLessx; 08-13-2017 at 06:48.
PurposeLessx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-13-2017 , 07:25   Re: Plugin Commands
Reply With Quote #23

Using the conversion stocks is worse than using fun. There is absolutely no reason to delete fum and cstrike, you are not improving anything.
__________________
HamletEagle is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-13-2017 , 07:38   Re: Plugin Commands
Reply With Quote #24

Really?
So, How can I improve? If I send you skype address, could you help me please
I bet If I send here the codes of plugins, someone stoles plugin
PurposeLessx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-13-2017 , 09:06   Re: Plugin Commands
Reply With Quote #25

I don't do private help. What are you trying to improve? Simply switching modules won't create a noticeable difference.
__________________
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-13-2017 , 10:03   Re: Plugin Commands
Reply With Quote #26

Hamlet is all right, removing the fun and the cstrike will not improve in anything and yes to bring headaches. Particularly I prefer to use engine than Fakemeta, but anyway... There are some tutorials that explain how to optimize your plugin, give a searched, but usually only old plugins need updates, often because they are using fakemeta_util, or running loops with get_maxplayers instead of get_players. It will depend on the plugin...

Imagine the number of rows your code would have if you had to make a stock for each native/forward of the fun/cstrike, it would be a total waste of time trying to replace something that already works...

What did we tell you about static variables????
__________________









Last edited by CrazY.; 08-13-2017 at 10:10.
CrazY. is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-13-2017 , 14:57   Re: Plugin Commands
Reply With Quote #27

What did you tell me about static variables?

I didn't understand this? I am tryna use static.
Is there a problem about static or new in this plugin?

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
//#include <cstrike>
//#include <fun>

public plugin_init() {
        
register_plugin("","","")

        
RegisterHam(Ham_Spawn"player""player_spawn"1)
}

public 
player_spawn(id)
{
    if(
get_user_team(id) != || !is_user_alive(id)) return

    
//strip_user_weapons(id)
    
strip_user_weaponsx(id)
    
give_itemx(id"weapon_knife")

    
//cs_set_weapon_ammo(give_item(id, "weapon_deagle", 1)
    //cs_set_user_bpammo(id, CSW_DEAGLE, 0)
    
static item;
    if((
item give_itemx(id"weapon_deagle")) != -1)
    {
        
set_pdata_int(item5114)
    }
}

stock strip_user_weaponsx(index)
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"))
    if(!
pev_valid(ent)) return 0

    dllfunc
(DLLFunc_Spawnent);
    
dllfunc(DLLFunc_Useentindex);
    
engfunc(EngFunc_RemoveEntityent);
    
set_pdata_int(index1160)
    return 
1;
}

stock give_itemx(index, const item[])
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
    if (!
pev_valid(ent))
        return 
0;
    
    new 
Float:origin[3];
    
pev(indexpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);

    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentindex);
    if (
pev(entpev_solid) != save)
        return 
ent;

    
engfunc(EngFunc_RemoveEntityent);
    return -
1;

PurposeLessx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-13-2017 , 16:12   Re: Plugin Commands
Reply With Quote #28

Don't use stocks instead of module functions, it's worse not better. I think what I said was pretty clear.
If you do not understand what static is read tutorials. Anyway, it WON'T optimize your plugin to the point where you will notice anything in game.

What you are trying to do is pointless. What you should be doing is to look at the logic behind the plugin and try to improve that if possible.
__________________

Last edited by HamletEagle; 08-13-2017 at 16:14.
HamletEagle is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 08-13-2017 , 17:12   Re: Plugin Commands
Reply With Quote #29

read this again:
https://forums.alliedmods.net/showpo...21&postcount=9
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-13-2017 , 18:03   Re: Plugin Commands
Reply With Quote #30

Quote:
Originally Posted by HamletEagle View Post
Don't use stocks instead of module functions, it's worse not better. I think what I said was pretty clear.
If you do not understand what static is read tutorials. Anyway, it WON'T optimize your plugin to the point where you will notice anything in game.

What you are trying to do is pointless. What you should be doing is to look at the logic behind the plugin and try to improve that if possible.
Okay I understand that I should never use stocks instead of module functions.
I have been too lazy to write new codes. So I send it (sorry I don't know what is the past time of send)

I was looking for static and new. I am feeling really idiot. I wanna describe my thinks to you with some examples. So I will describe something what I do everytime and what I know only
Hope you understand me. I am tryna use english better.

First thing,
While I am writing get_players, I always use that.
I am using static for players and inum. But I am using new for just i (new i=0)
PHP Code:
static players[32], inum
get_players
(playersinum)
for(new 
i=0i<inumi++) {
//etc

Second thing,
While I am getting user name, ip or authid, I always use that
PHP Code:
static name[32], ip[32], authid[32]
get_user_name(idnamecharsmax(name))
get_user_authid(idauthidcharsmax(authid))
get_user_ip(idipcharsmax(ip), 1// 1 is with no port, I guess. 
Third thing,
While I am using format, formatex, copy, I always use that
PHP Code:
static correctnumber[64]
format(correctnumbercharsmax(correctnumber), "31")
// etc 
Fourth thing,
While I am using register_cvar or creating hudmessage, I always use that
PHP Code:
static cvar_enabledsyncObj

public plugin_init() {
         
cvar_enabled register_cvar("cvar_enabled""1")

         
syncObj CreateHudSyncObj();

Could you tell my mistake(s), please.
If I have deficient, could you show it with example(s).
Thanks for helping. You have teached me everything about stocks.
I will just use "stock client_printc" to write colorful text.

Last edited by PurposeLessx; 08-13-2017 at 18:05.
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:18.


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