Raised This Month: $ Target: $400
 0% 

[SOLVED]remove text from text


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 06-11-2009 , 11:45   [SOLVED]remove text from text
Reply With Quote #1

hi.

how can i remove a text in text?

example :

client_cmd("name %s @AFK", playername)

client_cmd("name %s",playername)

so whats here different?! player is afk & the name willbe changed to "name @AFK". ... after player comes back in game, the name willbe changed to standard name what he use.i dont like to save the original names anywhere. is there a way to do it without saving the original name?

so anything like to remove @AFK in name or so.
__________________

Last edited by One; 06-11-2009 at 20:42.
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-11-2009 , 11:59   Re: remove text from text
Reply With Quote #2

Quick and easy way

PHP Code:
new szName[] = "Bugsy @AFK";

server_printszName );

replaceszName sizeof szName " @AFK" "" );

server_printszName ); 
__________________

Last edited by Bugsy; 06-11-2009 at 12:07.
Bugsy is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 06-11-2009 , 15:52   Re: remove text from text
Reply With Quote #3

hmm... problem?

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

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

new szName[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /on","afk_on")
    
register_clcmd("say /off","afk_off")

}
public 
afk_on(id)
{
    
get_user_name(id,szName,32)
    
client_cmd(id,"name %s@AFK",szName)
}
public 
afk_off(id)
{
    
get_user_name(id,szName,32)
    
server_printszName );
    
replaceszName sizeof szName " @AFK" "" );
    
server_printszName );  

__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-11-2009 , 15:55   Re: remove text from text
Reply With Quote #4

You are setting the name as "name@AFK" without a space then are trying to remove " @AFK" with a space.

"name@AFK" should be "name @AFK". If you dont want a space separator, remove the space from the replace() call.

Code:
public afk_on(id) {     get_user_name(id,szName,32)     client_cmd(id,"name %s@AFK",szName) } public afk_off(id) {     get_user_name(id,szName,32)     server_print( szName );     replace( szName , sizeof szName , " @AFK" , "" );     server_print( szName );   }
__________________
Bugsy is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 06-11-2009 , 20:27   Re: remove text from text
Reply With Quote #5

PHP Code:
public afk_on(id)
{
    
get_user_name(id,szName,32)
    
client_cmd(id,"name %s@AFK",szName)
    
client_print(idprint_chat,"test1")
}
public 
afk_off(id)
{
    
get_user_name(id,szName,32)
    
server_printszName );
    
replaceszName sizeof szName "@AFK" "" );
    
server_printszName );  
    
client_print(idprint_chat,"test2")

nop

when i try with name %s @AFK, i have a problem & this is a space there is not allowded. when u write in concole : name buggsy is cool << ur name willbe buggsy.

u must write it so : name "buggsy is cool"

so i cant add it so : client_cmd(id,"name "%s @AFK"",szName)

so i must do it without space. but the problem is its not workin
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-11-2009 , 20:31   Re: remove text from text
Reply With Quote #6

PHP Code:
client_cmdid "name ^"%@AFK^"" szName ); 
PHP Code:
public afk_onid )
{
    static 
szName33 ];
    
    
get_user_nameid szName 32 );
    
client_cmdid "name ^"%@AFK^"" szName );
}

public 
afk_offid )
{
    static 
szName[33];
    
    
get_user_nameid szName 32 );
    
replaceszName sizeof szName " @AFK" "" );
    
client_cmdid "name ^"%s^"" szName );

Edit: If you know the player is AFK and has " @AFK" appended to his name then you can just do:

PHP Code:
public afk_offid )
{
    static 
szName[33];

    
get_user_nameid szName 32 );
    
szNamestrlenszName ) - ] = 0;
    
client_cmdid "name ^"%s^"" szName );

__________________

Last edited by Bugsy; 06-11-2009 at 20:44.
Bugsy is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 06-11-2009 , 20:41   Re: remove text from text
Reply With Quote #7

perfect ty
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-11-2009 , 20:48   Re: [SOLVED]remove text from text
Reply With Quote #8

I would also suggest not sending the "name" command at all. There is no point to change the clients name on the clients computer. Just set the users "info" attribute "name". This will change it in-game only.

So, this will prevent someone going afk (manually of course) and then leaving. Then they come back and they obviously aren't afk but their name will say they are .
__________________
fysiks is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 06-11-2009 , 20:49   Re: [SOLVED]remove text from text
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
I would also suggest not sending the "name" command at all. There is no point to change the clients name on the clients computer. Just set the users "info" attribute "name". This will change it in-game only.
In fact you should avoid every kind of server_cmd or client_cmd at all. By doing client_cmd(id,"name x") you are asking a client to ask you to change his name, instead of changing it right away.
__________________
joaquimandrade is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-11-2009 , 20:51   Re: [SOLVED]remove text from text
Reply With Quote #10

I added my justification above while you were writing that .
__________________
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 13:48.


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