AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]remove text from text (https://forums.alliedmods.net/showthread.php?t=94450)

One 06-11-2009 11:45

[SOLVED]remove text from text
 
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.

Bugsy 06-11-2009 11:59

Re: remove text from text
 
Quick and easy way

PHP Code:

new szName[] = "Bugsy @AFK";

server_printszName );

replaceszName sizeof szName " @AFK" "" );

server_printszName ); 


One 06-11-2009 15:52

Re: remove text from text
 
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 );  



Bugsy 06-11-2009 15:55

Re: remove text from text
 
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 );   }

One 06-11-2009 20:27

Re: remove text from text
 
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 :(

Bugsy 06-11-2009 20:31

Re: remove text from text
 
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 );



One 06-11-2009 20:41

Re: remove text from text
 
perfect :P ty

fysiks 06-11-2009 20:48

Re: [SOLVED]remove text from text
 
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 :).

joaquimandrade 06-11-2009 20:49

Re: [SOLVED]remove text from text
 
Quote:

Originally Posted by fysiks (Post 846852)
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.

fysiks 06-11-2009 20:51

Re: [SOLVED]remove text from text
 
I added my justification above while you were writing that :).


All times are GMT -4. The time now is 13:48.

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