AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help about check... (https://forums.alliedmods.net/showthread.php?t=140390)

killergirl 10-11-2010 14:02

Help about check...
 
Code:

new_2.sma(55) : warning 213: tag mismatch
new_2.sma(59) : warning 213: tag mismatch

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>

#define TIME 10.0
#define ACCESS ADMIN_RESERVATION

new Float:player_origin[33][3];

public 
plugin_init()
{
    
RegisterHam(Ham_Spawn"player""e_Spawn"1);
}
 
public 
e_Spawn(id)
{
    
remove_task(id)
    if(
is_user_alive(id))
    {
        
set_task(0.8"get_spawn"id);
    }
    return 
HAM_IGNORED;
}

public 
get_spawn(id)
{
    
pev(idpev_originplayer_origin[id]);
    
set_task(TIME"check_afk"id);
}
 
public 
check_afk(id)
{
    if(
is_user_alive(id))
    {
        if(
same_origin(id))
        {
            
user_silentkill(id);
            
cs_set_user_team(id,CS_TEAM_SPECTATOR);
            new 
name[33];
            
get_user_name(idname32);
            
client_print(0print_chat,  "[AMXX] %s was killed and moved: AFK!"name);
            
set_task(70.0,"check_afk_spec",id);
        }
    }    
}

public 
check_afk_spec(id)
{
    if(
is_user_alive(id))
    {
        if(
same_origin(id))
        {
            if(!
get_user_flags(id) & ACCESS){
                return 
PLUGIN_HANDLED
                    
}
                    else{
                        if(!
cs_get_user_team(id) == CS_TEAM_SPECTATOR){
                            new 
name[32]
                            
get_user_name(idname31)
                            
server_cmd("kick %s AFK!"name)
                            
client_print(0print_chat"[AMXX] %s was kicked: AFK!"name)
                            }
                        }
        }
    }
    return 
PLUGIN_CONTINUE
}
 
public 
same_origin(id)
{
    new 
Float:origin[3];
    
pev(idpev_originorigin);
    for(new 
03i++)
        if(
origin[i] != player_origin[id][i])
            return 
0;
    return 
1;


I don't know why I getting this warning, what I did wrong? (also, the script wasn't checked)

Mxnn 10-11-2010 14:22

Re: Help about check...
 
PHP Code:

 if(!cs_get_user_team(id) == CS_TEAM_SPECTATOR){ 

This line doesn't mean "if player team is different to CS_TEAM_SPECTATOR". This line get the user team and it denies. If team = 3, 2, or 1 returns 0, if 0 returns 1.
The correct form to do this is:
PHP Code:

 if(cs_get_user_team(id) != CS_TEAM_SPECTATOR){ 

And this other:
PHP Code:

if(!get_user_flags(id) & ACCESS){ 

With this code you are obtaining the id's flags and denying it.
The correct way: using brackets.
PHP Code:

if(! (get_user_flags(id) & ACCESS) ){ 



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

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