AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]to give unlimited he grenade? (https://forums.alliedmods.net/showthread.php?t=101214)

sabrioz 08-21-2009 20:14

[SOLVED]to give unlimited he grenade?
 
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)

alan_el_more 08-21-2009 20:21

Re: HOW to give unlimited he grenade?
 
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



phoenix120 08-21-2009 20:23

Re: HOW to give unlimited he grenade?
 
try this:

Code:

public client_PreThink(id)
{
    new nades = cs_get_user_bpammo(id,CSW_HEGRENADE);
   
    if(nades == 0)
        give_item(id,"weapon_hegrenade");
       
}


Bugsy 08-21-2009 20:58

Re: HOW to give unlimited he grenade?
 
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 );



sabrioz 08-22-2009 01:18

Re: HOW to give unlimited he grenade?
 
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 08-22-2009 01:46

Re: HOW to give unlimited he grenade?
 
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

ot_207 08-22-2009 06:06

Re: HOW to give unlimited he grenade?
 
You want the client to have his weapons or only the grenades?

sabrioz 08-22-2009 06:14

Re: HOW to give unlimited he grenade?
 
Quote:

Originally Posted by ot_207 (Post 908914)
You want the client to have his weapons or only the grenades?

i mean..
client have grenade only..

client must use HE grenade only

ot_207 08-22-2009 06:17

Re: HOW to give unlimited he grenade?
 
Quote:

Originally Posted by sabrioz (Post 908919)
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.

sabrioz 08-22-2009 11:00

Re: HOW to give unlimited he grenade?
 
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 :shock:


All times are GMT -4. The time now is 15:07.

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