diff --git a/scriptfiles/index.ps b/scriptfiles/index.ps index 61d299d..b390408 100644 Binary files a/scriptfiles/index.ps and b/scriptfiles/index.ps differ diff --git a/sdk/pawn-script-sdk.inc b/sdk/pawn-script-sdk.inc index 447fe4d..82ee90f 100644 --- a/sdk/pawn-script-sdk.inc +++ b/sdk/pawn-script-sdk.inc @@ -23,12 +23,13 @@ the Initial Developer. All Rights Reserved. #pragma semicolon 1 #include -#define PS_CallPublicFunction(%0) CallRemoteFunction("PS_CallRemoteFunction","ss",%0) +#define ps_args<%0> %0 +#define CallPawnScriptFunction(%0) CallRemoteFunction("PS_CallRemoteFunction","ss",%0) __ps_sdktest(); public __ps_sdktest() { print("[PawnScript] SDK LOADED"); - PS_CallPublicFunction("TestFuncForAPI","1923,\"some text\""); + CallPawnScriptFunction("TestFuncForAPI","1923,\"some text\""); return 1; } \ No newline at end of file diff --git a/src/api_modules/samp/@global.inc b/src/api_modules/samp/@global.inc new file mode 100644 index 0000000..f921249 --- /dev/null +++ b/src/api_modules/samp/@global.inc @@ -0,0 +1,76 @@ +/* + +Version: MPL 1.1 + +The contents of this file are subject to the Mozilla Public License Version +1.1 the "License"; you may not use this file except in compliance with +the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +for the specific language governing rights and limitations under the +License. + +Portions created by the Initial Developer are Copyright (c) 2022 +the Initial Developer. All Rights Reserved. + +*/ + + +forward dpp_processSAMP@GLOBAL(funcgroup[][],args[][],args_const[][]); +public dpp_processSAMP@GLOBAL(funcgroup[][],args[][],args_const[][]) +{ + if(!strcmp(funcgroup[0], "@global")) + { + if(dpp_config[@global_comp] == 0) + { + dpp_error("Component \"samp/@global\" is not imported.",); + dpp_internal(0); + } + // If the function used it "print" + if(!strcmp(funcgroup[1], "setserverattrib")) + { + //dpp_debug("Line \"%s\" successfully executed.", line); + if(isnull(funcgroup[2])) + { + dpp_warning("Module component function \"setserverattrib\" does not posess any non-method configuration.",); + } + + if(!strcmp(funcgroup[2], "hostname")) + { + new mul, str[dpp_argcharsize]; + strmid(str, args[0], 0, dpp_argcharsize); + for(new i; i < strlen(args[0]); i++) + { + if(args[0][i] == '\"') mul++, strdel(args[0], i, i+1); + } + if(mul == 0) + { + dpp_error("You need to use '\"' to start a string.",); + dpp_internal(0); + } + if(mul != 2) + { + dpp_error("Argument error; [%i] \"%s\"", mul, args[0]); + dpp_internal(0); + } + if(strlen(args[0]) > 144) + { + dpp_apierror("samp","Host name can't be longer than 144 characters.",); + dpp_internal(0); + } + new __FUNC_ARG[200]; + format(__FUNC_ARG, sizeof __FUNC_ARG, "hostname %s", args[0]); + SendRconCommand(__FUNC_ARG); + } + dpp_internal(1); + } + else + { + dpp_error("Unknown form in the component \"samp/@global\".",); + dpp_internal(0); + } + } + return 0; +} \ No newline at end of file diff --git a/src/modules/header.inc b/src/modules/header.inc index 8b9549f..e8d1809 100644 --- a/src/modules/header.inc +++ b/src/modules/header.inc @@ -427,6 +427,8 @@ stock dpp_createfunc(funcname[], const args[], autoform = 0, hookform = 0, metho dpp_returntype[i] = ret; + dpp_privatefunc[i] = dpp_setprivate__; + for(new y; y < dpp_maxfuncs; y++) { if(!strcmp(dpp_funcname[y], funcname)) diff --git a/src/modules/interpreter.inc b/src/modules/interpreter.inc index 62e6dcf..11580b8 100644 --- a/src/modules/interpreter.inc +++ b/src/modules/interpreter.inc @@ -568,6 +568,15 @@ stock dpp_process(line[]) { dpp_config[graphics_comp] = 0; } + if(dpp_compusedfor__ == dpp_comp_@global) + { + dpp_config[@global_comp] = 0; + } + } + //MODULES/APIS + if(dpp_event == dpp_event_REQUIRES@samp) + { + dpp_config__[samp@api_module] = 0; } if(strlen(line) >= 2) @@ -614,6 +623,11 @@ stock dpp_process(line[]) { //do absolutely nothing } + //MODULES/APIS + if(dpp_event == dpp_event_REQUIRES@samp) + { + dpp_config__[samp@api_module] = 1; + } if(strlen(line) >= 2) { @@ -807,7 +821,7 @@ stock dpp_process(line[]) return 1; } - if(!strcmp(funcdeclgroup2[1], "public")) + if((!strcmp(funcdeclgroup2[1], "public")) || (!strcmp(funcdeclgroup2[1], "private"))) { if(dpp_processfunc != DPP_INVALID_FORM_ID) { @@ -816,6 +830,12 @@ stock dpp_process(line[]) return 1; } + dpp_setprivate__ = 0; + if(!strcmp(funcdeclgroup2[1], "private")) + { + dpp_setprivate__ = 1; + } + new arguments[2][1024]; strmid(arguments[0], tokengroup2[1], 0,256,256); strmid(arguments[1], funcdeclgroup2[0], 0, 256,256); @@ -3187,7 +3207,14 @@ stock dpp_process(line[]) //// //// /////////////////////////////////////////////////////// - + if(!strcmp(tokengroup[0], "requires")) + { + if(!strcmp(tokengroup[1], "samp")) + { + dpp_event = dpp_event_REQUIRES@samp; + return 1; + } + } if(!strcmp(tokengroup[0], "using")) { dpp_usingfor__ = 0; @@ -3303,6 +3330,20 @@ stock dpp_process(line[]) dpp_config[graphics_comp] = 1; return 1; } + //samp@api_module + if(!strcmp(tokengroup[1], "@global")) + { + if(dpp_config__[samp@api_module] == 0) + { + return 1; + } + if(dpp_usingfor__ == 1) + { + dpp_compusedfor__ = dpp_comp_@global; + } + dpp_config[@global_comp] = 1; + return 1; + } } /////////////////////////////////////////////////////// @@ -4165,6 +4206,17 @@ stock dpp_process(line[]) { dpp_funcfound = CallLocalFunction("dpp_processgraphics", "sss", funcgroup_form,args_form,args_fconst); } + /////////////////////////////////////////////////////// + //// + //// + //// SAMP API MODULE comp FUNC SYS + //// + //// + /////////////////////////////////////////////////////// + if(dpp_funcfound == 0) + { + dpp_funcfound = CallLocalFunction("dpp_processSAMP@GLOBAL", "sss", funcgroup_form,args_form,args_fconst); + } diff --git a/src/pawnscript.pwn b/src/pawnscript.pwn index d83f2a6..21e1e5f 100644 --- a/src/pawnscript.pwn +++ b/src/pawnscript.pwn @@ -471,4 +471,6 @@ stock dpp_genver__() s2 = (s2 + s1) % 65521; } return floatround(((s2 << 16) + s1)/100000); -} \ No newline at end of file +} + +#include "ps_api_modules.pwn" \ No newline at end of file diff --git a/src/ps_api_modules.pwn b/src/ps_api_modules.pwn new file mode 100644 index 0000000..8d00c65 --- /dev/null +++ b/src/ps_api_modules.pwn @@ -0,0 +1,20 @@ +/* + +Version: MPL 1.1 + +The contents of this file are subject to the Mozilla Public License Version +1.1 the "License"; you may not use this file except in compliance with +the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +for the specific language governing rights and limitations under the +License. + +Portions created by the Initial Developer are Copyright (c) 2022 +the Initial Developer. All Rights Reserved. + +*/ + +#include "api_modules/samp/@global.inc" \ No newline at end of file diff --git a/src/ps_sdk.pwn b/src/ps_sdk.pwn index 87cffa0..bdb84ab 100644 --- a/src/ps_sdk.pwn +++ b/src/ps_sdk.pwn @@ -36,6 +36,10 @@ public PS_CallRemoteFunction(funcname[],args__[]) { if(!strcmp(dpp_funcname[i], funcname)) { + if(dpp_privatefunc[i] == 1) + { + return 1; + } if(dpp_hookform[i] == 0) { for(new argid; argid < dpp_maxformargs; argid++) diff --git a/src/ps_setup.pwn b/src/ps_setup.pwn index eb15da1..c02d0bc 100644 --- a/src/ps_setup.pwn +++ b/src/ps_setup.pwn @@ -177,6 +177,7 @@ new dpp_lastdeco = dpp_deco_invalid; #define dpp_event_try 12 #define dpp_event_using 15 +#define dpp_event_REQUIRES@samp 16 //----------------------------------------------------------- #define DPP_INPUT_TYPE_NONE 0 #define DPP_INPUT_TYPE_LINE 1 @@ -237,10 +238,17 @@ enum dpp_enumset pawn_comp, iter_comp, vector_comp, - graphics_comp + graphics_comp, + //samp, + @global_comp } new dpp_config[dpp_enumset]; +enum dpp_enumset2 +{ + samp@api_module +} +new dpp_config__[dpp_enumset2]; //----------------------------------------------------------- //const enum __dpp_const_val @@ -328,6 +336,8 @@ new dpp_autoform[dpp_maxfuncs__]; new dpp_hookform[dpp_maxfuncs__]; new dpp_structtype[dpp_maxfuncs__]; new dpp_methodform[dpp_maxfuncs__]; +new dpp_privatefunc[dpp_maxfuncs__]; +new dpp_setprivate__ = 0; enum __dpp_argcache { dpp_argname[dpp_maxsymbolchar/2], @@ -544,6 +554,8 @@ new dpp_usingfor__ = 0; #define dpp_comp_iter 8 #define dpp_comp_vec 9 #define dpp_comp_graphics 10 +//samp +#define dpp_comp_@global 100 new dpp_compusedfor__ = 0; //----------------------------------------------------------- new dpp_deprecated__=1;