Raised This Month: $32 Target: $400
 8% 

Plugin Commands


Post New Thread Reply   
 
Thread Tools Display Modes
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-11-2017 , 15:27   Re: Plugin Commands
Reply With Quote #11

I don't know when I use static or name.
Could you give a example please? Should it be as that?

PHP Code:
static name[32], semiclip
new timexpurpo 0;

semiclip get_cvar_pointer("semiclip")
get_user_name(idnamecharsmax(name))
timex--, purpo++;

if(
timex && purpo <= 10) {
//blabla
}


Last edited by PurposeLessx; 08-11-2017 at 15:28.
PurposeLessx is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-11-2017 , 18:53   Re: Plugin Commands
Reply With Quote #12

Let's explain with an example:

In this case, the compiler will generate only one variable and assign the values ​​to it.

Code:
new players[32], pnum get_players(players, pnum, "a") new id, name[32] for (--pnum; pnum >= 0; pnum--) {     id = players[pnum];     get_user_name(id, name, charsmax(name))     client_print(id, print_chat, "Your name is %s", name) }

Now in this case, the compiler will generate one variable during the repeat process until the condition is reached.
Code:
new players[32], pnum get_players(players, pnum, "a") for (--pnum; pnum >= 0; pnum--) {     static id, name[32]     id = players[pnum];     get_user_name(id, name, charsmax(name))     client_print(id, print_chat, "Your name is %s", name) }

So, surely the first form, in this case, is recommended over, put in a function that is repeated several times per second is recommended use static variables have to be changed again and again.
__________________









Last edited by CrazY.; 08-11-2017 at 18:59.
CrazY. is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-12-2017 , 03:18   Re: Plugin Commands
Reply With Quote #13

I got it, thanks.
But I have a question. Couldn't I use static with players[32], inum
For exp;

PHP Code:
static players[32], Uidinum
get_players
(playersinum)
for(new 
i=0i<inumi++) {
           
Uid players[i]
           
//blabla

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

I told you when to use static...
__________________
HamletEagle is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-12-2017 , 10:55   Re: Plugin Commands
Reply With Quote #15

Quote:
Originally Posted by HamletEagle View Post
I told you when to use static...
I understand, I guess. check it out and tell my mistakes, please [If I have].

PHP Code:
        static players[32], Uidmessage[192]
    new 
counterrorist=0terrorist=0inum=0
    
    get_players
(playersinum"ae")
    for(new 
i=0i<inumi++)
    {
        
Uid players[i]
        if(
get_user_team(Uid) == 2)
            
counterrorist++
        
        else if(
get_user_team(Uid) == 1)
            
terrorist++;
    }
    
copy(messagecharsmax(message), "CT %d T %d"counterroristterrorist

Last edited by PurposeLessx; 08-12-2017 at 10:58.
PurposeLessx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-12-2017 , 12:01   Re: Plugin Commands
Reply With Quote #16

Where will be this code used?
__________________
HamletEagle is offline
Old 08-12-2017, 13:41
CrazY.
This message has been deleted by CrazY..
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-12-2017 , 13:47   Re: Plugin Commands
Reply With Quote #17

See get players flags.
https://www.amxmodx.org/api/amxmodx/get_players

And the Hamlet already told the answer to you.
__________________








CrazY. is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-12-2017 , 15:06   Re: Plugin Commands
Reply With Quote #18

It will say "How many cts and ts are alive.
Couldn't it work?

I know all get players
I forgot to delete "e" from "ae".
PurposeLessx is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 08-12-2017 , 17:53   Re: Plugin Commands
Reply With Quote #19

And I wanna know something too.
I am creating a menu. Which codes I should use while creating?

PHP Code:
static menu[64]

formatex(menucharsmax(menu), "Name")
new 
menux menu_create(menu"handler")

formatex(menucharsmax(menu), "sadasd")
menu_additem(menuxmenu"1"
or
PHP Code:
new menu menu_create("Name""handler")
menu_additem(menu"sadasd""1"
PurposeLessx is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 08-13-2017 , 01:07   Re: Plugin Commands
Reply With Quote #20

First example is recommend when you've registered a dictionary into your plugin and want to show menu items/title based on player language.

Both work...
__________________








CrazY. 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 04:26.


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