This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Solved scan problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 12-03-2020 , 13:37   scan problem
Reply With Quote #1

hi guys. so i'm trying to do a plugin that have 2 commands:
/scan name -> move player to spec, show him an hud msg and save his team
/clean name -> move player to team which was saved by first command, delete that hudmsg and show in chat an message that he's clean.

this is what i did until now
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <ColorChat>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "super"

#define ADMIN_FLAG ADMIN_LEVEL_E

new const tag[] = "JoiNET"
new SyncHudMessage;
new 
message[256]
new 
playermsg
new aname[32]
new 
pname[32]
new 
bool:hscan

public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say","scan")
    
    
register_clcmd("say_team""scan")
    
    
SyncHudMessage CreateHudSyncObj( );
    
}

public 
scan(id){
    
    new 
szSaid[192]
    
    new 
iTeam
    
    read_args
(szSaidcharsmax(szSaid))
    
    
remove_quotes(szSaid)
    
    if(
contain(szSaid"scan") != -1){
        
        if(
get_user_flags(id) & ADMIN_FLAG){
            
            
hscan true
            
            
new target[32]
            
            
copy(targetsizeof (target) -1szSaid[5])
            
            new 
player cmd_target(idtarget2)
            
            new 
playermsg player
            
            ColorChat
(0GREEN"- %s"player)
            
            if(
player){
                
                
set_task1.0"hudmsg"player__"b"); 
                
                
get_user_name(id,  anamecharsmax(aname))
                
                
get_user_name(playerpnamecharsmax(pname))
                
                
ColorChat(0GREEN"^x04[%s]^x01 Admin^x04 %s^x01 is requesting an WarGods from^x01 %s"taganamepname)
                
                
iTeam cs_get_user_team(player)
                
                
                if(
is_user_alive(player))
                    
user_kill(player)
                
                
cs_set_user_teamplayerCS_TEAM_SPECTATOR )
                
                } else if (!
player){
                
                
ColorChat(idGREEN"^x04[%s]^x01 Player^x04 %s^x01 does not exist!"tagpname)
                
            }
            
        }
        
        } else if (
contain(szSaid"clean")){
        
        if ( 
get_user_flags(id) & ADMIN_FLAG ){
            
            
hscan false
            
            
new target[32]
            
            
copy(targetsizeof (target) -1szSaid[6])
            
            new 
player cmd_target(idtarget2)
            
            
get_user_name(id,  anamecharsmax(aname))
                
            
get_user_name(playerpnamecharsmax(pname))
            
            if (
player){
                
                
                
cs_set_user_team(playeriTeam)    
                
                
remove_task(player)
                
                } else if (!
player){
                
                
ColorChat(idGREEN"^x04[%s]^x01 Player ")
                
            }
            
        }
        
    }
    
}


public 
hudmsg(id){
    
    if (
hscan == false ) return 0
    
    formatex
(messagecharsmax(message), "Good luck, %s!^nYou have to do an WarGods and show it to our admin, %s^nIf you leave, you will be permanently banned"pnameaname)
    
    
set_hudmessage25500, -1.0 , -1.000.01.00.10.1, -);
    
    
ShowSyncHudMsgplayermsgSyncHudMessagemessage );
    
}

public 
client_disconnected(id){

    
remove_task(id)


also, that remove_task don t work so if i have that hud msg, when i reconnect i still have it.

some help here, please ?

Last edited by lexzor; 12-07-2020 at 17:34. Reason: thanks fysiks
lexzor is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-04-2020 , 00:36   Re: scan problem
Reply With Quote #2

Here are a couple things that I noticed:
  • The variable "playermsg" should be removed entirely. for ShowSunchHudMsg(), just use "id".
  • The variable "hscan" needs to be an array so that you can keep track of each player individually. Currently, if you "clean" for one player, all players will be stop receiving the HUD message.
  • If you're using AMX Mod X 1.8.2 then client_disconnected() doesn't exist (it only exists in AMX Mod X 1.9.0 and newer). You should use client_disconnect(). This could explain why think they that the remove_task() isn't working.
__________________
fysiks 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 11:59.


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