You are not logged in.

Dear visitor, welcome to sourceserver.info. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

HSFighter

Administrator

  • "HSFighter" started this thread

Posts: 1,517

Location: Flensburg

Occupation: Industrieelektroniker

wcf.user.option.userOption53: Nein

  • Send private message

1

Saturday, February 4th 2012, 1:23pm

Saycommands auswerten

Man kann den Client in der Funktion mit nutzen!

PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public OnPluginStart()
{
    // Register Console Commands
    RegConsoleCmd("say"Command_Say);
    RegConsoleCmd("say2"Command_Say);
    RegConsoleCmd("say_team"Command_Say);
}

public Action:Command_Say(clientargs)
{
    // Declaring variables
    decl String:text[192], String:command[64];
    new startidx 0;

    // Check saycommand is valid
    if (GetCmdArgString(textsizeof(text)) < 1)
    {
        return Plugin_Continue;
    }
    if (text[strlen(text)-1] == '"')
    {
        text[strlen(text)-1] = '\0';
        startidx 1;
    }
    // Check saycommand type
    GetCmdArg(0commandsizeof(command));
    if (strcmp(command"say2"false) == 0)
    {
        startidx += 4;
    }
    // Command vergleichen
    if (strcmp(text[startidx], "test1"false) == 0)
    {
        // Action when command = test1
        
    }
    // Command vergleichen
    if (strcmp(text[startidx], "test2"false) == 0)
    {
        // Action when command = test2
        
    }
       // u.s.w.....
    return Plugin_Continue;
}



-
Anti Cheat: www.smacbans.com
Kein direkter Support per PM (nur auf Anforderung)

Impact

Super Moderator

Posts: 1,276

wcf.user.option.userOption53: Nein

  • Send private message

2

Tuesday, February 14th 2012, 11:12pm

HSFighter hatte diese Funktion zwar bereits oben gezeigt, aber ich finde diese Methode schöner.
Manchmal möchte man seinen Usern die Funktion bieten Chattrigger zu benutzen wie zB rtv, rockthevote, thetime, votekick oder ähnliches.
Um dies zu tun kann man folgendes Beispiel benutzen.

PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 2D Array
new String:MyCommands[][] = {"command1""command2"};

// Cache
new MComSize sizeof(MyCommands);




public OnPluginStart()
{
    // Man koennte hier auch say_team hooken, halte ich allerdings nichts von
    AddCommandListener(Listener"say");
}




public Action:Listener(client, const String:command[], argc)
{
    // Arg definieren
    new String:Arg[64];

    // Das erste Argument speichern
    GetCmdArgString(Argsizeof(Arg));
    
    // Anfuehrungstriche entfernen "text"
    StripQuotes(Arg);
    
    // Fuer jeden Command
    for(new iMComSizei++)
    {
        // Wenn der Command == command1, oder command2
        if(StrEqual(ArgMyCommands[i], true))
        {
            PrintToChat(client"Yay, du hast %s eingegeben"Arg);
        }
    }
    
    return Plugin_Continue;
}


MfG
Impact

This post has been edited 1 times, last edit by "Impact" (Feb 15th 2012, 1:01pm)