Raised This Month: $ Target: $400
 0% 

Change secondary weapon to a new one


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-06-2013 , 13:49   Change secondary weapon to a new one
Reply With Quote #1

Hi guys!

I am beginner in programming plugins and that kind of stuff, so please don't judge me so much Thank you!

So I have that:

PHP Code:
public LogEvent_RoundStart2()
{
    
CurrentRound++;
    new 
players[32], playerpnum;
    
get_players(playerspnum"a");
    for(new 
0pnumi++)
    {
        
player players[i];
        if(
is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_G)
        {
            
give_item(player"weapon_deagle")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae")
            
            if (!
get_pcvar_num(g_menu_active))
                return 
PLUGIN_CONTINUE
            
            
if(CurrentRound >= 3)
            {
                
Showrod(player);
            }
        }
    }
    return 
PLUGIN_HANDLED

And I need to make it like, If at the beginning of 1 round player has USP or Glock, script changes it into Deagle and player has only deagle... How can I do that? Thank you!

Last edited by leonardo_; 02-06-2013 at 13:51.
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 02-06-2013 , 14:16   Re: Change secondary weapon to a new one
Reply With Quote #2

PHP Code:
if (!get_pcvar_num(g_menu_active))
                return 
PLUGIN_CONTINUE 
From what i can see, you should use a bool there instead

as for the usp or glock thing, strip their weapons and give them a deagle
EpicMonkey is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-06-2013 , 14:18   Re: Change secondary weapon to a new one
Reply With Quote #3

Strip their weapons first, then give them a weapon.

PHP Code:
if(is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_G)
        {
            
strip_user_weaponsplayer)
            
give_item(player"weapon_deagle")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae"
                        
            
if (!get_pcvar_num(g_menu_active))
                return 
PLUGIN_CONTINUE
            
            
if(CurrentRound >= 3)
            {
                
Showrod(player);
            }
        }
    } 
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 02-06-2013 , 14:24   Re: Change secondary weapon to a new one
Reply With Quote #4

Quote:
Originally Posted by wickedd View Post
Strip their weapons first, then give them a weapon.

PHP Code:
if(is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_G)
        {
            
strip_user_weaponsplayer)
            
give_item(player"weapon_deagle")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae"
                        
            
if (!get_pcvar_num(g_menu_active))
                return 
PLUGIN_CONTINUE
            
            
if(CurrentRound >= 3)
            {
                
Showrod(player);
            }
        }
    } 
do i remember it right that "strip_user_weapons()" also drop knife?
.Dare Devil. is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-06-2013 , 15:24   Re: Change secondary weapon to a new one
Reply With Quote #5

Quote:
Originally Posted by .Dare Devil. View Post
do i remember it right that "strip_user_weapons()" also drop strips knife?
Yes it does. He can give it back to them;
PHP Code:
give_itemplayer"weapon_knife" 
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.

Last edited by wickedd; 02-06-2013 at 15:26.
wickedd is offline
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-06-2013 , 19:07   Re: Change secondary weapon to a new one
Reply With Quote #6

Quote:
Originally Posted by wickedd View Post
Strip their weapons first, then give them a weapon.

PHP Code:
if(is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_G)
        {
            
strip_user_weaponsplayer)
            
give_item(player"weapon_deagle")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae"
                        
            
if (!get_pcvar_num(g_menu_active))
                return 
PLUGIN_CONTINUE
            
            
if(CurrentRound >= 3)
            {
                
Showrod(player);
            }
        }
    } 

PHP Code:
strip_user_weaponsplayer
what should I do there? Do I change ( player) into something?

Because when I compile it, It gives me 1 warning on that line... What should I do?

and when I deleted that line:
PHP Code:
strip_user_weaponsplayer
It doesn't show an error.

Last edited by leonardo_; 02-06-2013 at 19:18.
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 02-06-2013 , 19:17   Re: Change secondary weapon to a new one
Reply With Quote #7

Whats the warning?

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

const OFFSET_PRIMARYWEAPON 116;
const 
OFFSET_C4_SLOT 372;

StripUserWeapons(id)
{
    new 
iC4Ent get_pdata_cbase(idOFFSET_C4_SLOT);
    
    if( 
iC4Ent )
    {
        
set_pdata_cbase(idOFFSET_C4_SLOTFM_NULLENT);
    }

    
strip_user_weapons(id);
    
give_item(id"weapon_knife");
    
set_pdata_int(idOFFSET_PRIMARYWEAPON0);

    if( 
iC4Ent )
    {
        
entity_set_int(idEV_INT_weaponsentity_get_int(idEV_INT_weapons) | (1<<CSW_C4));
        
set_pdata_cbase(idOFFSET_C4_SLOTiC4Ent);
        
cs_set_user_bpammo(idCSW_C41);
        
cs_set_user_plant(id1);
    }
    return 
PLUGIN_HANDLED;

This stock is from Conor If the player has the C4 it will give him the c4 back so that you dont strip that.. and of course the knife also
Doc-Holiday is offline
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-06-2013 , 19:25   Re: Change secondary weapon to a new one
Reply With Quote #8

Quote:
Originally Posted by Doc-Holiday View Post
Whats the warning?

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

const OFFSET_PRIMARYWEAPON 116;
const 
OFFSET_C4_SLOT 372;

StripUserWeapons(id)
{
    new 
iC4Ent get_pdata_cbase(idOFFSET_C4_SLOT);
    
    if( 
iC4Ent )
    {
        
set_pdata_cbase(idOFFSET_C4_SLOTFM_NULLENT);
    }

    
strip_user_weapons(id);
    
give_item(id"weapon_knife");
    
set_pdata_int(idOFFSET_PRIMARYWEAPON0);

    if( 
iC4Ent )
    {
        
entity_set_int(idEV_INT_weaponsentity_get_int(idEV_INT_weapons) | (1<<CSW_C4));
        
set_pdata_cbase(idOFFSET_C4_SLOTiC4Ent);
        
cs_set_user_bpammo(idCSW_C41);
        
cs_set_user_plant(id1);
    }
    return 
PLUGIN_HANDLED;

This stock is from Conor If the player has the C4 it will give him the c4 back so that you dont strip that.. and of course the knife also
that warning:


and line 144 is that one:

PHP Code:
strip_user_weapons(player



And tried that code:
PHP Code:
 for(new 0pnumi++)
    {
        
player players[i];
        if(
is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_G)
        {
            
strip_user_weaponsplayer)
            
give_item(player"weapon_deagle")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae")
            
give_item(player"ammo_50ae")
            
give_item(player"weapon_knife")
            
            if (!
get_pcvar_num(g_menu_active))
                return 
PLUGIN_CONTINUE
            
            
if(CurrentRound >= 3)
            {
                
Showrod(player);
            }
        }
    } 
and I didn't have anything, just deagle... even knife was deleted, like the menu that usually shows on the top-left of the screen was deleted too... Like when you choosing between knife and primary weapon it shows you a yellow menu on the top, and with that code it didn't show me anything...

Can anyone help me to fix that...

Last edited by leonardo_; 02-06-2013 at 20:00.
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-07-2013 , 02:19   Re: Change secondary weapon to a new one
Reply With Quote #9

You can ignore that warning or if you really want to fix search for "loose indentation". Also, strip_user_weapons will remove ALL weapons from players. To give them a knife just add the code below to your plugin.
PHP Code:
give_itemplayer"weapon_knife" 
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 02-07-2013 , 04:13   Re: Change secondary weapon to a new one
Reply With Quote #10

loose identation usually means that your code looks like this: (note that code itself is the same)
Code:
{
	if(player)
	{
	if(g_bSolid[host] && g_bSolid[ent] && get_distance_f( g_fOrigin[host], g_fOrigin[ent] ) <= 10000)
	{
	if(get_pcvar_num(g_iCvar[1]) && g_iTeam[host] != g_iTeam[ent])
	return FMRES_IGNORED;
	set_es(es_handle, ES_Solid, SOLID_NOT); // makes semiclip flawless
It should be:
Code:
	if(player)
	{
		if(g_bSolid[host] && g_bSolid[ent] && get_distance_f( g_fOrigin[host], g_fOrigin[ent] ) <= 10000)
		{
			if(get_pcvar_num(g_iCvar[1]) && g_iTeam[host] != g_iTeam[ent])
			return FMRES_IGNORED;
			set_es(es_handle, ES_Solid, SOLID_NOT); // makes semiclip flawless
Also, post your complete code and tell me again what is the problem because i can't understand you right now.
__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.

Last edited by naven; 02-07-2013 at 04:14.
naven 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 20:31.


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