[Plugin] SA:MP Shell Plugin
#9

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Can you explain what a shell ID actually is, and how it can be used? For instance how can I check if a program actually launched correctly? I tried doing this:
pawn Код:
if(cmdresult != 0)
how-ever it returns a shell ID so I can't really use this method. And how would I go about launching something from the root server directory? Documentation on these things would be helpful.

I've noticed that the shell ID seems to increase by 16 steadily. Is there any reasoning for this?
The command is executed in other thread, so the id is for identify the executed command. Example:

This script prints your current gamemode:
pawn Код:
new Shell:dirlist, Shell:serverinfo, Shell:gminfo;

public OnFilterScriptInit() {
    dirlist = SHELL_Execute("dir"); // dump directory files and folders
}

public OnRecieveShellMessage(Shell:id, msg[])
{
    if (id == dirlist) {
        if (strfind(msg, "server.cfg") != -1) {
            printf("server.cfg found. Dumping server info...");
            serverinfo = SHELL_Execute("more server.cfg");
        }
        print(msg);
    } else if (id == serverinfo) {
        new
            linepos;
        if ((linepos = strfind(msg, "gamemode0")) != -1) {
           
            new
                gamemode_filename[40],
                count;
               
            // find for gamemode0 script!
            for (new i = linepos+strlen("gamemode0 "); i <  strlen(msg); i++) {
               
                if (msg[i] == '\n' || msg[i] == ' ') { // gamemode text end
                    break;
                }
                gamemode_filename[count++] = msg[i]; // Copy message gamemode chars.
            }
           
            // Add file extension
            strcat(gamemode_filename, ".pwn");
            printf("Your gamemode is: '%s'. ", gamemode_filename);
           
            format(gamemode_filename, 40, "more gamemodes\\%s", gamemode_filename); // Shell command for dump file data: "more filename"
            printf("shell command: %s", gamemode_filename);
            gminfo = SHELL_Execute(gamemode_filename);
        }
    } else if (id == gminfo) {
       
        // Print gamemode
        printf(msg);
    }
   
}
Using "more" command, you can read files in other thread from pawn, without affecting server performance.
Reply


Messages In This Thread
SA:MP Shell Plugin - by BigETI - 22.11.2014, 20:18
Re: SA:MP Shell Plugin - by Jay_ - 22.11.2014, 20:24
Re: SA:MP Shell Plugin - by Meta - 22.11.2014, 20:26
Re: SA:MP Shell Plugin - by Kaperstone - 22.11.2014, 20:31
AW: Re: SA:MP Shell Plugin - by BigETI - 22.11.2014, 20:33
Re: SA:MP Shell Plugin - by Pottus - 22.11.2014, 20:36
Re: SA:MP Shell Plugin - by Write - 22.11.2014, 21:36
Re: SA:MP Shell Plugin - by Abagail - 22.11.2014, 21:52
Re: SA:MP Shell Plugin - by spell - 23.11.2014, 04:15
AW: SA:MP Shell Plugin - by BigETI - 23.11.2014, 14:21
AW: Re: SA:MP Shell Plugin - by BigETI - 23.11.2014, 21:25
Re: SA:MP Shell Plugin - by Crowler - 24.11.2014, 19:46
Re: SA:MP Shell Plugin - by Mark™ - 25.11.2014, 11:09
Re: SA:MP Shell Plugin - by KubiPL - 25.11.2014, 12:45
AW: Re: SA:MP Shell Plugin - by BigETI - 25.11.2014, 13:45
Re: SA:MP Shell Plugin - by KubiPL - 25.11.2014, 15:25
AW: SA:MP Shell Plugin - by BigETI - 27.11.2014, 09:53

Forum Jump:


Users browsing this thread: 2 Guest(s)