AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   write own inc's (https://forums.alliedmods.net/showthread.php?t=120367)

One 03-04-2010 04:53

write own inc's
 
hi,

idk which title i have to use.
i'm writing a new jailmod and want to check if is my freeday manager running on server and if yes, give the Leader acces to use the new effects in new plugin.

in freeday manager i have something like :

player_is_leader[id] <

do you have any ideas how can i catch the leader in new plugin?

here link of plugin http://forums.alliedmods.net/showthread.php?t=117343
PS. if is there noway, i will attach a new plugin as freedaymanager to catch the leader.

Xellath 03-04-2010 05:07

Re: get users info
 
Register a native in your main plugin and return the value of g_player_is_leader.

Code:
public plugin_natives( ) {     register_native( "is_player_leader", "_is_player_leader" ); } public bool:_is_player_leader( iPlugin, iParams ) {     return g_player_is_leader[ get_param( 1 ) ]; }

Then make an include file and add this:

Code:
#if defined _jail_manager_included     #endinput #endif #define _jail_manager_included native bool:is_player_leader( const id );

Then after that is done you just have to include the .inc file to your sub-plugin.

Examples how to check:
Code:
#include < jail_manager > public function( id ) {     if( is_player_leader( id ) )     {         // player is leader     }     else     {         // not leader     } }

One 03-04-2010 07:01

Re: get users info
 
awesome. ty. :D
i tough its imposs :D

now i can upload more plugins :D

and how is it to register a function in inc?

i mean for example i have in the main plugin :

public show_me_the_scores(id,test,test2)

:D

One 03-05-2010 04:23

Re: get users info
 
sry for push or dubble post.

i tried to check it in csdm or zp inc but couldnt find anything which can help me.

main plugin/test1.amxx
PHP Code:

#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <jail_manager>

#define TASK_PLAYERFREE 1000

new g_tempid,g_MaxPlayers,g_leach_cvar,bool:g_player_is_leader[33],iPlayers32 ], iNum,g_printed,we_have_a_leader,gVoteMenu,
gVotes[2],gVoting,g_delay,g_percent,bool:g_Vote_Player[33],g_voted,g_free_vote,g_its_freeday,g_rounds,g_had_freeround,can_vote,
g_vote_round_number,g_let_be_freeday,g_vote_canceled,g_vip_admin,g_show_votes,g_welcomed[33],admin_gave_freeday,g_welcome_menu


public plugin_natives( ) 
{     
    
register_native"is_player_leader""_is_player_leader"); 

public 
bool:_is_player_leaderiPluginiParams 
{     
    return 
g_player_is_leaderget_param) ]; 


inc file =
PHP Code:

#if defined _jail_manager_included
    #endinput
#endif
#define _jail_manager_included

native is_player_leader( const id ); 

sub-plugin/test2.amxx
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <jail_manager>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say a","function")
    
// Add your code here...
}
public function( 
id )
{
    if( 
is_player_leaderid ) )
    {
        
// player is leader
        
client_print(id,print_chat,"jaaaaaaaaaa")
    }
    else
    {
        
// not leader
        
client_print(id,print_chat,"neiiiiiiiiiiiin")
    }


error :
PHP Code:

L 03/05/2010 10:18:25Start of error session.
L 03/05/2010 10:18:25Info (map "de_dust2") (file "addons/amxmodx/logs/error_20100305.log")
L 03/05/2010 10:18:25Wrong style of dynamic native
L 03
/05/2010 10:18:25: [AMXXDisplaying debug trace (plugin "test1.amxx")
L 03/05/2010 10:18:25: [AMXXRun time error 10native error (native "get_param")
L 03/05/2010 10:18:25: [AMXX]    [0test1.sma::_is_player_leader (line 19)
L 03/05/2010 10:18:25Unhandled dynamic native error 

i tried to search and found more topics like http://forums.alliedmods.net/showthread.php?t=118049 but the same resault. (all are the same :( )

Xellath 03-05-2010 04:38

Re: get users info
 
Fixed my post above.

One 03-05-2010 04:44

Re: get users info
 
ty :D its working but idk how to call a function.

main plugin function :

player_menu(id)

i want to call this function in sub plug :D

so i think it's last post about this.

i cant find any tuts for it or how i can make own inc :(

oh && get the names of plugins which use the same inc.

i want to show it in welcome menu like :

main plugin = freeday manager
subs = test1
subs = test2

in welcome menu :

this server is using : freeday manager,test1 and test2 .

something like this :D

tuty 03-05-2010 07:07

Re: write own inc's
 
[COLOR=#000000]public bool:_is_player_leader( iPlugin, iParams )
{
return
g_player_is_leader[ get_param( 1 ) ];
}


should be is_player_leader not _is_player_leader, and try to add this line
in your inc file

#pragma reqlib <library>
library - your library name



xPaw 03-05-2010 07:33

Re: get users info
 
Quote:

Originally Posted by One (Post 1108015)
ty :D its working but idk how to call a function.

main plugin function :

player_menu(id)

i want to call this function in sub plug :D

so i think it's last post about this.

i cant find any tuts for it or how i can make own inc :(

oh && get the names of plugins which use the same inc.

i want to show it in welcome menu like :

main plugin = freeday manager
subs = test1
subs = test2

in welcome menu :

this server is using : freeday manager,test1 and test2 .

something like this :D

Forwards

One 03-05-2010 08:23

Re: write own inc's
 
ty. i tried to read the tut but...

please dont lol @ me :D

main plugin :
PHP Code:

public showing_menu(id)
{
    new 
szMenuName[32]
    
formatex(szMenuName31"\y%L"id"MENU_HEADER")
    new 
menu menu_create(szMenuName"free_choosed")
    new 
players[32], pnum
    
new szName[32], szTempid[10]
    
get_players(playerspnum)
    
    new 
Temp[32]
    
formatex(Temp31"\w%L"id"FFA");
    
menu_additem(menu,Temp"1",id);
    
formatex(Temp31"\w%L"id"REMOVE");
    
menu_additem(menu,Temp"2"id);
    
    
formatex(Temp31"\w%L"id"VOTE");
    
menu_additem(menu,Temp"3"id);
    
    for( new 
ii<pnum;i++ )
    {
        
g_tempid players[i];
        if(
get_user_team(g_tempid) & && is_user_alive(g_tempid))
        {
            
get_user_name(g_tempidszName31)
            
num_to_str(g_tempidszTempid9)
            
menu_additem(menuszNameszTempid0)
        }
    }
    
menu_display(idmenu0)


sub plugin :

PHP Code:

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say a","function")
    
// Add your code here...
}
public function( 
id )
{
    if( 
is_player_leaderid ) )
    {
        
// player is leader
        
client_print(id,print_chat,"jaaaaaaaaaa")
        new 
menu CreateMultiForward("showing_menu",id)
        
ExecuteForward(menu,id)
    }
    else
    {
        
// not leader
        
client_print(id,print_chat,"neiiiiiiiiiiiin")
    }


why i cant call the function showing_menu from main plugin in sub? :(



Dont lol @ me :(

Xellath 03-05-2010 09:49

Re: write own inc's
 
Quote:

Originally Posted by tuty (Post 1108116)
should be is_player_leader not _is_player_leader, and try to add this line
in your inc file

#pragma reqlib <library>
library - your library name

It should be _is_player_leader, look at the native registering.

About the reqlib, that is not required unless you're running an outdated version of amxmodx.


All times are GMT -4. The time now is 08:46.

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