Raised This Month: $32 Target: $400
 8% 

Solved [ H3LP ] Natives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 02-13-2018 , 07:36   [ H3LP ] Natives
Reply With Quote #1

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);

Last edited by DarthMan; 02-13-2018 at 17:40. Reason: Solved
DarthMan is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 02-13-2018 , 10:59   Re: [ H3LP ] Natives
Reply With Quote #2

probably need the full code
and is there any error messages?
__________________
8guawong is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 02-13-2018 , 11:20   Re: [ H3LP ] Natives
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
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);     } }
DarthMan is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 02-13-2018 , 13:09   Re: [ H3LP ] Natives
Reply With Quote #4

well your not going to get much help if you don't post the whole code.....
__________________
8guawong is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 02-13-2018 , 13:34   Re: [ H3LP ] Natives
Reply With Quote #5

Quote:
Originally Posted by 8guawong View Post
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.
DarthMan is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 02-13-2018 , 15:12   Re: [ H3LP ] Natives
Reply With Quote #6

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 am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 02-13-2018 at 15:16.
eyal282 is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 02-13-2018 , 17:19   Re: [ H3LP ] Natives
Reply With Quote #7

Quote:
Originally Posted by eyal282 View Post
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 is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 02-13-2018 , 17:23   Re: [ H3LP ] Natives
Reply With Quote #8

Quote:
Originally Posted by eyal282 View Post
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]); }

Last edited by DarthMan; 02-13-2018 at 17:31.
DarthMan is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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