AlliedModders

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

shine771 06-10-2007 10:15

Player Out Of Range
 
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 06-10-2007 11:35

Re: Player Out Of Range
 
Noone knows? ;(

mogel 06-10-2007 14:49

Re: Player Out Of Range
 
Hi,

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

hand, mogel

shine771 06-10-2007 15:49

Re: Player Out Of Range
 
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?

pRED* 06-10-2007 18:17

Re: Player Out Of Range
 
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)

shine771 06-10-2007 18:35

Re: Player Out Of Range
 
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

pRED* 06-10-2007 18:46

Re: Player Out Of Range
 
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])

shine771 06-10-2007 19:09

Re: Player Out Of Range
 
Thnx very much!

_Master_ 06-12-2007 10:43

Re: Player Out Of Range
 
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 !!!


All times are GMT -4. The time now is 10:39.

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