Hi,
I have a problem with a plugin, it always gives errors about invalid players.
I check max players and is_user_connected(id) and is_user_alive(id) but still i get errors.
Could someone take a look at this and learn me how to fix these errors.
(I'm not really experienced at using stocks, maybe i use it the wrong way)
The error
Code:
L 03/17/2010 - 16:20:11: Start of error session.
L 03/17/2010 - 16:20:11: Info (map "jail_sanctuary") (file "addons/amxmodx/logs/error_20100317.log")
L 03/17/2010 - 16:20:11: [CSTRIKE] Invalid player 2
L 03/17/2010 - 16:20:12: [AMXX] Displaying debug trace (plugin "jailbreak_main.amxx")
L 03/17/2010 - 16:20:12: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 03/17/2010 - 16:20:12: [AMXX] [0] handgunmenu.inl::gun_spawn (line 12)
L 03/17/2010 - 16:20:12: [AMXX] [1] jailbreak_main.sma::PlayerSpawn (line 100)
L 03/17/2010 - 16:25:48: [CSTRIKE] Player out of range (0)
L 03/17/2010 - 16:25:48: [AMXX] Displaying debug trace (plugin "jailbreak_main.amxx")
L 03/17/2010 - 16:25:48: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 03/17/2010 - 16:25:48: [AMXX] [0] jail_addons.inl::rebeldeath (line 54)
And there is a lot more where that came from.
The plugin:
handgunmenu part
PHP Code:
public gun_spawn(id)
{
new players[32], pnum
get_players(players, pnum, "a");
for( new i; i<pnum; i++ )
{
check_user(id)
if(cs_get_user_team(id) == CS_TEAM_CT)
{
handgun_menu(id)
}
got_gun[id] = false
}
return PLUGIN_HANDLED
}
PlayerSpawn(id) part:
PHP Code:
public PlayerSpawn(id)
{
for( new i = 1; i <= g_iMaxPlayers ; i++ )
{
check_user(id)
if(is_user_alive(id))
{
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 20)
strip_weapons(id)
}
}
if(gravityday)
{
check_user(id)
if(is_user_alive(id)
||(cs_get_user_team(id) == CS_TEAM_T))
{
set_user_gravity(id, 1.0)
}
}
check_lr(id)
gun_spawn(id)
is_user_wanted[id] = false
return PLUGIN_HANDLED
}
jail_addons part:
PHP Code:
public rebeldeath()
{
new attacker = read_data(1)
new victim = read_data(2)
new headshot = read_data(3)
new AttackerName[32]
new VictimName[32]
check_user(attacker)
check_user(victim)
if( cs_get_user_team(attacker) == CS_TEAM_CT && cs_get_user_team(victim) == CS_TEAM_T)
{
if(is_user_wanted[victim])
{
get_user_name(attacker, AttackerName, 31)
get_user_name(victim, VictimName,31)
client_print(0, print_chat, "Guard %s killed wanted prisoner %s!", AttackerName, VictimName)
}
else if(!is_user_wanted[victim])
{
get_user_name(attacker, AttackerName, 31)
get_user_name(victim, VictimName,31)
client_print(0, print_chat, "Guard %s killed unwanted prisoner %s!", AttackerName, VictimName)
}
}
if( cs_get_user_team(attacker) == CS_TEAM_T && cs_get_user_team(victim) == CS_TEAM_CT)
{
playerpoints[attacker] += get_pcvar_num(cvar_killpoints)
if(headshot)
playerpoints[attacker] += get_pcvar_num(cvar_headshotpoints);
}
//SaveData(attacker)
}
And the stock: check_user(id):
PHP Code:
stock check_user(index)
{
if(!is_user_connected(index)
||(is_user_bot(index)))
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
I hope you guys can show me how it works, so i can fix my plugin.
Thanks in advance
__________________