26.06.2011, 15:06
It works perfectly for me now. But I had a problem : everyone could use /exec command ! So I little changed the filterscript and it is now :
Now, you must be admin to use the command.
pawn Код:
#include <a_samp>
#define ERROR_OUT_OF_MEMORY_SOURCES 0
#define ERROR_BAD_FORMAT 11
#define ERROR_FILE_NOT_FOUND 2
#define ERROR_PATH_NOT_FOUND 3
native WinExec(execPath[]);
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/exec", true, 5))
{
if (!IsPlayerAdmin(playerid))
return SendClientMessage(playerid, 0xFF0000AA, "You are not an admin ! !");
else if(cmdtext[5] != ' ' || cmdtext[6] == EOS)
return SendClientMessage(playerid, 0xFF0000FF, "/exec [command]");
else
{
new
File: execFile,
pawnScript[256]
;
execFile = fopen("ExecFS.pwn", io_write);
if(execFile)
{
strcat(pawnScript, "#include <a_samp>\r\n\r\n");
strcat(pawnScript, "public OnFilterScriptInit()\r\n");
strcat(pawnScript, "{\r\n\t");
strcat(pawnScript, cmdtext[6]);
strcat(pawnScript, "\r\n}");
fwrite(execFile, pawnScript);
fclose(execFile);
if(WinExec("pawno\\pawncc.exe ./scriptfiles/ExecFS.pwn"))
{
SetTimer("ReloadFS", 50, 0);
return 1;
}
else return SendClientMessage(playerid, -1, "WinExec is unable to execute pawncc.exe!");
}
return 0;
}
}
return 0;
}
forward ReloadFS();
public ReloadFS()
{
if(fexist("ExecFS.amx"))
SendRconCommand("reloadfs ../scriptfiles/ExecFS");
}