AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Crossbow v2.1 (https://forums.alliedmods.net/showthread.php?t=107360)

beginnercs 10-06-2021 11:23

Re: Crossbow v2.1
 
Hello, can someone help me with a question?
i set the cvar "amx_crossbow_admin", "1", so that only players with ADMIN_LEVEL_H (the vips) can have the crossbow, this prevents other players from buying the crossbow, but they can still pick it up from the ground when a vip dies or drop the crossbow.
i want to prevent players from getting the crossbow from the ground, but still allow vips to get it from the ground.

I tried this, but with no effect, players can still pick up and use the crossbow

Code:

// Touch
public crossbow_touch(xbow, id)
{
        if(!(get_user_flags(id) & BUY_FLAG) && g_admin == 1)
        {
                // Prevent invalid ent messages
                if (!is_valid_ent(xbow) || !is_valid_ent(id))
                        return PLUGIN_CONTINUE
               
                // Not allowed to touch       
                if (g_hasXbow[id] || user_has_weapon(id, CSW_AWP))
                        return PLUGIN_CONTINUE
               
                // Give crossbow       
                give_xbow(id)
       
                // Remove crossbow on ground
                remove_entity(xbow)
        }
        return PLUGIN_CONTINUE
}

later I tried this:
Code:

// Called when player touch something,
public fw_Touch(ptr, ptd)
{
        if(get_user_flags(ptd) & BUY_FLAG)
        {
                // Invalid ent/toucher
                if(!pev_valid(ptr) || !pev_valid(ptd))
                        return FMRES_IGNORED;
       
                // Get model, toucherclass, entityclass
                new toucherclass[33], entityclass[33]
                pev(ptr, pev_classname, entityclass, charsmax(entityclass))
                pev(ptd, pev_classname, toucherclass, charsmax(toucherclass))
       
                // TOucher isn't player and entity isn't weapon
                if (!equali(toucherclass, "player") || !equali(entityclass, "weaponbox"))
                        return FMRES_IGNORED
       
                // Our world model
                new model[33]; pev(ptr, pev_model, model, charsmax(model))
                if(equali(model, W_MODEL))
                {
                        // If allowed to touch
                        if(allowed_toucher(ptd))
                        {
                                // 
                                g_hasXbow[ptd] = true
                        }
                }
        }
        return FMRES_IGNORED;
}

So it worked perfectly, vips take the crossbow from the ground and can use the crossbow normally, not vips when taking the crossbow from the ground gain the common weapon which the crossbow replaces (awp), but I have this error:

Code:

[AMXX] Displaying debug trace (plugin "amx_crossbow21.amxx", version "2.0")
[AMXX] Run time error 10: native error (native "get_user_flags")
[AMXX]    [0] amx_crossbow21.sma::fw_Touch (line 506)

I don't understand the reason for the error, in the game it's working perfectly as I want it, but the error persists.
Can anyone help me with this? how to fix this error and keep the functionality i want?

* Sorry for bad English.

Napoleon_be 10-06-2021 11:30

Re: Crossbow v2.1
 
Check if user is alive, this should fix it.

beginnercs 10-06-2021 13:55

Re: Crossbow v2.1
 
Quote:

Originally Posted by Napoleon_be (Post 2759784)
Check if user is alive, this should fix it.

Thank you very much, it is now working perfectly and without errors. :up:


All times are GMT -4. The time now is 09:20.

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