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

Crossbow v2.1


Post New Thread Reply   
 
Thread Tools Display Modes
beginnercs
Junior Member
Join Date: Jul 2020
Old 10-06-2021 , 11:23   Re: Crossbow v2.1
Reply With Quote #71

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.
beginnercs is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-06-2021 , 11:30   Re: Crossbow v2.1
Reply With Quote #72

Check if user is alive, this should fix it.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
beginnercs
Junior Member
Join Date: Jul 2020
Old 10-06-2021 , 13:55   Re: Crossbow v2.1
Reply With Quote #73

Quote:
Originally Posted by Napoleon_be View Post
Check if user is alive, this should fix it.
Thank you very much, it is now working perfectly and without errors.
beginnercs 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 07:04.


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