Raised This Month: $32 Target: $400
 8% 

WeapPickup not working!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 07-06-2020 , 10:02   WeapPickup not working!
Reply With Quote #1

Hey, so all VIP menu plugins that I saw were hardcoded and I wanted to make my own for my purposes, everything was fine, but when I tried to add that no one can pick up AWP, other than VIP's it didn't work, I added so neither players and VIP's can't have AWP on smaller maps as de_dust2_2x2 or de_dust2_long, but I don't know why it doesn't work. Nothing in debug too
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <cromchat> 

#define VERSION "0.9"

new g_HasVIP[33];
new 
g_mapname[32];
new 
g_AWP_WPN[33];
new 
g_AWPg_MENUg_roundnumberg_FLAGg_AWP_ROUNDS

public 
plugin_init() 
{
    
register_plugin("VIP Plugin By BOOPSY!"VERSION"Mr. Boopsy");

    
g_FLAG register_cvar("vip_flag""t"); //koji je flag za vipa
    
g_AWP_ROUNDS register_cvar("vip_awp_rounds""5"); //posle koliko rundi moze awp
    
g_AWP register_cvar("vip_awp_only""1"); // rest menu ce lepo da radi tek posle rr mape
    
g_MENU register_cvar("vip_menu""1"); //da li vipovi dobijaju menu
    
register_clcmd("say /test""test")

    
g_roundnumber 0;

    
register_event("HLTV""round_check""a""1=0""2=0");
    
register_event("TextMsg""round_restart""a""2=#Game_Commencing""2=#Game_will_restart_in");

    
register_event("WeapPickup""cmd_WaitAWP""be""1=18");
    
RegisterHam(Ham_Spawn"player""OnPlayerSpawn"1);

    if(
get_pcvar_num(g_AWP) == 1
    {
        
server_cmd("amx_restrict on awp");//mora da se radi preko restmenu plugina, tkd on mora da bude upaljen
    
}
    else
    {
        
server_cmd("amx_restrict off awp");
    }
}

public 
plugin_cfg()
{
    
get_mapname(g_mapnamecharsmax(g_mapname));
}

public 
test(id)
{
    
strip_user_weapons (id)
    
give_item(id,"weapon_awp")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"weapon_deagle")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"weapon_knife")
    
give_item(id,"weapon_hegrenade")
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_flashbang");
    
give_item(id"weapon_smokegrenade");
    
give_item(id"item_assaultsuit");
    
give_item(id"item_thighpack");
    
CC_SendMessage(id"&x01>> &x04Izabrali ste &x07M4A1+Deagle&x04! %s"g_mapname);
}

public 
client_putinserver(id)
{
    new 
flag[10];
    
get_pcvar_string(g_FLAGflagcharsmax(flag));
    if(
has_flag(idflag))
    {
        
g_HasVIP[id] = 1;
    }
    else
    {
        
g_HasVIP[id] = 0;
    }
}

public 
round_check()
{
    
g_roundnumber++;
}

public 
round_restart()
{
    
g_roundnumber 0;


public 
OnPlayerSpawn(id)
{
    if(
g_HasVIP[id] == && is_user_alive(id))
    {
        
give_item(id"weapon_hegrenade");
        
give_item(id"weapon_flashbang");
        
give_item(id"weapon_flashbang");
        
give_item(id"weapon_smokegrenade");
        
give_item(id"item_assaultsuit");
        
give_item(id"item_thighpack");
        if(
get_pcvar_num(g_MENU) == && g_roundnumber >= 3)
        {
            
vip_menu(id);
        }
    }
}

public 
vip_menu(id)
{
    new 
vip_menu menu_create("\r[\wVIP\r]\w Izaberi Oruzije""menu_vip")
    
    
menu_additem(vip_menu"\r - [\wM4A1+Deagle\r]""1"0)
    
menu_additem(vip_menu"\r - [\wAK47+Deagle\r]""2"0)
    if(
g_roundnumber >= get_pcvar_num(g_AWP_ROUNDS))
    {
        
menu_additem(vip_menu"\r - [\wAWP+Deagle\r]""3"0)
    }
    else
    {
        
menu_additem(vip_menu"\d - [AWP+Deagle]""3"0)
    }

    
    
menu_setprop(vip_menuMPROP_EXITMEXIT_ALL)
    
menu_setprop(vip_menuMPROP_NUMBER_COLOR"\r>> \y")
    
    
menu_display(idvip_menu0)
}

public 
menu_vip(idvip_menuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(vip_menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], iName[64]
    new 
accescallback
    menu_item_getinfo
(vip_menuitemaccesdata,5iName63callback)
    
    new 
key str_to_num(data)
    
    switch(
key)
    { 
       case 
1
       {
            
strip_user_weapons (id)
            
give_item(id,"weapon_m4a1")
            
give_item(id,"ammo_556nato")
            
give_item(id,"ammo_556nato")
            
give_item(id,"ammo_556nato")
            
give_item(id,"weapon_deagle")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"weapon_knife")
            
give_item(id,"weapon_hegrenade")
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_smokegrenade");
            
give_item(id"item_assaultsuit");
            
give_item(id"item_thighpack");
            
CC_SendMessage(id"&x01>> &x04Izabrali ste &x07M4A1+Deagle&x04!");
       }
       case 
2
       {
            
strip_user_weapons (id)
            
give_item(id,"weapon_ak47")
            
give_item(id,"ammo_762nato")
            
give_item(id,"ammo_762nato")
            
give_item(id,"ammo_762nato")
            
give_item(id,"weapon_deagle")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"ammo_50ae")
            
give_item(id,"weapon_knife")
            
give_item(id,"weapon_hegrenade")
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_flashbang");
            
give_item(id"weapon_smokegrenade");
            
give_item(id"item_assaultsuit");
            
give_item(id"item_thighpack");
            
CC_SendMessage(id"&x01>> &x04Izabrali ste &x07AK47+Deagle&x04!");
       }
       case 
3:
       {
            if(
equali(g_mapname"de_dust2_2x2") || equali(g_mapname"de_dust2_long"))
            {
                
set_task(0.1"vip_menu"id);
                
CC_SendMessage(id"&x01>> &x04AWP je zabranjen na malim mapama!");
            }
            else if(
g_roundnumber >= get_pcvar_num(g_AWP_ROUNDS))
            {
                
strip_user_weapons (id)
                
give_item(id,"weapon_awp")
                
give_item(id,"ammo_338magnum")
                
give_item(id,"ammo_338magnum")
                
give_item(id,"ammo_338magnum")
                
give_item(id,"weapon_deagle")
                
give_item(id,"ammo_50ae")
                
give_item(id,"ammo_50ae")
                
give_item(id,"ammo_50ae")
                
give_item(id,"ammo_50ae")
                
give_item(id,"ammo_50ae")
                
give_item(id,"ammo_50ae")
                
give_item(id,"ammo_50ae")
                
give_item(id,"weapon_knife")
                
give_item(id,"weapon_hegrenade")
                
give_item(id"weapon_flashbang");
                
give_item(id"weapon_flashbang");
                
give_item(id"weapon_smokegrenade");
                
give_item(id"item_assaultsuit");
                
give_item(id"item_thighpack");
                
CC_SendMessage(id"&x01>> &x04Izabrali ste &x07AWP+Deagle&x04!");
            }
            else if(
g_roundnumber get_pcvar_num(g_AWP_ROUNDS))
            {
                
set_task(0.1"vip_menu"id);
                
CC_SendMessage(id"&x01>> &x04AWP je dozvoljen samo posle &x07pete &x04runde!");
            }
       }
    }
    
menu_destroy(vip_menu)
    return 
PLUGIN_HANDLED
}

public 
cmd_WaitAWP(id)
{
    if(
g_AWP == 1)
    {
        if(
equali(g_mapname"de_dust2_2x2") || equali(g_mapname"de_dust2_long"))
        {
            
g_AWP_WPN[id] = 1;
            
set_task(0.1"cmd_CheckSniper"id);
        }
        else if(
g_HasVIP[id] != 1)
        {
            
g_AWP_WPN[id] = 1;
            
set_task(0.1"cmd_CheckSniper2"id);
        }
    }
}

public 
cmd_CheckSniper(id)
{
    if(
g_AWP_WPN[id] == 1)
    {
        
console_cmd(id,"drop weapon_awp");
        
g_AWP_WPN[id] = 0;
        
CC_SendMessage(id"&x01>> &x04AWP je zabranjen na malim mapama!");
    }    
}

public 
cmd_CheckSniper2(id)
{
    if(
g_AWP_WPN[id] == 1)
    {
        
console_cmd(id,"drop weapon_awp");
        
g_AWP_WPN[id] = 0;
        
CC_SendMessage(id"&x01>> &x04AWP je dozvoljen samo za &x07VIP-ove&x04!");
    }    
}

#if AMXX_VERSION_NUM < 190
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    
g_HasVIP[id] = 0;

__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-06-2020 , 10:07   Re: WeapPickup not working!
Reply With Quote #2

https://wiki.alliedmods.net/Half-Lif...nts#WeapPickup

Code:
public cmd_WaitAWP(id)

The function passes a weapon id, not a player id.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Foxa
Member
Join Date: Nov 2018
Location: Croatia
Old 07-06-2020 , 11:54   Re: WeapPickup not working!
Reply With Quote #3

You're already using HamSandwich so why not just hook Ham_Touch to a "weaponbox" entity, check if the weapon is CSW_AWP and if it is -> HAM_SUPERCEDE

Or even better try this: https://forums.alliedmods.net/showthread.php?t=235139
Foxa is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-06-2020 , 12:31   Re: WeapPickup not working!
Reply With Quote #4

Using WeapPickup for this is a poor solution. You should hook Ham_Touch with weaponbox/armoury_entity, check if they contain an AWP and if so, block.
How do you check that?
For weaponbox entity: Check m_rgpPlayerItems offset(the CWeaponBox offset, not CBasePlayer), slot 1 with get_pdata_cbase. If if returns a valid entity, retrieve the classname with pev_classname and compare it with weapon_awp. If you need more details about this, search, you will find a ton of examples.
For armoury_entity read here: https://forums.alliedmods.net/showthread.php?t=250922
__________________

Last edited by HamletEagle; 07-06-2020 at 12:32.
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-06-2020 , 13:46   Re: WeapPickup not working!
Reply With Quote #5

also use cs_set_user_bpammo rather than call give_item thousand times.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 07-06-2020 , 15:12   Re: WeapPickup not working!
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
Using WeapPickup for this is a poor solution. You should hook Ham_Touch with weaponbox/armoury_entity, check if they contain an AWP and if so, block.
How do you check that?
For weaponbox entity: Check m_rgpPlayerItems offset(the CWeaponBox offset, not CBasePlayer), slot 1 with get_pdata_cbase. If if returns a valid entity, retrieve the classname with pev_classname and compare it with weapon_awp. If you need more details about this, search, you will find a ton of examples.
For armoury_entity read here: https://forums.alliedmods.net/showthread.php?t=250922
PHP Code:
public OnPlayerTouchWeaponBox(entid)
{
    new 
iId cs_get_weapon_id(ent);
    if( 
iId == CSW_AWP )
    {
        if(
equali(g_mapname"de_dust2_2x2") || equali(g_mapname"de_dust2_long"))
        {
            
console_cmd(id,"drop weapon_awp");
            
CC_SendMessage(id"&x01>> &x04AWP je zabranjen na malim mapama!");
        }
        else if(
g_HasVIP[id] != 1)
        {
            
console_cmd(id,"drop weapon_awp");
            
CC_SendMessage(id"&x01>> &x04AWP je zabranjen na malim mapama!");
        }
    }

I tried something like this, but it doesn't work
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-06-2020 , 15:19   Re: WeapPickup not working!
Reply With Quote #7

Ok, now go back and actually read what I said. If you ignore everything I say then I can't do anything.

One more hint: a player touches a weaponbox entity, not the actual weapon. The actual weapon entity is packed inside the box. You need to retrieve it from the box, as I already explained and you completely ignored it.
__________________

Last edited by HamletEagle; 07-06-2020 at 15:22.
HamletEagle is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 07-06-2020 , 15:45   Re: WeapPickup not working!
Reply With Quote #8

Sorry, but I didn't really understand that
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-06-2020 , 16:45   Re: WeapPickup not working!
Reply With Quote #9

So why not ask for more information then? What exactly you did not understand?
I posted a few steps to do what you want, all you have to do is search for each individual step or ask. Say something concrete, like "I'm stuck at registering touch", or "I don't know what that offset is".
__________________

Last edited by HamletEagle; 07-06-2020 at 16:48.
HamletEagle is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-06-2020 , 16:51   Re: WeapPickup not working!
Reply With Quote #10

supertrio17, you have to understand that this forum has been around for a long time. Any question you may have has more than likely been covered multiple times. Get familiar with searching.

If you don't like the built-in forum search, use google.

"weappickup event site:forums.alliedmods.net"

And get familiar with how events work, this page is a great resource:

https://wiki.alliedmods.net/Half-life_1_game_events
__________________

Last edited by Bugsy; 07-06-2020 at 16:52.
Bugsy is offline
Reply


Thread Tools
Display Modes

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 03:36.


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