Samp shell plugin

From SA-MP Wiki

Jump to: navigation, search

Contents

SA:MP Shell Plugin

SA:MP Shell Plugin
Plugin
AuthorBigETI
Released22/11/2014
Latest Versionv1.0.3 (27/11/2014)
Development Status Active
License Mozilla Public License
Forum Topic










About

This plugin allows you to execute shell commands on your server.

Documentation

Natives

Shell:SHELL_Execute

Description:

Executes shell commands.


Parameters:
(const cmd[])
cmd[]The command to be executed


Return Values:

Returns the shell handle. This handle is used to differenciate command executions.


Example Usage:

new Shell:handle;
// ...
handle = SHELL::Execute("echo test"); // Echoes "test".
// ...

SHELL_System

Description:

Executes shell commands.


Parameters:
(const cmd[])
cmd[]The command to be executed


Return Values:

Check system - C++ Reference for more information.


Example Usage:

// ...
SHELL::System("echo test"); // Echoes "test".
// ...

bool:SHELL_IsActive

Description:

Checks, if this handle is active.


Parameters:
(Shell:handle)
Shell:handleThe handle to be checked


Return Values:

Returns true, if successful, otherwise false.


Example Usage:

new Shell:handle;
// ...
handle = SHELL::Execute("echo test"); // Echoes "test".
// ...
new bool:is_active = SHELL::IsActive(handle);

SHELL_Release

Description:

Releases the handle.


Parameters:
(Shell:handle)
Shell:handleThe handle to release. Does not directly terminate it! Use "SHELL::IsActive()" or "OnReleaseShell()" to check, if this is truly released!


Return Values:

This function does not return any specific values.


Example Usage:

new Shell:handle;
// ...
handle = SHELL::Execute("echo test"); // Echoes "test".
// ...
SHELL::Release(handle); // Releases handle

SHELL_ReleaseAll

Description:

Releases all available handles.


Parameters:
This function has no parameters.


Return Values:

This function does not return any specific values.


Example Usage:

new Shell:handle1, Shell:handle2;
// ...
handle1 = SHELL::Execute("echo test"); // Echoes "test".
handle2 = SHELL::Execute("ping 127.0.0.1"); // Pings "127.0.0.1"
// ...
SHELL::ReleaseAll(); // Releases all available handles

SHELL_MEM_CleanUp

Description:

Cleans up some memory.


Parameters:
This function has no parameters.


Return Values:

This function does not return any specific values.


Example Usage:

// ...
SHELL::MEM_CleanUp();
// ...

Callbacks

OnReceiveShellMessage

Description:

Outputs the messages from the shell.


Parameters:
(Shell:handle, msg[])
Shell:handleThe shell handle.
msg[]The message as string.


Example Usage:

public OnReceiveShellMessage(Shell:handle, msg[])
{
	printf("Shell handle 0x%x", _:handle);
	print(msg);
}

OnReleaseShell

Description:

Gets called, if the handle gets released.


Parameters:
(Shell:handle, msg[])
Shell:handleThe released shell handle.


Example Usage:

public OnReleaseShell(Shell:handle)
{
	printf("Released shell handle 0x%x", _:handle);
}

Setup

Put the plugin binary into your server's "plugins" folder and set in server.cfg

Windows

plugins sampshell

LINUX

plugins sampshell.so

Scriptwise Implementation

// On top of your script
#include <sampshell>
// your code

Compile and run.

Downloads

sampshell.dll (Win32), sampshell.inc - Solidfiles
sampshell.so (Debian 7 (Wheezy)), sampshell.inc - Solidfiles
sampshell.so (CentOS), sampshell.inc - Solidfiles
sampshell.so (Ubuntu 14.04.1), sampshell.inc - Solidfiles
source code - Solidfiles

sampshell.inc - Pastebin
makefile - Pastebin
main.cpp - sampshell - Pastebin
sampshelltest.pwn - Pastebin

Credits

  • BigETI for the source code and compiled binaries for Windows distributions and Ubuntu 14.04.1
  • SA:MP development team
  • Bluescreen for compiling this for Debian 7 (Wheezy)
  • Markā„¢ for compiling this for CentOS
Personal tools
Navigation
Toolbox