Raised This Month: $442 Target: $400
 110% 

Solved [CSTRIKE] Non-player entity 0 out of range


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 07-21-2019 , 06:02   [CSTRIKE] Non-player entity 0 out of range
Reply With Quote #1

PHP Code:
L 07/22/2019 12:08:31: [CSTRIKENon-player entity 0 out of range
L 07
/22/2019 12:08:31: [AMXXDisplaying debug trace (plugin "jailbreak_lastrequest.amxx"version "v1.0")
L 07/22/2019 12:08:31: [AMXXRun time error 10native error (native "cs_set_weapon_ammo")
L 07/22/2019 12:08:31: [AMXX]    [0jailbreak_lastrequest.sma::taskGiveWeapon (line 1258
Lines 1258 Colored Red:
Code:
public taskGiveWeapon(iTaskId)
{
	if (!is_user_alive(ID_GIVEWEAPON))
		return;

	if (ID_GIVEWEAPON == g_rgLR[LR_GUARD])
	{
		if (is_user_alive(g_rgLR[LR_PRISONER]))
			StripWeapons(g_rgLR[LR_PRISONER]);
	}
	else
	{
		if (is_user_alive(g_rgLR[LR_GUARD]))
			StripWeapons(g_rgLR[LR_GUARD]);
	}

	new pWeapon = give_item(ID_GIVEWEAPON, g_pszNameLrWeapon);

	if (pWeapon != -1)
		cs_set_weapon_ammo(pWeapon, 1);
}

Last edited by Fuck For Fun; 07-22-2019 at 20:05. Reason: Solved
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 07-21-2019 , 07:41   Re: [CSTRIKE] Non-player entity 0 out of range
Reply With Quote #2

pWeapon is 0.
Make sure you give a valid weapon entity name to a valid player index.

It would make more sense to check if pWeapon > 0
__________________
<VeCo> is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 07-21-2019 , 07:45   Re: [CSTRIKE] Non-player entity 0 out of range
Reply With Quote #3

Quote:
Originally Posted by <VeCo> View Post
pWeapon is 0.
Make sure you give a valid weapon entity name to a valid player index.

It would make more sense to check if pWeapon > 0
So change from 1 to 0? Is this the test I was supposed to do?

PHP Code:
cs_set_weapon_ammo (pWeapon0); 
Or should I do a test if valid equals to 0 then make it do RELOAD?

Last edited by Fuck For Fun; 07-21-2019 at 07:46.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 07-21-2019 , 08:08   Re: [CSTRIKE] Non-player entity 0 out of range
Reply With Quote #4

What exactly are ID_GIVEWEAPON and g_pszNameLrWeapon?
__________________
<VeCo> is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 07-21-2019 , 09:03   Re: [CSTRIKE] Non-player entity 0 out of range
Reply With Quote #5

Quote:
Originally Posted by <VeCo> View Post
What exactly are ID_GIVEWEAPON and g_pszNameLrWeapon?
Quote:
#define ID_GIVEWEAPON (iTaskId - TASK_GIVEWEAPON)
Code:
new g_pszNameLrWeapon[32]
Code:
	switch (g_rgLR[LR_GAME])
	{
		case GAME_S4S:
		{
			new pszNameWeapon[32], szName[32];

			if (g_iWeaponId != 0)
				get_weaponname(g_iWeaponId, pszNameWeapon, charsmax(pszNameWeapon));
			
			get_user_name(pPrisoner, szName, charsmax(szName));
			copy(g_pszNameLrWeapon, charsmax(g_pszNameLrWeapon), pszNameWeapon);

			if (g_iWeaponId == CSW_DEAGLE)
			{
				set_hudmessage(0, 200, 0, -1.0, 0.5, 1, 1.0, 3.0, 0.2, 0.2, -1);
				show_hudmessage(pGuard, "Prisoner %s will get Deagle in 3 seconds!!!", szName);
			}
			
			set_task(3.0, "taskGiveWeapon", pPrisoner+TASK_GIVEWEAPON);
		}
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
E1_531G
Senior Member
Join Date: Dec 2017
Old 07-21-2019 , 10:45   Re: [CSTRIKE] Non-player entity 0 out of range
Reply With Quote #6

pWeapon is an ent. The correct check will be this:
Quote:
pWeapon > 0
or
Quote:
pev_valid(pWeapon)
__________________
My English is A0

Last edited by E1_531G; 07-21-2019 at 10:46.
E1_531G is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 07-21-2019 , 12:12   Re: [CSTRIKE] Non-player entity 0 out of range
Reply With Quote #7

Quote:
Originally Posted by E1_531G View Post
pWeapon is an ent. The correct check will be this:

or
Something like that:
Code:
public taskGiveWeapon(iTaskId)
{
	if (!is_user_alive(ID_GIVEWEAPON))
		return;

	if (ID_GIVEWEAPON == g_rgLR[LR_GUARD])
	{
		if (is_user_alive(g_rgLR[LR_PRISONER]))
			StripWeapons(g_rgLR[LR_PRISONER]);
	}
	else
	{
		if (is_user_alive(g_rgLR[LR_GUARD]))
			StripWeapons(g_rgLR[LR_GUARD]);
	}

	new pWeapon = give_item(ID_GIVEWEAPON, g_pszNameLrWeapon);
		
	if (!pev_valid(pWeapon)) 
		return;
		
	//if (pWeapon != -1)
	cs_set_weapon_ammo(pWeapon, 1);
}

Last edited by Fuck For Fun; 07-21-2019 at 13:53.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
thEsp
Veteran Member
Join Date: Aug 2017
Location: Land of Eagles
Old 07-21-2019 , 12:26   Re: [CSTRIKE] Non-player entity 0 out of range
Reply With Quote #8

pWeapon is used before it's declared, wtf?
thEsp is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 07-21-2019 , 13:56   Re: [CSTRIKE] Non-player entity 0 out of range
Reply With Quote #9

Solved
Code:
	new pWeapon = give_item(ID_GIVEWEAPON, g_pszNameLrWeapon);

	if (pev_valid(pWeapon))
		cs_set_weapon_ammo(pWeapon, 1);

Last edited by Fuck For Fun; 07-22-2019 at 20:05.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
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 10:01.


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