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

Solved [CS:GO] Create native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 01-14-2018 , 11:21   [CS:GO] Create native
Reply With Quote #1

Hello, guys.

How can I create a native for "SpawnKilled[client] = value; (false or true)" for this plugins? That's the only thing I wasn't able to do and I need this, because I want to add that check to another plugin.

SOLVED: Thank you, @hmmmmm.
__________________

Last edited by PinHeaDi; 01-17-2018 at 07:05.
PinHeaDi is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 01-14-2018 , 11:31   Re: [CS:GO] Create native
Reply With Quote #2

Something like this.


Plugin code:
PHP Code:
public APLRes AskPluginLoad2(Handle myselfbool latechar [] errorint err_max)
{
    
CreateNative("Spawnkiller"Native_Spawnkiller);

    return 
APLRes_Success;
}

public 
int Native_Spawnkiller(Handle pluginint argc)
{
    
int client GetNativeCell(1);
    
    return 
SpawnKilled[client];

include file:
PHP Code:
native bool Spawnkiller(int client); 
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 01-14-2018 at 12:59.
Franc1sco is offline
Send a message via MSN to Franc1sco
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 01-14-2018 , 12:02   Re: [CS:GO] Create native
Reply With Quote #3

PHP Code:
//// a_res_test.sp
//
// D:\Sourcemod Plugins\a_res_test.sp(46) : error 100: function prototypes do not match
//
// 1 Error.
//
// Compilation Time: 0,59 sec
// ----------------------------------------

Press enter to exit ... 
That's the line:
PHP Code:
CreateNative("Spawnkiller"Native_Spawnkiller); 
__________________
PinHeaDi is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 01-14-2018 , 12:40   Re: [CS:GO] Create native
Reply With Quote #4

A native function/handler is (always?) an int, even when the native is a bool/void/...
https://wiki.alliedmods.net/Creating...Mod_Scripting)

so use
PHP Code:
public int Native_Spawnkiller(Handle pluginint argc) {} 
instead of
PHP Code:
public bool Native_Spawnkiller(Handle pluginint argc) {} 
edit: yes always. https://sm.alliedmods.net/new-api/functions/NativeCall
__________________
coding & free software

Last edited by shanapu; 01-14-2018 at 12:46. Reason: fix link
shanapu is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 01-14-2018 , 12:53   Re: [CS:GO] Create native
Reply With Quote #5

Spawnkiller(client); doen't work.. Well it doesn't put SpawnKilled[client] to true and they can respawn again. Maybe that way:

PHP Code:
public int Native_Spawnkiller(Handle pluginint argc)
{
    
int client GetNativeCell(1);
    
    return 
SpawnKilled[client] = true;

I need it to trigger true, since it triggers false on roundstart anyways.
__________________

Last edited by PinHeaDi; 01-14-2018 at 13:46.
PinHeaDi is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 01-14-2018 , 16:19   Re: [CS:GO] Create native
Reply With Quote #6

PHP Code:
public APLRes AskPluginLoad2(Handle myselfbool latechar [] errorint err_max)
{
    
CreateNative("SetSpawnKilled"Native_Spawnkiller);

    return 
APLRes_Success;
}

public 
int Native_Spawnkiller(Handle pluginint argc)
{
    
int client GetNativeCell(1);
    
bool value GetNativeCell(2);
    
    
SpawnKilled[client] = value;

In include:
PHP Code:
native void SetSpawnKilledint clientbool value ); 
There might be a tag mismatch in there somewhere, haven't tested it out, but I think this is what you're trying to do.
hmmmmm is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 01-14-2018 , 16:43   Re: [CS:GO] Create native
Reply With Quote #7

Quote:
Originally Posted by hmmmmm View Post
PHP Code:
public APLRes AskPluginLoad2(Handle myselfbool latechar [] errorint err_max)
{
    
CreateNative("SetSpawnKilled"Native_Spawnkiller);

    return 
APLRes_Success;
}

public 
int Native_Spawnkiller(Handle pluginint argc)
{
    
int client GetNativeCell(1);
    
bool value GetNativeCell(2);
    
    
SpawnKilled[client] = value;

In include:
PHP Code:
native void SetSpawnKilledint clientbool value ); 
There might be a tag mismatch in there somewhere, haven't tested it out, but I think this is what you're trying to do.
Will test it tomorrow and yes, that's what I needed and it's way better than I expected.
__________________
PinHeaDi is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 01-15-2018 , 12:42   Re: [CS:GO] Create native
Reply With Quote #8

So @hmmmmm, this works perfectly. One was think - how can I make a seconds include that will tell me if RespawnOnMap is true or false and so that I can add in the second plugin that's using the SetSpawnKilled too, that if RespawnOnMap is true to do something.
__________________
PinHeaDi is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 01-15-2018 , 14:47   Re: [CS:GO] Create native
Reply With Quote #9

Almost all natives are created the same, only thing that differs is return value and params. It's not difficult to add on others once you've seen the example, but I'll do this one as well.

PHP Code:
public APLRes AskPluginLoad2(Handle myselfbool latechar [] errorint err_max)
{
    
CreateNative("RespawnOnMap"Native_RespawnOnMap);

    return 
APLRes_Success;
}

public 
int Native_RespawnOnMap(Handle pluginint argc)
{
    return 
g_bRespawnOnMap // or whatever variable tells you if its enabled

In include:
PHP Code:
native bool RespawnOnMap(); 
hmmmmm is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 01-15-2018 , 15:25   Re: [CS:GO] Create native
Reply With Quote #10

I get the on check (either with RespawnOnMap or !RespawnOnMap) and I changed to the proper variable. And, yes, I'll try to make them on my own next time:

PHP Code:
error 076syntax error in the expression, or invalid function call 
PHP Code:
public Action RoundStart(Event event, const char[] namebool dontBroadcast)
{
    if(!
RespawnOnMap)
        return 
Plugin_Handled;

    
LateForRespawn false;
    
RespawnEndTimer CreateTimer(60.0EndRespawn);
    return 
Plugin_Continue;

With RespawnOnMap(true or false) it returns "error 092: number of arguments does not match definition".
__________________

Last edited by PinHeaDi; 01-15-2018 at 15:33.
PinHeaDi 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 16:55.


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