Raised This Month: $51 Target: $400
 12% 

Native with optional parameters


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ROKronoS
Senior Member
Join Date: Oct 2010
Location: Bucharest, Romania
Old 07-29-2014 , 08:39   Native with optional parameters
Reply With Quote #1

Is it possible to create natives with optional parameters?
If so, can you provide me an example?
__________________
ROKronoS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-29-2014 , 09:05   Re: Native with optional parameters
Reply With Quote #2

Just seach, ot_207 already made a tutorial about this.

Last edited by HamletEagle; 07-29-2014 at 09:05.
HamletEagle is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-29-2014 , 09:05   Re: Native with optional parameters
Reply With Quote #3

For that, create a native with style 0, so you can specify as much parameters as you want.
klippy is offline
ROKronoS
Senior Member
Join Date: Oct 2010
Location: Bucharest, Romania
Old 07-29-2014 , 09:35   Re: Native with optional parameters
Reply With Quote #4

@HamletEagle: It's only related to functions.
@KliPPy: The problem is that i want to edit an existing native which is not coded using that template.

PHP Code:
public native_register_extra_item(const name[], costteam)

native zp_register_extra_item(const name[], costteams
I want to alter this native, adding two optional parameters.
__________________
ROKronoS is offline
schmurgel1983
Veteran Member
Join Date: Aug 2006
Location: Germany
Old 07-29-2014 , 09:46   Re: Native with optional parameters
Reply With Quote #5

just do it ^^
PHP Code:
public native_register_extra_item(const name[], costteamparam1param2)

native zp_register_extra_item(const name[], costteamsparam1 0param2 0)

You can use Float:, bool:  etc what u even need :) 
__________________

Working on:
nothing

Last edited by schmurgel1983; 07-29-2014 at 09:47.
schmurgel1983 is offline
ROKronoS
Senior Member
Join Date: Oct 2010
Location: Bucharest, Romania
Old 07-29-2014 , 10:33   Re: Native with optional parameters
Reply With Quote #6

If i do it like that, the existing extra items will not be compatible anymore.
__________________
ROKronoS is offline
schmurgel1983
Veteran Member
Join Date: Aug 2006
Location: Germany
Old 07-29-2014 , 11:47   Re: Native with optional parameters
Reply With Quote #7

that's why u set in include file
native zp_register_extra_item(const name[], cost, teams, param1 = 0, param2 = 0)
and re-compile the old items.
It automatic set param1 and param2 to 0, when u let the 2 new params free.
__________________

Working on:
nothing
schmurgel1983 is offline
ROKronoS
Senior Member
Join Date: Oct 2010
Location: Bucharest, Romania
Old 07-30-2014 , 04:38   Re: Native with optional parameters
Reply With Quote #8

Quote:
Originally Posted by schmurgel1983 View Post
that's why u set in include file
native zp_register_extra_item(const name[], cost, teams, param1 = 0, param2 = 0)
and re-compile the old items.
It automatic set param1 and param2 to 0, when u let the 2 new params free.
I'm dumb.Thanks for your help, gonna check if all is ok.
__________________
ROKronoS 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 06:46.


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