Raised This Month: $ Target: $400
 0% 

Question about .inc files


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-02-2010 , 17:19   Question about .inc files
Reply With Quote #1

I got some questions about the includes, file.inc ...

1.How do we make them (like making new commands. ex: "zp_get_user_zombie" from zombieplague.inc

2.I'd also like some info about natives.

3. If i think right, a include can hold a bool like this.

example:

plugins:
jailbreak.sma and lr.sma

include holds bool:lr_started

so when you code a rebelling system in jailbreak.sma but lr.sma says lr is started.
No rebeling thing will start.

4.if you can help me out with this, i'll be a very happy guy. ;)
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-02-2010 , 17:24   Re: Question about .inc files
Reply With Quote #2

Heres one of my includes..


It hods all the values for cvars and class/ranks/XP

as well as stocks. and other stuff i call frequently.

How ever the version of battle field that i will be releasing will be fully modular and rewritten.

Meaning it will hold natives as well as stock functions and variables that all the attatched plugins will uses such as (Primary weapons, Secondary, Armor, Health, Speed, Gravity)


And that example is the second include file i have attatched.
Attached Files
File Type: inc bfmod.inc (57.8 KB, 83 views)
File Type: inc modular_test.inc (69 Bytes, 84 views)

Last edited by Doc-Holiday; 03-02-2010 at 17:33.
Doc-Holiday is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-02-2010 , 17:39   Re: Question about .inc files
Reply With Quote #3

2) https://forums.alliedmods.net/showth...t=fake+natives
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT

Last edited by wrecked_; 03-02-2010 at 17:43.
wrecked_ is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-02-2010 , 17:57   Re: Question about .inc files
Reply With Quote #4

@ NbC_Sav:

so you make it like the start of a normal plugin, defining things and such.
Could you explain a little more about the stocks to?
And i create a float in my inc and 1 plugin changes the value of the float, will plugin 2 see the changed value or not?

@wrecked_:
And agian you make my day a lot easyer.

@Both:
Thanks
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-02-2010 , 18:34   Re: Question about .inc files
Reply With Quote #5

Don't create 'global' variables in includes. They will not be used as you are hoping.
__________________
fysiks is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-02-2010 , 20:48   Re: Question about .inc files
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
Don't create 'global' variables in includes. They will not be used as you are hoping.

They work fine to seperate the two plugins just fine...

The first one was just to keep the main plugin nice and simple to read..

How ever say i added another plugin that used that include if i dont use all those variables i get errors saying that all the variables werent used.

So if its just a really large plugin to make it more readable i sperated them.

The plugin was like 4k lines of code lol so makeing the inc and regular file it was so much easier.

Quote:
@ NbC_Sav:

so you make it like the start of a normal plugin, defining things and such.
Could you explain a little more about the stocks to?
And i create a float in my inc and 1 plugin changes the value of the float, will plugin 2 see the changed value or not?
Not exactly like that

When you create a Float in your inc. Plugin one can use it and make the value what it would like change it and do what ever how ever plugin two can use it but its a completely different variable

So technically it would be like creating a float in each of the 2 plugins. I believe that is correct.

Now for the stock

PHP Code:
Stock SetSkills(idszPrimWeapon[], szSecWeapon[], iHealthiArmorFloat:flSpeedFloat:flGravity)
{
    
give_item(idszPrimWeapon);
    
give_item(idszSecWeapon);
    
cs_set_user_bpammoid get_weaponidszPrimWeapon ) , 200 );
    
cs_set_user_bpammoid get_weaponidszSecWeapon ) , 200 );  
    
set_user_health(idiHealth);
    
set_user_armor(idiArmor);
    
set_user_maxspeed(idflSpeed);
    
set_user_gravity(idflGravity);

With that in the inc file it allows any of the plugins that include that inc to call something like.

PHP Code:
SetSkills(idweapon_akweapon_usp1501503200.5
Which would send to the stock the players id and the values for those give items and set user health/armor/speed/gravity

It makes it simpler to use multiple functions calling the same function. (if that makes sense)

Last edited by Doc-Holiday; 03-02-2010 at 20:54.
Doc-Holiday is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-02-2010 , 22:03   Re: Question about .inc files
Reply With Quote #7

On an off-note, you may want to add a prefix on to each of your variables / stocks in the include (if you're publicizing it), so that people don't waste their time looking through the main plugin to modify something, when something as simple as JB_Strip_Weapons would notify the editor that the stock he wants to modify is in the .include file.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-02-2010 , 22:58   Re: Question about .inc files
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
Don't create 'global' variables in includes. They will not be used as you are hoping.
Cause if you do, some smart scripter is going to change its value to an unexpected range, and your plugin goes from ass-kicking to unpredictable behavior.
Seta00 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-03-2010 , 04:37   Re: Question about .inc files
Reply With Quote #9

is the stock called in another function then? like so:
PHP Code:
public plugin_init()

    
RegisterHamHam_Spawn"player""FwdHamPlayerSpawn");
}

public 
FwdHamPlayerSpawn(id

     
SetSkills(idweapon_akweapon_usp1501503200.5)

then is there a way to make the bool in 2 plugins, and when 1 plugin makes it true,
the other plugin sees that it's true?

like this

jailbreak last request plugin:
PHP Code:
public lr_menu(id)
{
    if (
cs_get_user_team(id) != CS_TEAM_T || !is_user_alive(id))
    {
        return 
PLUGIN_HANDLED;
    }
    if (
lr_started)
    {
        return 
PLUGIN_HANDLED
    
}
    new 
ctCounttrCount;
    
    for (new 
1<= g_iMaxPlayersi++)
    {
        if (!
is_user_alive(i))
        {
            continue;
        }
        
        switch (
cs_get_user_team(i))
        {
            case 
CS_TEAM_CT:
            {
                
ctCount++;
            }
            
            case 
CS_TEAM_T:
            {
                
trCount++;
            }
        }
    }
    
    if (
trCount 1)
    {
        
client_print(idprint_chat"[JAIL] There are to many prisoners left.")
        return 
PLUGIN_HANDLED;
    }
    
    if (
ctCount == 0)
    {
        
client_print(idprint_chat"[JAIL] There are no opponent")
        return 
PLUGIN_HANDLED;
    }
    if(
get_user_team(id) == )
    {    
        new 
lrmenu menu_create("\yLast Request:""sub_lr_menu")
        
        
menu_additem(lrmenu"\wGames""1"0);
        
menu_additem(lrmenu"\wRebel options""2"0);
        
        
menu_setprop(lrmenuMPROP_EXITMEXIT_ALL);
        
menu_display(idlrmenu0);
    }
    return 
PLUGIN_HANDLED;
}    

public 
sub_lr_menu(idlrmenuitem)
{
    
    if (
item == MENU_EXIT)
    {
        
menu_destroy(lrmenu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
Data[7], Name[64];
    new 
AccessCallback;
    
menu_item_getinfo(lrmenuitemAccessData,5Name63Callback);
    
    new 
Key str_to_num(Data);
    
    switch (
Key)
    {
        case 
1:
        {
            
gameslrmenu(id)
        }
        case 
2
        {
            
rebelmenu(id)
        }
    }
    
    
menu_destroy(lrmenu);
    
    return 
PLUGIN_HANDLED;

when the choose a option lr_started is set to true until the ct dies or the round ends

the rebel plugin:
PHP Code:
public client_damage(victimentidattackerFloat:damagedamagebits)
{
    if(!
is_user_connected(victim) || !is_user_connected(attacker))
        return 
HAM_IGNORED
    
    
if(get_pcvar_num(cvar_revolt)) 
    {    
        if(
cs_get_user_team(attacker) == CS_TEAM_T && cs_get_user_team(victim) == CS_TEAM_CT
        {
            if(!
revolt_started)
            {
                if(!
lr_started)
                {
                
start_revolt()
                }
            }    
        }
    }
    return 
HAM_IGNORED
}

public 
start_revolt()
{
    
    
set_hudmessage(random_num(0,255), random_num(0,255), random_num(0,255), -1.00.320.55.0)
    
ShowSyncHudMsg(0hudmessage3"= Prisoners has started a riot! Beware agents =")
    
client_cmd(0,"speak ambience/siren")
    
    
set_task(8.0"stop_sound"0)
    
    
revolt_started true    
}

public 
stop_sound(id)
{
    
client_cmd(id"stopsound")

when the bool lr_started is true, the rebel system cannot start. so can i created something that the rebel plugin knows when lr_started is set to true by the other plugin?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 03-03-2010 at 04:44.
drekes is offline
Send a message via MSN to drekes
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-03-2010 , 08:49   Re: Question about .inc files
Reply With Quote #10

JailBreak plugin that sets lr_started:
Code:
public plugin_natives( ) {     register_library( "jailbreak" );     register_native( "jb_lr_started", "_lr_started" ); } public bool:_lr_started( iPlugin, iParams ) {     return lr_started; }
Create jailbreak.inc and put this inside:
Code:
#if defined _jailbreak_included     #endinput #endif #define _jailbreak_included #if AMXX_VERSION_NUM >= 175     #pragma reqlib jailbreak     #if !defined AMXMODX_NOAUTOLOAD         #pragma loadlib jailbreak     #endif #else     #pragma library jailbreak #endif native bool:jb_lr_started( );
Other plugins (must be after the jailbreak plugin in the plugins.ini):
Code:
#include <jailbreak> public client_damage(victim, entid, attacker, Float:damage, damagebits) {     if(!is_user_connected(victim) || !is_user_connected(attacker))         return HAM_IGNORED         if(get_pcvar_num(cvar_revolt))     {             if(cs_get_user_team(attacker) == CS_TEAM_T && cs_get_user_team(victim) == CS_TEAM_CT)         {             if(!revolt_started)             {                 if(!jb_lr_started())                 {                 start_revolt()                 }             }             }     }     return HAM_IGNORED }

That was with using Dynamic Natives.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 08:39.


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