Raised This Month: $ Target: $400
 0% 

client_print cmd_target problems...


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2009 , 22:06   Re: execute a command after respawn...
Reply With Quote #11

I don't know why people are suggesting the Death event. You need to use the spawn as a point when you "resume" the players cloak state.

You can't just copy and paste code from an admin command to a function that's called on an event.

EDIT:

PHP Code:
#include <amxmodx>
#include <fun>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Cloak"
#define VERSION "1.0"
#define AUTHOR "Master A.K.A. HLM"

new g_iVisibilityState[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("amx_cloak","give_invis"ADMIN_KICK"<name|#userid|steamid> <on/half/off> ")
    
RegisterHam(Ham_Spawn"player""ham_player_spawn"1)
}

public 
give_invis(id,level,cid)
{
    if(!
cmd_access(id,level,cid,3))
        return 
PLUGIN_HANDLED
    
    
new szarg1[33], szarg2[8]
    
read_argv(1,szarg1,32)
    
read_argv(2,szarg2,7)
    
    new 
target cmd_target(id,szarg1,2)
    new 
name[32];
    
get_user_name(idname32)
    if(
target)
    {
        if( 
equalszarg2"off" ) )
        {
            
// No Cloak
            
set_user_rendering(target)
            
client_print(target,print_chat,"-[EVIL]- %s is no longer cloaked ",name)
            
g_iVisibilityState[target] = 0
        
}
        else if( 
equalszarg2"half" ) ) 
        {
            
// Partial Cloak
            
set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,85)
            
client_print(target,print_chat"-[EVIL]- %s is partially cloaked ",name)
            
g_iVisibilityState[target] = 1
        
}
        else if( 
equalszarg2"on" ) )
        {
            
// Full Cloak
            
set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0)
            
client_print(target,print_chat"-[EVIL]- %s is completely cloaked ",name)
            
g_iVisibilityState[target] = 2
        
}
    }
    return 
PLUGIN_HANDLED
}

public 
ham_player_spawn(id)
{
    if(
is_user_alive(id))
    {
        switch(
g_iVisibilityState[id])
        {
            case 
1:
            {
                
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,85)
            }
            case 
2:
            {
                
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0)
            }
        }
    }
    
    return 
PLUGIN_HANDLED
}  

public 
client_connect(id)
{
    
g_iVisibilityState[id] = 0

__________________

Last edited by fysiks; 06-25-2009 at 22:17.
fysiks is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-25-2009 , 22:19   Re: execute a command after respawn...
Reply With Quote #12

anyone know how I can find if user respawns??

I dont know where to look..
__________________
+|- KARMA Respectively

HLM is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2009 , 22:22   Re: execute a command after respawn...
Reply With Quote #13

Look up. Tested in DOD and it works . Although, when I tested it before on my bots the "cloak" survived the death/respawn, strange.
__________________

Last edited by fysiks; 06-25-2009 at 22:25.
fysiks is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-25-2009 , 22:28   Re: execute a command after respawn...
Reply With Quote #14

thanks fysiks!!

where would I be without you?

I guess im going to need to learn some ham sammich eventually..
__________________
+|- KARMA Respectively

HLM is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2009 , 22:37   Re: execute a command after respawn...
Reply With Quote #15

You need to start reading more tutorials and testing your plugins, that is the best way without holding your hand the whole time.
__________________
fysiks is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-26-2009 , 01:16   Re: execute a command after respawn...
Reply With Quote #16

okay, Ive looked at alot of the tuts, looked it up but I cant find out why this plugin is printing the command executer, not the command target...

here is what I have..

PHP Code:
#include <amxmodx>
#include <fun>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Cloak"
#define VERSION "1.0"
#define AUTHOR "Master A.K.A. HLM"

new g_iVisibilityState[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("amx_cloak","give_invis"ADMIN_KICK"<name|#userid|steamid> <on/half/off> ")
    
RegisterHam(Ham_Spawn"player""ham_player_spawn"1)
}

public 
give_invis(id,level,cid)
{
    if(!
cmd_access(id,level,cid,3))
        return 
PLUGIN_HANDLED
    
    
new szarg1[33], szarg2[8]
    
read_argv(1,szarg1,32)
    
read_argv(2,szarg2,7)
    
    new 
target cmd_target(id,szarg1,2)
    new 
name[32];
    
get_user_name(idname32)
    
    new 
user cmd_target(id,szarg1,2)        
    if(
target)
    {
        if( 
equalszarg2"off" ) )
        {
            
// No Cloak
            
set_user_rendering(target)
            
client_print(0,print_chat,"[AMXX] %s is no longer cloaked ",user)
            
g_iVisibilityState[target] = 0
        
}
        else if( 
equalszarg2"half" ) ) 
        {
            
// Partial Cloak
            
set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,85)
            
client_print(0,print_chat"[AMXX] %s is partially cloaked ",user)
            
g_iVisibilityState[target] = 1
        
}
        else if( 
equalszarg2"on" ) )
        {
            
// Full Cloak
            
set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0)
            
client_print(0,print_chat"[AMXX] %s is completely cloaked ",user)
            
g_iVisibilityState[target] = 2
        
}
    }
    return 
PLUGIN_HANDLED
}

public 
ham_player_spawn(id)
{
    new 
name[33]
    
get_user_name(id,name,32)
    
    
    if(
is_user_alive(id))
    {
        switch(
g_iVisibilityState[id])
        {
            case 
1:
            {
                
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,85)
                
client_print(id,print_chat,"[AMXX] %s, you are still half-cloaked! ",name)
            }
            case 
2:
            {
                
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0)
                
client_print(id,print_chat,"[AMXX] %s, you are still completely cloaked! ",name)
            }
        }
    }
    
    return 
PLUGIN_HANDLED
}  

public 
client_connect(id)
{
    
g_iVisibilityState[id] = 0

everything works fine (thanks fysiks), but it bugs me (and probably others) that it shows that $admin_who_ran_command has $type invisiblity, instead of $user having the invisibility... from what im seeing, im doing it properly.. im not 100% sure about the ham sandwich part for the correct one though.. it might be working right there..

can someone tell me how im going about that wrong? (because it looks right to me)
__________________
+|- KARMA Respectively

HLM is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 06-26-2009 , 07:09   Re: client_print cmd_target problems...
Reply With Quote #17

PHP Code:
new target cmd_target(id,szarg1,2// target is now the id of  the person sho should get  invis/visible again
new name[32]; 
get_user_name(idname32// username of id is stored, ERROR it should be target
     
new user cmd_target(id,szarg1,2// unnecessary since its the same like the first quoted line, target == user 
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Old 06-26-2009, 09:13
HLM
This message has been deleted by HLM.
Old 06-26-2009, 11:42
HLM
This message has been deleted by HLM.
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-26-2009 , 16:04   Re: client_print cmd_target problems...
Reply With Quote #18

I changed the source accordingly, but now it will say

Code:
[AMXX] szarg2, info about what happened
and the user arg is szarg1, so then it will look like
Code:
[AMXX] on had full cloak turned on
I dont know HOW I messed that up, but thats what happens when im involved

PHP Code:
#include <amxmodx>
#include <fun>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "Cloak"
#define VERSION "1.0"
#define AUTHOR "Master A.K.A. HLM"

new g_iVisibilityState[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("amx_cloak","give_invis"ADMIN_KICK"<name|#userid|steamid> <on/half/off> ")
    
RegisterHam(Ham_Spawn"player""ham_player_spawn"1)
}

public 
give_invis(id,level,cid)
{
    if(!
cmd_access(id,level,cid,3))
        return 
PLUGIN_HANDLED
    
    
new szarg1[33], szarg2[8]
    
read_argv(1,szarg1,32)
    
read_argv(2,szarg2,7)
    
    new 
target cmd_target(id,szarg1,2)
    new 
name[32]
    
get_user_name(targetname32)
    if(
target)
    {
        if( 
equalszarg2"off" ) )
        {
            
// No Cloak
            
set_user_rendering(target)
            
client_print(0,print_chat,"[AMXX] %s is no longer cloaked ",target)
            
g_iVisibilityState[target] = 0
        
}
        else if( 
equalszarg2"half" ) ) 
        {
            
// Partial Cloak
            
set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,85)
            
client_print(0,print_chat"[AMXX] %s is partially cloaked ",target)
            
g_iVisibilityState[target] = 1
        
}
        else if( 
equalszarg2"on" ) )
        {
            
// Full Cloak
            
set_user_rendering(target,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0)
            
client_print(0,print_chat"[AMXX] %s is completely cloaked ",target)
            
g_iVisibilityState[target] = 2
        
}
    }
    return 
PLUGIN_HANDLED
}

public 
ham_player_spawn(id)
{
    new 
name[33]
    
get_user_name(id,name,32)
    
    
    if(
is_user_alive(id))
    {
        switch(
g_iVisibilityState[id])
        {
            case 
1:
            {
                
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,85)
                
client_print(id,print_chat,"[AMXX] %s, you are still half-cloaked! ",name)
            }
            case 
2:
            {
                
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0)
                
client_print(id,print_chat,"[AMXX] %s, you are still completely cloaked! ",name)
            }
        }
    }
    
    return 
PLUGIN_HANDLED
}  

public 
client_connect(id)
{
    
g_iVisibilityState[id] = 0

__________________
+|- KARMA Respectively

HLM is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-26-2009 , 18:36   Re: client_print cmd_target problems...
Reply With Quote #19

"target" is an interger and represents the entity number of the player. In your client_print() function you need to use "name" instead of "target".

PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <fun> 
#include <hamsandwich> 

#define PLUGIN "Cloak" 
#define VERSION "1.0" 
#define AUTHOR "Master A.K.A. HLM" 

new g_iVisibilityState[33

public 
plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR
    
register_clcmd("amx_cloak","give_invis"ADMIN_KICK"<name|#userid|steamid> <on/half/off> "
    
RegisterHam(Ham_Spawn"player""ham_player_spawn"1


public 
give_invis(id,level,cid

    if(!
cmd_access(id,level,cid,3)) 
        return 
PLUGIN_HANDLED 
     
    
new szarg1[33], szarg2[8
    
read_argv(1,szarg1,32
    
read_argv(2,szarg2,7
     
    new 
target cmd_target(id,szarg1,CMDTARGET_ALLOW_SELF
    new 
name[33
    
get_user_name(targetname32
    if(
target
    { 
        if( 
equalszarg2"off" ) ) 
        { 
            
// No Cloak 
            
set_user_rendering(target
            
client_print(0,print_chat,"[AMXX] %s is no longer cloaked ",name
            
g_iVisibilityState[target] = 
        

        else if( 
equalszarg2"half" ) )  
        { 
            
// Partial Cloak 
            
set_user_rendering(target,kRenderFxGlowShell,_,_,_,kRenderTransAlpha,85
            
client_print(0,print_chat"[AMXX] %s is partially cloaked ",name
            
g_iVisibilityState[target] = 
        

        else if( 
equalszarg2"on" ) ) 
        { 
            
// Full Cloak 
            
set_user_rendering(target,kRenderFxGlowShell,_,_,_,kRenderTransAlpha,0
            
client_print(0,print_chat"[AMXX] %s is completely cloaked ",name
            
g_iVisibilityState[target] = 
        

    } 
    return 
PLUGIN_HANDLED 


public 
ham_player_spawn(id

    new 
name[33
    
get_user_name(id,name,32
     
     
    if(
is_user_alive(id)) 
    { 
        switch(
g_iVisibilityState[id]) 
        { 
            case 
1
            { 
                
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,85
                
client_print(id,print_chat,"[AMXX] %s, you are still half-cloaked! ",name
            } 
            case 
2
            { 
                
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0
                
client_print(id,print_chat,"[AMXX] %s, you are still completely cloaked! ",name
            } 
        } 
    } 
}   

public 
client_connect(id

    
g_iVisibilityState[id] = 

__________________

Last edited by fysiks; 06-27-2009 at 00:48.
fysiks is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 06-26-2009 , 19:19   Re: client_print cmd_target problems...
Reply With Quote #20

Use HAM_* as return values in ham forwards.
__________________

anakin_cstrike 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 15:33.


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