AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Cstrike Invalid id Out Of Range (https://forums.alliedmods.net/showthread.php?t=163318)

Doc-Holiday 07-29-2011 03:41

Cstrike Invalid id Out Of Range
 
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;



Hunter-Digital 07-29-2011 03:55

Re: Cstrike Invalid id Out Of Range
 
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.

Doc-Holiday 07-29-2011 04:56

Re: Cstrike Invalid id Out Of Range
 
Quote:

Originally Posted by Hunter-Digital (Post 1520840)
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.

fysiks 07-29-2011 04:59

Re: Cstrike Invalid id Out Of Range
 
Quote:

Originally Posted by Doc-Holiday (Post 1520861)
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.

Doc-Holiday 07-29-2011 05:04

Re: Cstrike Invalid id Out Of Range
 
Quote:

Originally Posted by fysiks (Post 1520862)
You'll need to read the documentation again.

Then its wrong on the docs page.

Guess i should read the comments.

Hunter-Digital 07-29-2011 05:10

Re: Cstrike Invalid id Out Of Range
 
Quote:

Originally Posted by Doc-Holiday (Post 1520863)
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.

Doc-Holiday 07-29-2011 05:20

Re: Cstrike Invalid id Out Of Range
 
Quote:

Originally Posted by Hunter-Digital (Post 1520866)
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.


All times are GMT -4. The time now is 00:57.

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