Skip to content

Commit

Permalink
BOOM
Browse files Browse the repository at this point in the history
  • Loading branch information
DEntis-T committed Jul 30, 2024
1 parent bc209f4 commit 2dcfa57
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 6 deletions.
Binary file modified scriptfiles/index.ps
Binary file not shown.
5 changes: 3 additions & 2 deletions sdk/pawn-script-sdk.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ the Initial Developer. All Rights Reserved.
#pragma semicolon 1
#include <open.mp>

#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;
}
76 changes: 76 additions & 0 deletions src/api_modules/samp/@global.inc
Original file line number Diff line number Diff line change
@@ -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<return>(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<return>(0);
}
if(mul != 2)
{
dpp_error("Argument error; [%i] \"%s\"", mul, args[0]);
dpp_internal<return>(0);
}
if(strlen(args[0]) > 144)
{
dpp_apierror("samp","Host name can't be longer than 144 characters.",);
dpp_internal<return>(0);
}
new __FUNC_ARG[200];
format(__FUNC_ARG, sizeof __FUNC_ARG, "hostname %s", args[0]);
SendRconCommand(__FUNC_ARG);
}
dpp_internal<return>(1);
}
else
{
dpp_error("Unknown form in the component \"samp/@global\".",);
dpp_internal<return>(0);
}
}
return 0;
}
2 changes: 2 additions & 0 deletions src/modules/header.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
56 changes: 54 additions & 2 deletions src/modules/interpreter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

///////////////////////////////////////////////////////
Expand Down Expand Up @@ -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);
}



Expand Down
4 changes: 3 additions & 1 deletion src/pawnscript.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,6 @@ stock dpp_genver__()
s2 = (s2 + s1) % 65521;
}
return floatround(((s2 << 16) + s1)/100000);
}
}

#include "ps_api_modules.pwn"
20 changes: 20 additions & 0 deletions src/ps_api_modules.pwn
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions src/ps_sdk.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
14 changes: 13 additions & 1 deletion src/ps_setup.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2dcfa57

Please sign in to comment.