AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [ H3LP ] Natives (https://forums.alliedmods.net/showthread.php?t=305252)

DarthMan 02-13-2018 07:36

[ H3LP ] Natives
 
Hello. I made a native to check if a client is burried when he types /stuck, but it doesn't seem to work.
Can anyone help me? Many thanks !

Code:
//from max_admin_bury.sp public APLRes AskPluginLoad2(Handle hSelf, bool bLate, char[] szError, int iErrMax) {     CreateNative("IsClientBuried", Native_IsBuried);         RegPluginLibrary("max_natives");         return APLRes_Success; } public int Native_IsBuried(Handle hPlugin, int iNumparams) {     int iID = GetNativeCell(1);         return g_bIsBurried[iID]; } //from max_natives.inc native bool IsClientBuried(int iID);

8guawong 02-13-2018 10:59

Re: [ H3LP ] Natives
 
probably need the full code
and is there any error messages?

DarthMan 02-13-2018 11:20

Re: [ H3LP ] Natives
 
Quote:

Originally Posted by 8guawong (Post 2577983)
probably need the full code
and is there any error messages?

There are no erros. That global var is a bool. Also, the bool works in the bury plug-in, it's jsut the native that doesn't work correctly when called from the stuck plug-in.

I also made a global bool that gets activated if the bury plug-in is loaded inside the stuck plug-in.
Here's how I check when typing the stuck command"

Code:
public void OnClientSayCommand_Post(int iID, const char[] szCommand, const char[] szArg) {     if(StrEqual(szArg, "/stuck"))     {         if(g_bBuryLoaded)         {             if(IsClientBuried(iID))                 PrintToChat(iID, "* You seem to be burried.");             else                 CheckUserStuck(iID);         }         else             CheckUserStuck(iID);     } }

8guawong 02-13-2018 13:09

Re: [ H3LP ] Natives
 
well your not going to get much help if you don't post the whole code.....

DarthMan 02-13-2018 13:34

Re: [ H3LP ] Natives
 
Quote:

Originally Posted by 8guawong (Post 2577996)
well your not going to get much help if you don't post the whole code.....

Well, that should be enought. Since I tested the variable and it works fine, it's just the native that has problems. Maybe you can write a native example and test it? So that then I can adapt it to my bury plug-in.

eyal282 02-13-2018 15:12

Re: [ H3LP ] Natives
 
Why not be extra safe and do this?

Code:

public APLRes AskPluginLoad2(Handle hSelf, bool bLate, char[] szError, int iErrMax)
{
    CreateNative("IsClientBuried", Native_IsBuried);
   
    RegPluginLibrary("max_natives");
   
    return APLRes_Success;
}

public Native_IsBuried(Handle hPlugin, int iNumparams)
{
    int iID = GetNativeCell(1);
   
    return bool:g_bIsBurried[iID];
}
//from max_natives.inc
native bool IsClientBuried(int iID);

Here's how the L4D2 point system is doing:

Code:


CreateNative("PS_SetPoints", PS_SetPoints);
       
public PS_SetPoints(Handle:plugin, numParams)
{
        new client = GetNativeCell(1);
        new newval = GetNativeCell(2);
        points[client] = newval;
}

The CreateNative appears in APL obviously.

DarthMan 02-13-2018 17:19

Re: [ H3LP ] Natives
 
Quote:

Originally Posted by eyal282 (Post 2578011)
Why not be extra safe and do this?

Code:

public APLRes AskPluginLoad2(Handle hSelf, bool bLate, char[] szError, int iErrMax)
{
    CreateNative("IsClientBuried", Native_IsBuried);
   
    RegPluginLibrary("max_natives");
   
    return APLRes_Success;
}

public Native_IsBuried(Handle hPlugin, int iNumparams)
{
    int iID = GetNativeCell(1);
   
    return bool:g_bIsBurried[iID];
}
//from max_natives.inc
native bool IsClientBuried(int iID);

Here's how the L4D2 point system is doing:

Code:


CreateNative("PS_SetPoints", PS_SetPoints);
       
public PS_SetPoints(Handle:plugin, numParams)
{
        new client = GetNativeCell(1);
        new newval = GetNativeCell(2);
        points[client] = newval;
}

The CreateNative appears in APL obviously.

I'm doing it right now. Will see if it works.

DarthMan 02-13-2018 17:23

Re: [ H3LP ] Natives
 
Quote:

Originally Posted by eyal282 (Post 2578011)
Why not be extra safe and do this?

Code:

public APLRes AskPluginLoad2(Handle hSelf, bool bLate, char[] szError, int iErrMax)
{
    CreateNative("IsClientBuried", Native_IsBuried);
   
    RegPluginLibrary("max_natives");
   
    return APLRes_Success;
}

public Native_IsBuried(Handle hPlugin, int iNumparams)
{
    int iID = GetNativeCell(1);
   
    return bool:g_bIsBurried[iID];
}
//from max_natives.inc
native bool IsClientBuried(int iID);

Here's how the L4D2 point system is doing:

Code:


CreateNative("PS_SetPoints", PS_SetPoints);
       
public PS_SetPoints(Handle:plugin, numParams)
{
        new client = GetNativeCell(1);
        new newval = GetNativeCell(2);
        points[client] = newval;
}

The CreateNative appears in APL obviously.

Strange, but biew as bool seemed to fix it. Thanks !

Code:
public int Native_IsBuried(Handle hPlugin, int iNumparams) {     int iID = GetNativeCell(1);         return view_as<bool>(g_bIsBurried[iID]); }


All times are GMT -4. The time now is 17:18.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.