Raised This Month: $12 Target: $400
 3% 

Cstrike Invalid id Out Of Range


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 07-29-2011 , 03:41   Cstrike Invalid id Out Of Range
Reply With Quote #1

For some reason while in Ham_Killed i get issues with Cstrike natives (cs_get_weapon_id()) Also tried multiple other cs natives all gave the same error

I used get_user_name to display the name of the killer and it returns my name so not sure why im having issues with cstrike natives saying im not a player lol.

Code:
L 07/29/2011 - 00:07:31: [CSTRIKE] Non-player entity 1 out of range
L 07/29/2011 - 00:07:31: [AMXX] Run time error 10: native error (native "cs_get_weapon_id")
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

new bool:gBotsRegistered;

public 
plugin_init()
{
    
RegisterHam(Ham_Killed"player""fwdPlayerDeath");
}

public 
fwdPlayerDeath(iVictimiKilleriShouldGib)
{    
    if(!
is_user_alive(iKiller))
        return 
HAM_IGNORED;
    
    if(
get_user_team(iVictim) == get_user_team(iKiller))
        return 
HAM_IGNORED;
    
    
//This gives error posted in thread
    
new WeaponID cs_get_weapon_id(iKiller);//<----Error line
    
    //This works fine
    //new WeaponID = get_user_weapon(iKiller);
        
    
client_print(0print_chat"ID: %d ..... WeaponID: %d"iKillerWeaponID);
    
    return 
HAM_HANDLED;


Last edited by Doc-Holiday; 07-29-2011 at 03:43.
Doc-Holiday is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-29-2011 , 03:55   Re: Cstrike Invalid id Out Of Range
Reply With Quote #2

cs_get_weapon_id accepts WEAPON entities, not players, use the other method, get_user_weapon().

Also be warned, if someone is killed by a grenade, you can get verry bad results, you should get a pev value from the victim indicating damage type, I don't remember which... pev_dmg.. something.
__________________
Hunter-Digital is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 07-29-2011 , 04:56   Re: Cstrike Invalid id Out Of Range
Reply With Quote #3

Quote:
Originally Posted by Hunter-Digital View Post
cs_get_weapon_id accepts WEAPON entities, not players, use the other method, get_user_weapon().

Also be warned, if someone is killed by a grenade, you can get verry bad results, you should get a pev value from the victim indicating damage type, I don't remember which... pev_dmg.. something.
LMAO didnt see that oops... also get it there though

cs_set_weapon_ammo ( index, newammo ) Notes
index is a player index from 1 to 32.
Doc-Holiday is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-29-2011 , 04:59   Re: Cstrike Invalid id Out Of Range
Reply With Quote #4

Quote:
Originally Posted by Doc-Holiday View Post
LMAO didnt see that oops... also get it there though

cs_set_weapon_ammo ( index, newammo ) Notes
index is a player index from 1 to 32.
You'll need to read the documentation again.
__________________
fysiks is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 07-29-2011 , 05:04   Re: Cstrike Invalid id Out Of Range
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
You'll need to read the documentation again.
Then its wrong on the docs page.

Guess i should read the comments.

Last edited by Doc-Holiday; 07-29-2011 at 05:08.
Doc-Holiday is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-29-2011 , 05:10   Re: Cstrike Invalid id Out Of Range
Reply With Quote #6

Quote:
Originally Posted by Doc-Holiday View Post
Then its wrong on the docs page.

Guess i should read the comments.
No it's not wrong, you read it wrong.
Quote:
cs_set_weapon_ammo - Sets the amount of ammo in weapon's clip.
Syntax:

cs_set_weapon_ammo ( index, newammo ) Type:

Native Notes:

index is the weapon entity's index.
Meaning you input a weapon entity id, not a player id nor a CSW_* id.

Still, that's a different function, we were talking about cs_get_weapon_id.
__________________
Hunter-Digital is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 07-29-2011 , 05:20   Re: Cstrike Invalid id Out Of Range
Reply With Quote #7

Quote:
Originally Posted by Hunter-Digital View Post
No it's not wrong, you read it wrong.

Meaning you input a weapon entity id, not a player id nor a CSW_* id.

Still, that's a different function, we were talking about cs_get_weapon_id.

obv you cant read ither... "I guess i should read the comments."

because its edited there.
Doc-Holiday 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 16:52.


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