Raised This Month: $ Target: $400
 0% 

Player Out Of Range


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shine771
Senior Member
Join Date: Jun 2007
Old 06-10-2007 , 10:15   Player Out Of Range
Reply With Quote #1

I have a problem with my plugin. When i launched my server it gave me this:
Code:
[CSTRIKE] Player out of range (0)
[AMXX] Run time error 10 (plugin "slayer.amxx") (native "cs_get_user_team")
Here's the code:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Team Slayer"
#define VERSION "1.0"
#define AUTHOR "Sh!nE*"

new slayed_tslayed_ctslayed_all

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_concmd("amx_slayer""slay_cmd"ADMIN_SLAY" <@CT @T @ALL>")
    
    
set_task(1.0"check_slay")
}

public 
slay_cmd(idlevelcid)
{
    if (!
cmd_access(idlevelcid3))
        return 
PLUGIN_HANDLED
    
    
new Arg1[5]
    
    
read_argv(1Arg14)
    
    if (
Arg1[0] == '@')
    {
        new 
Team 0
        
if (equali(Arg1[1], "CT"))
        {
            
Team 2
        

        else if (
equali(Arg1[1], "T"))
        {
            
Team 1
        
}
        else if (
equali(Arg1[1], "ALL"))
        {
            
Team 3
            
new players[32], num
            get_players
(playersnum)
            new 
i
            
for (i=0i<numi++)
            {
                if (
Team == 1)
                {
                    
slayed_t 1
                
}
                else if(
Team == 2)
                {
                    
slayed_ct 1
                
}
                else if(
Team == 3)
                {
                    
slayed_all 1
                
}
            }
        }
    }
    return 
PLUGIN_HANDLED
}

public 
check_slay(id)
{    
    new 
CsTeams:team cs_get_user_team(id)
    
    if(
slayed_t == 1)
    {
        if(
team == CS_TEAM_T)
        {
            
user_slap(id99990)
            
slayed_t 0
            
return PLUGIN_CONTINUE
        
}
    }
    
    if(
slayed_ct == 1)
    {
        if(
team == CS_TEAM_CT)
        {
            
user_slap(id99990)
            
slayed_ct 0
            
return PLUGIN_CONTINUE
        
}
    }
    
    if(
slayed_all == 1)
    {
        
user_slap(id99990)
        
slayed_all 0
        
return PLUGIN_CONTINUE
    
}
    
set_task(1.0"check_slay")
    return 
PLUGIN_CONTINUE

Please help me, i'm new to scripting. This is one of my first plugins.
I think i messed up with set_task

Sorry for my bad english.
shine771 is offline
shine771
Senior Member
Join Date: Jun 2007
Old 06-10-2007 , 11:35   Re: Player Out Of Range
Reply With Quote #2

Noone knows? ;(
shine771 is offline
mogel
Senior Member
Join Date: Jan 2007
Old 06-10-2007 , 14:49   Re: Player Out Of Range
Reply With Quote #3

Hi,

*argh* ... try this first ... you are number 29377423 with this question

hand, mogel
__________________
mogel is offline
shine771
Senior Member
Join Date: Jun 2007
Old 06-10-2007 , 15:49   Re: Player Out Of Range
Reply With Quote #4

Ok i fixed that...
Now i can't slay anything

Code:
] amx_slayer T
Usage:  amx_slayer  <@CT @T @ALL>
] amx_slayer CT
Usage:  amx_slayer  <@CT @T @ALL>
] amx_slayer @ALL
Usage:  amx_slayer  <@CT @
Nothing happens
Here's my code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Team Slayer"
#define VERSION "1.0"
#define AUTHOR "Sh!nE*"

new slayed_tslayed_ctslayed_all

new g_max_players

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_concmd("amx_slayer""slay_cmd"ADMIN_SLAY" <@CT @T @ALL>")
    
g_max_players get_maxplayers()
    
}

public 
slay_cmd(idlevelcid)
{
    if( 
id || id g_max_players)
    return 
PLUGIN_CONTINUE

    
if (!cmd_access(idlevelcid3))
        return 
PLUGIN_HANDLED
    
    
new Arg1[5]
    
    
read_argv(1Arg14)
    
    if (
Arg1[0] == '@')
    {
        new 
Team 0
        
if (equali(Arg1[1], "CT"))
        {
            
Team 2
        

        else if (
equali(Arg1[1], "T"))
        {
            
Team 1
        
}
        else if (
equali(Arg1[1], "ALL"))
        {
            
Team 3
            
new players[32], num
            get_players
(playersnum)
            new 
i
            
for (i=0i<numi++)
            {
                if (
Team == 1)
                {
                    
slayed_t 1
                    check_slay
(id)
                }
                else if(
Team == 2)
                {
                    
slayed_ct 1
                    check_slay
(id)
                }
                else if(
Team == 3)
                {
                    
slayed_all 1
                    check_slay
(id)
                }
            }
        }
    }
    return 
PLUGIN_HANDLED
}

public 
check_slay(id)
{    
    new 
CsTeams:team cs_get_user_team(id)
    
    if(
slayed_t == 1)
    {
        if(
team == CS_TEAM_T)
        {
            
user_slap(id99990)
            
slayed_t 0
            
return PLUGIN_CONTINUE
        
}
    }
    
    if(
slayed_ct == 1)
    {
        if(
team == CS_TEAM_CT)
        {
            
user_slap(id99990)
            
slayed_ct 0
            
return PLUGIN_CONTINUE
        
}
    }
    
    if(
slayed_all == 1)
    {
        
user_slap(id99990)
        
slayed_all 0
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE

Maybe this is stupid.. but im new.
Can you please help me?
shine771 is offline
Old 06-10-2007, 17:30
regalis
This message has been deleted by regalis. Reason: nvm
pRED*
Join Date: Dec 2006
Old 06-10-2007 , 18:17   Re: Player Out Of Range
Reply With Quote #5

Change the number 3 in cmd_access to 2.

This number is the number of 'arguments' the command expects. If it gets the wrong number it will return an error and show you the 'usage' thing.

Since you want amx_slay <command>, this is 2 arguments. (the command counts as 1)
pRED* is offline
shine771
Senior Member
Join Date: Jun 2007
Old 06-10-2007 , 18:35   Re: Player Out Of Range
Reply With Quote #6

Thnx very very much..

but now i cant slay anybody..
Code:
amx_slayer @CT < nothing happens
amx_slayer @T < nothing happens
amx_slayer @ALL < slay's my self
i need that plugin checks all players not that one who called the command...

Something with register_forward or register_event? maybe?

i tryed almost everything... with tasks it say's "Player Out OF Range (0)"
I don't know what to do ;( i really need to finish this plugin...

Thnx for again for help.

EDIT: please don't give a link to SEARCH i already searched... and looked at many codes... still nothing

Sorry for my bad english

Last edited by shine771; 06-10-2007 at 18:43.
shine771 is offline
pRED*
Join Date: Dec 2006
Old 06-10-2007 , 18:46   Re: Player Out Of Range
Reply With Quote #7

Well the way your trying to do it isn't that efficient but..

The new players[32] section onwards needs to be moved out the if statement.

Make the third if just team=3 and then end it.
The problem is your get_players and for loop are only reached if you input @all. The other two options skip this because its inside the if statement.

Also you need to change check_slay(id) to check_slay(players[i])
pRED* is offline
shine771
Senior Member
Join Date: Jun 2007
Old 06-10-2007 , 19:09   Re: Player Out Of Range
Reply With Quote #8

Thnx very much!
shine771 is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-12-2007 , 10:43   Re: Player Out Of Range
Reply With Quote #9

Tho I won't even try to undestand what you did there, place
PHP Code:
if(!is_user_connected(id)) return PLUGIN_HANDLED 
first in public check_slay(id)

You should do this EVERY TIME you deal with player ids in delayed tasks !!!

Last edited by _Master_; 06-12-2007 at 10:46.
_Master_ 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 10:39.


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