Raised This Month: $ Target: $400
 0% 

[SOLVED]to give unlimited he grenade?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sabrioz
Senior Member
Join Date: Apr 2009
Old 08-21-2009 , 20:14   [SOLVED]to give unlimited he grenade?
Reply With Quote #1

hello i'm newbie in scriptng..

can you help me by showing the script that will give unlimited he grenade..

i have try try this script but it doesn't work..

PHP Code:
public giveheifnothas(id) {
    new 
nades cs_get_user_bpammo(idCSW_HEGRENADE)
    if (
nades == 0) {
        
give_item(id"weapon_hegrenade")
        
cs_set_user_bpammo(idCSW_HEGRENADENADEAMOUNT)
    }
    else if (
nades == 1) {
        
cs_set_user_bpammo(idCSW_HEGRENADENADEAMOUNT)
    }

    return 
PLUGIN_CONTINUE

i want the script that allow player to use HE grenade only..(unlimited grenade)

Last edited by sabrioz; 02-12-2010 at 08:19. Reason: Problem Solved
sabrioz is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 08-21-2009 , 20:21   Re: HOW to give unlimited he grenade?
Reply With Quote #2

PHP Code:
public giveheifnothas(id) {
     if (!
user_has_weapon(idCSW_HEGRENADE) {
        
give_item(id"weapon_hegrenade")
        
cs_set_user_bpammo(idCSW_HEGRENADENADEAMOUNT)
    }
    else 
         
cs_set_user_bpammo(idCSW_HEGRENADENADEAMOUNT)

    return 
PLUGIN_CONTINUE

__________________
alan_el_more is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-21-2009 , 20:58   Re: HOW to give unlimited he grenade?
Reply With Quote #3

Slight optimization
PHP Code:
public giveheifnothas(id
{
    if ( !
user_has_weaponid CSW_HEGRENADE ) )
        
give_itemid "weapon_hegrenade" );

    
cs_set_user_bpammo(idCSW_HEGRENADENADEAMOUNT);

Do not use what phoenix120 posted. This can be done much more efficiently.

This is the simplest way that requires little\no scripting knowledge. The only requirement is that the player needs to be given or purchase the first grenade (which can be done @ spawn)
PHP Code:
#include <csx>

public grenade_throwid greindex wId 
{
    if ( 
wId == CSW_HEGRENADE )
        
cs_set_user_bpammoid CSW_HEGRENADENADEAMOUNT);

Here's a full unlimited he-grenade plugin; the user is given a grenade when spawned so no purchase necessary. Since grenades are unlimited, the variable g_GrenadeNum simply is just the number that will display as the ammo amount for he-grenades (though, must be > 0).
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <csx>
#include <fun>

const g_GrenadeNum 5;

public 
plugin_init() 
{
    
register_plugin"unlimited hegrenades" "1.0" "bugsy" );
    
RegisterHamHam_Spawn "player" "fw_HamSpawn_Post" );
}

public 
fw_HamSpawn_Postid )
{
    if ( 
is_user_aliveid ) )
    {
        
give_itemid "weapon_hegrenade" );
        
cs_set_user_bpammoid CSW_HEGRENADE g_GrenadeNum );
    }
}

public 
grenade_throwid greindex wId 
{
    if ( 
wId == CSW_HEGRENADE )
        
cs_set_user_bpammoid CSW_HEGRENADE g_GrenadeNum );

__________________

Last edited by Bugsy; 08-22-2009 at 10:43.
Bugsy is offline
phoenix120
Junior Member
Join Date: Aug 2009
Location: Czech Republic
Old 08-21-2009 , 20:23   Re: HOW to give unlimited he grenade?
Reply With Quote #4

try this:

Code:
public client_PreThink(id)
{
    new nades = cs_get_user_bpammo(id,CSW_HEGRENADE);
    
    if(nades == 0)
        give_item(id,"weapon_hegrenade");
        
}
phoenix120 is offline
Send a message via ICQ to phoenix120
sabrioz
Senior Member
Join Date: Apr 2009
Old 08-22-2009 , 01:18   Re: HOW to give unlimited he grenade?
Reply With Quote #5

ok guys thanks...

i will try you script..

thank for the help..

i'm newbie here..
if i got more problem i will ask you again..
byeee
sabrioz is offline
sabrioz
Senior Member
Join Date: Apr 2009
Old 08-22-2009 , 01:46   Re: HOW to give unlimited he grenade?
Reply With Quote #6

dear Bugsy

how to make that player must use HE grenade (unlimited) only..

block using all weapon..
force / allow player to use HE grenade only..

ok thanks
sabrioz is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-22-2009 , 06:06   Re: HOW to give unlimited he grenade?
Reply With Quote #7

You want the client to have his weapons or only the grenades?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
sabrioz
Senior Member
Join Date: Apr 2009
Old 08-22-2009 , 06:14   Re: HOW to give unlimited he grenade?
Reply With Quote #8

Quote:
Originally Posted by ot_207 View Post
You want the client to have his weapons or only the grenades?
i mean..
client have grenade only..

client must use HE grenade only
sabrioz is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-22-2009 , 06:17   Re: HOW to give unlimited he grenade?
Reply With Quote #9

Quote:
Originally Posted by sabrioz View Post
i mean..
client have grenade only..

client must use HE grenade only
No weapons, just HE?
If you want the user just to have He_Grenades then use this function ->
PHP Code:
#include <fakemeta> 
#include <fun> 

#define OFFSET_PRIMARYWEAPON        116 

public StripPlayerWeapons(id

    
strip_user_weapons(id
    
set_pdata_int(idOFFSET_PRIMARYWEAPON0

Before giving player grenades.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 08-22-2009 at 06:21.
ot_207 is offline
sabrioz
Senior Member
Join Date: Apr 2009
Old 08-22-2009 , 11:00   Re: HOW to give unlimited he grenade?
Reply With Quote #10

i want to modify this plugin

and make it to HE only vote plugin..

i want to change the knife to HE..

but the result is my modify plugin failed..
when i vote for HE only
the primary and secondary weapon still can use..i want to block all weapon
and make client to use HE grenade only..

here i attach my modify script
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <csx>
#include <fakemeta>
#include <fun>

new vote
new votes
new players[32]
new 
he_rounds
new he_cooldown
new show[6]

#define CHANNEL 4
#define OFFSET_PRIMARYWEAPON 116  
#define NADEAMOUNT 2

public plugin_init() {
    
register_plugin("Vote HE Plugin""1.0""Rains/sabrioz")
    
    
register_cvar("amx_vote_he","1"// Turns plugin on
    
register_cvar("amx_vote_he_time","25.0"// How long time people can vote
    
register_cvar("amx_vote_he_ratio","0.5"// How many votes needed for he only
    
register_cvar("amx_vote_he_rounds","2"// How many rounds it will be he only
    
register_cvar("amx_vote_he_hud","1"// Set hudmessage on/off
    
register_cvar("amx_vote_he_cooldown","4"// How many rounds it will wait between he only and next vote
    
    
if (get_cvar_num("amx_vote_he") == 1)
        {
        
register_event("ResetHUD""hook_hud""be")
        
register_event("CurWeapon""cur_weapon""be""1=0""2=29")
        
register_clcmd("say /heg""he_vote")
        
register_clcmd("say /votehe""he_vote")
    }
}

public 
hook_hud(id)
    {
    if (
get_cvar_num("amx_vote_he") == 1)
        {
        if (
he_rounds 0)
            
vote 0
        
else if (he_cooldown 0)
            {
            
vote 2
            
if (show[5] == 0)
                
he_cooldown -= 1
            show
[5] = 1
            set_task
(5.0"reset_show")
        }
        else
        
vote 1
        
        
if (vote == 0)
            {
            if (
get_cvar_num("amx_vote_he_hud") == 1)
                {
                
set_hudmessage(255255255, -1.00.306.05.00.10.2CHANNEL)
                
show_hudmessage(id"HE only for %i more rounds!"he_rounds)
            }
            if (
show[0] == 0)
                
client_print(0,print_chat,"[HE] HE only for %i more rounds!"he_rounds)
            
show[0] = 1
            
if (show[5] == 0)
                
he_rounds -= 1
            show
[5] = 1
            set_task
(5.0"reset_show")
            
cur_weapon(id)
        }
        else if (
vote == 1)
            {
            
set_task(get_cvar_float("amx_vote_he_time"),"check_vote")
            new 
i
            
for (i=0;i<32;i++)
                {
                
players[i] = 0
            
}
            
votes 0
            
if (get_cvar_num("amx_vote_he_hud") == 1)
                {
                
set_hudmessage(255255255, -1.00.306.05.00.10.2CHANNEL)
                
show_hudmessage(id"[HE] Write /votehe to vote for HE only!^nYou have %i seconds to vote!"get_cvar_num("amx_vote_he_time"))
            }
            if (
show[1] == 0)
                
client_print(0,print_chat,"[HE] Write /votehe to vote for HE only! You have %i seconds to vote!"get_cvar_num("amx_vote_he_time"))
            
show[1] = 1
        
}
        else if(
vote == 2)
            {
            if (
get_cvar_num("amx_vote_he_hud") == 1)
                {
                
set_hudmessage(255255255, -1.00.306.05.00.10.2CHANNEL)
                
show_hudmessage(id"[HE] Normal play for %i more rounds!^nThen you will be able to vote again!", (he_cooldown+1))
            }
            if (
show[2] == 0)
                
client_print(0,print_chat,"[HE] Normal play for %i more rounds! Then you will be able to vote again!", (he_cooldown+1))
            
show[2] = 1
        
}
    }
}

public 
he_vote(id)
    {
    if (
get_cvar_num("amx_vote_he") == 1)
        {
        if (
players[id] == && vote == 1)
            {
            if (
get_cvar_num("amx_vote_he_hud") == 1)
                {
                
set_hudmessage(255255255, -1.00.306.05.00.10.2CHANNEL)
                
show_hudmessage(id"[HE] You can't vote more than one time!")
            }
            
client_print(id,print_chat,"[HE] You can't vote more than one time!")
        }
        else if (
players[id] == && vote == 1)
            {
            if (
get_cvar_num("amx_vote_he_hud") == 1)
                {
                
set_hudmessage(255255255, -1.00.306.05.00.10.2CHANNEL)
                
show_hudmessage(id"[HE] You have succesfully voted!")
            }
            
client_print(id,print_chat,"[HE] You have succesfully voted!")
            
votes votes+1
            players
[id] = 1
        
}
        else
        {
            if (
get_cvar_num("amx_vote_he_hud") == 1)
                {
                
set_hudmessage(255255255, -1.00.306.05.00.10.2CHANNEL)
                
show_hudmessage(id"[HE] You can't vote!")
            }
            
client_print(id,print_chat,"[HE] You can't vote!")
        }
    }
}

public 
check_vote(id)
    {
    if (
get_cvar_num("amx_vote_he") == 1)
        {
        
vote 0
        
new i
        
new check 0
        
for (i=0;i<32;i++)
            {
            if (
is_user_connected(i))
                
check check 1
        
}
        if (
floatround(votes/get_cvar_float("amx_vote_he_ratio"))>=check)
            {
            
he_rounds get_cvar_num("amx_vote_he_rounds")
            
he_cooldown get_cvar_num("amx_vote_he_cooldown")
            if (
get_cvar_num("amx_vote_he_hud") == 1)
                {
                
set_hudmessage(255255255, -1.00.306.05.00.10.2CHANNEL)
                
show_hudmessage(id"[HE] Voting succeded!^nNext %i rounds will be HE only"get_cvar_num("amx_vote_he_rounds"))
            }
            if (
show[3] == 0)
                
client_print(0,print_chat,"[HE] Voting succeded! Next %i rounds will be HE only"get_cvar_num("amx_vote_he_rounds"))
            
show[3] = 1
        
}
        else
        {
            if (
get_cvar_num("amx_vote_he_hud") == 1)
                {
                
set_hudmessage(255255255, -1.00.306.05.00.10.2CHANNEL)
                
show_hudmessage(id"[HE] Voting failed, to few votes.")
            }
            if (
show[4] == 0)
                
client_print(0,print_chat,"[HE] Voting failed, to few votes.")
            
show[4] = 1
        
}
    }
}

public 
cur_weapon(id
{
    if (
get_cvar_num("amx_vote_he") == && he_rounds && he_rounds get_cvar_num("amx_vote_he_rounds") || he_cooldown == get_cvar_num("amx_vote_he_cooldown"))
    
strip_user_weapons(id)  
        
set_pdata_int(idOFFSET_PRIMARYWEAPON0)    
        {
        
engclient_cmd(id,"weapon_hegrenade")
        }
    

}

public 
grenade_throwid greindex wId 
{
    if (
get_cvar_num("amx_vote_he") == && he_rounds && he_rounds get_cvar_num("amx_vote_he_rounds") &&  wId == CSW_HEGRENADE  || he_cooldown == get_cvar_num("amx_vote_he_cooldown"))
        
cs_set_user_bpammoid CSW_HEGRENADENADEAMOUNT);



public 
reset_show()
    {
    if (
get_cvar_num("amx_vote_he") == 1)
        {
        new 
i
        
for (i=0;i<6;i++)
            {
            
show[i] = 0
        
}
    }

so hope you can fix the bug for this plugin.
this is my first time to learn about scripting

Last edited by sabrioz; 08-22-2009 at 11:03.
sabrioz 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 15:07.


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