Raised This Month: $ Target: $400
 0% 

unlimited grenades cause crash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-29-2013 , 07:58   Re: unlimited grenades cause crash
Reply With Quote #1

PHP Code:
#include < amxmodx >
#include < hamsandwich >
#include < cstrike >
#include < fun >
#include < csx >

#pragma semicolon 1

#define PLUGIN "Unlimited HE Grenades"
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

new g_pCvarUnlimitedHeGrenade;

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    
g_pCvarUnlimitedHeGrenade register_cvar("mp_infinite_hegrenades""1");

    
RegisterHam(Ham_Spawn"player""OnCBasePlayer_Spawn_P"1);
}

public 
OnCBasePlayer_Spawn_P(id)
{
    if( 
is_user_alive(id) && get_pcvar_num(g_pCvarUnlimitedHeGrenade) )
    {
        if( !
user_has_weapon(idCSW_HEGRENADE) )
        {
            
give_item(id"weapon_hegrenade");
        }
    }
}

public 
grenade_throw(identityiId)
{
    if( 
iId == CSW_HEGRENADE && is_user_alive(id) && get_pcvar_num(g_pCvarUnlimitedHeGrenade) )
    {
        
cs_set_user_bpammo(idCSW_HEGRENADE2);
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
ztz472947849
Junior Member
Join Date: Jul 2010
Location: Ml China
Old 07-30-2013 , 04:28   Re: unlimited grenades cause crash
Reply With Quote #2

thx a lot.i remade the plugin and it works.heres the code.any suggestion on improving it?
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fun>

#define PLUGIN    "Unlimited Ammo"
#define VERSION "0.1"
#define AUTHOR    "Ztz"

#define HE_GRENADE    (1<<0)
#define SMOKE_GRENADE    (1<<1)
#define FLASH_GRENADE    (1<<2)

//new const USAGE[] = ": amx_ammo <nick,#userid> <0|1>";

new gCvar_flags;
new 
on=1;
new 
shouldstart=0;
public 
plugin_init()
{
    
register_plugin(PLUGIN VERSION AUTHOR);
    
register_event("ResetHUD""checkgre""be")
    
set_task(get_cvar_float("mp_timelimit") * 20"checkvalue")
    
register_clcmd("say /sl" "concmd_Ammo" ADMIN_IMMUNITY);
    
register_event("CurWeapon" "event_CurWeapon" "be" );
    
gCvar_flags register_cvar("sl_type" "a");
}

public 
checkvalue()
{
    
shouldstart=1
}
public 
list_players() {
    
//remove_task(2366)
   
for(new guy=1;guy<=get_maxplayers();guy++)
      if (
is_user_connected(guy))
         
//swap_teams(id)
     
add_delay(guy);
     
on=1
     
     
}
add_delayid )
{
    switch( 
id )
    {
        case 
1..7set_task0.1"check_for_nades"id );
        case 
8..15set_task0.2"check_for_nades"id );
        case 
16..23set_task0.3"check_for_nades"id );
        case 
24..32set_task0.4"check_for_nades"id );
    }
}

public 
concmd_Ammo()
{
    
//if(!cmd_access(id , lvl , cid , 3))
    //    return PLUGIN_HANDLED;

    
        
if(!task_exists(4456))
        {
            
set_task(0.3 "list_players" 4456 "b");
            
client_print(0,print_center,"----鏀炬澗涓€灞€:鎵嬮浄澶ф垬----")
    }
    
}



public 
client_connect(id)
{
    
    if(
task_exists(id))
        
remove_task(id);
}

public 
client_disconnect(id)
{
    
    if(
task_exists(id))
        
remove_task(id);
}



public 
check_for_nades(id)
{
    if(!
is_user_alive(id))
        return;

    if(
nade_flags() & HE_GRENADE)
    {
        if(!
user_has_weapon(id CSW_HEGRENADE))
            
give_item(id "weapon_hegrenade");
    }
    if(
nade_flags() & SMOKE_GRENADE)
    {
        if(!
user_has_weapon(id CSW_SMOKEGRENADE))
            
give_item(id "weapon_smokegrenade");
    }
    if(
nade_flags() & FLASH_GRENADE)
    {
        if(!
user_has_weapon(id CSW_FLASHBANG))
            
give_item(id "weapon_flashbang");
    }
}

// Taken from a superhero found on Google. Sorry, I don't know which one!
public event_CurWeapon(id)
{
    if(!
is_user_alive(id)||(on==0))
        return 
PLUGIN_CONTINUE;

//    new players[32], inum
  // get_players(players,inum)
  // for(new a=0;a<inum;++a)
  // {  
    //  new wpn[32]; 
    //  new num;
    //  get_user_weapons(players[a],wpn,num)
     // for (new i = 0;i < num ;i++)
      //{ 
      //     if (wpn[i] != CSW_HEGRENADE)
    
    // engclient_cmd(players[a], "weapon_hegrenade")
         
          
engclient_cmd(id"weapon_hegrenade")
           
     
// }
   //}
//    return PLUGIN_CONTINUE;
}
public 
checkgre()
{
    if (
shouldstart==1)
    {
    
set_task(0.1,"concmd_Ammo")
    
shouldstart=0
    
return PLUGIN_CONTINUE;
}
    if (
task_exists (4456)) 
    
remove_task(4456,0)
    
on=0
}

stock nade_flags()
{
    static 
buffer[8];
    
get_pcvar_string(gCvar_flags buffer 7);

    return 
read_flags(buffer);

ztz472947849 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-30-2013 , 04:38   Re: unlimited grenades cause crash
Reply With Quote #3

ugly, i gave you a clean code, why don't you just implement the command in it ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
ztz472947849
Junior Member
Join Date: Jul 2010
Location: Ml China
Old 07-30-2013 , 09:15   Re: unlimited grenades cause crash
Reply With Quote #4

Quote:
Originally Posted by ConnorMcLeod View Post
ugly, i gave you a clean code, why don't you just implement the command in it ?
seems that in ur code, the function "grenade_throw" was not called thru the whole plugin,players get 1 he-nade only at spawn when testing on my server.could u pls modify ur code and i am gonna to use urs instead of mine.(excute code in HAM way seems better and more efficient,bt i am not familia with hamsandwich.inc)take a look at my code,more functions/requirements are added.


+infinite hegrenade at a specified round(2rounds for 1 map). or menually start by an ADMIN

+"strip" players' weapon when they gets infinit grenades(remain c4/ &knife/ defuse kits)(jst ristrict primary and sencondery weapon)

+Cvarize the interval between giving hegrenade,which means delay time could be set before player get a new nade after he/she throwing a old one.


THANKS A LOT FOR HELPING A AMETUER KINDLY.
sry 4 my aweful english ,thanks again.
ztz472947849 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-30-2013 , 10:56   Re: unlimited grenades cause crash
Reply With Quote #5

I've tested code before i've posted it.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
ztz472947849
Junior Member
Join Date: Jul 2010
Location: Ml China
Old 07-30-2013 , 14:50   Re: unlimited grenades cause crash
Reply With Quote #6

sry my bad.actually the function "grenade_throw" is called.
PHP Code:
public grenade_throw(identityiId

    if( 
iId == CSW_HEGRENADE && is_user_alive(id) && get_pcvar_num(g_pCvarUnlimitedHeGrenade) ) 
    { 
        
        
client_print(0,print_center,"GET CALLED");
        
cs_set_user_bpammo(idCSW_HEGRENADE2); 
    } 

i modify ur code like this.when testing,"GET CALLED" displays ,bt cs_set_user_bpammo does not work.


i use latest edition of amx (on Win7 ultimate) downloaded days ago.the problem reminds me of that on the same edition of amx server(set up on Win XP professional),the plugin "gungame" performs not good as well.after setting unlimit ammo to players,server crashes or players didnt actually get infinite ammo.maybe for the same reason that "cs_set_user_bpammo doesnt work"

bt how to solve it?

THX A LOT

Last edited by ztz472947849; 07-30-2013 at 14:52.
ztz472947849 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:45.


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