AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   string replace (https://forums.alliedmods.net/showthread.php?t=309216)

Alexunder 07-17-2018 17:47

string replace
 
hi guys
my script :
Code:

public OnPluginStart()
{
RegConsoleCmd("test", testCmd);
}

public Action:testCmd(client, args)
{
    PrintToChat(client, "The weather is cool today");
}

i want to change "cool" to "hot" , i need search word in the variable

can you help me ?

Neuro Toxin 07-17-2018 18:08

Re: string replace
 
Lets start by properly indenting your code and using the new syntax.

Code:

public void OnPluginStart()
{
        RegConsoleCmd("test", testCmd);
}

public Action testCmd(int client, int args)
{
        PrintToChat(client, "The weather is cool today");
}

Here is the info you need.

http://www.sourcemod.net/new-api/string/ReplaceString

Alexunder 07-18-2018 01:45

Re: string replace
 
Quote:

Originally Posted by Neuro Toxin (Post 2604372)
Lets start by properly indenting your code and using the new syntax.

Code:

public void OnPluginStart()
{
        RegConsoleCmd("test", testCmd);
}

public Action testCmd(int client, int args)
{
        PrintToChat(client, "The weather is cool today");
}

Here is the info you need.

http://www.sourcemod.net/new-api/string/ReplaceString

thx man , this is my script :
Code:

public Action:thetimeCmd(client, args)
{
    decl String:ctime[64];
    FormatTime(ctime, 64, NULL_STRING);
    PrintToChat(client, "\x01 \x04[SM]\x01 Time : \x04 %s", ctime);
}

Result : [SM] Time : 2018/07/18 11:11

i want to exchange "07" to "09" ok ?
i don't have problem for set time zone , i just want replace (fun) .

can you help me ?

LenHard 07-18-2018 04:39

Re: string replace
 
Quote:

Originally Posted by Alexunder (Post 2604417)
thx man , this is my script :
Code:

public Action:thetimeCmd(client, args)
{
    decl String:ctime[64];
    FormatTime(ctime, 64, NULL_STRING);
    PrintToChat(client, "\x01 \x04[SM]\x01 Time : \x04 %s", ctime);
}

Result : [SM] Time : 2018/07/18 11:11

i want to exchange "07" to "09" ok ?
i don't have problem for set time zone , i just want replace (fun) .

can you help me ?

PHP Code:

public Action Cmd_Time(int clientint args)
{
    if (
client <= MaxClients && IsClientInGame(client))
    {
        
char[] sTime = new char[64];
        
FormatTime(sTime64NULL_STRING);
        
ReplaceString(sTime64"/07/""/09/");
        
PrintToChat(client" \x04[SM]\x01 Time: \x04%s"sTime);
    }
    return 
Plugin_Handled;



mug1wara 07-18-2018 07:26

Re: string replace
 
I'd use unixtime_sourcemod.inc


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

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