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

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
sheo
SourceMod Donor
Join Date: Jul 2013
Location: Russia, Moscow
Old 08-24-2014 , 03:08   Re: New API and Syntax
Reply With Quote #101

lol
Thank you, BAILOPAN
__________________
sheo is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 08-27-2014 , 15:18   Re: New API and Syntax
Reply With Quote #102

Compile time error on this code

PHP Code:
methodmap Player
{
    public 
Playerint playerIndex )
    {
        if (!
IsClientInGame(playerIndex))
            return 
INVALID_PLAYER;
        return 
Player:EntIndexToEntRef(playerIndex);
    }

    
property int index { public get() { return EntRefToEntIndex(_:this); }  }


it expect new line for some reason so for small function that I want to put into 1 line is not possible.

PHP Code:
methodmap Player
{
    public 
Playerint playerIndex )
    {
        if (!
IsClientInGame(playerIndex))
            return 
INVALID_PLAYER;
        return 
Player:EntIndexToEntRef(playerIndex);
    }

    
property int index { public get() { return EntRefToEntIndex(_:this); 
}  }


still an error since the last } is not a new line

but

PHP Code:
methodmap Player
{
    public 
Playerint playerIndex )
    {
        if (!
IsClientInGame(playerIndex))
            return 
INVALID_PLAYER;
        return 
Player:EntIndexToEntRef(playerIndex);
    }

    
property int index { public get() { return EntRefToEntIndex(_:this); 
}  
}


work...

I know it a not a big issue but logically everything above should compile fine.
Mathias. is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 08-27-2014 , 15:21   Re: New API and Syntax
Reply With Quote #103

Are you sure you're using the latest snapshots of the 1.7 compiler? I remember there being some parsing issues re: methodmaps in the past, but it should all be working now.
__________________
VoiDeD is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 08-27-2014 , 15:36   Re: New API and Syntax
Reply With Quote #104

I didn't have the lasted version, I will check it out, thank you

EDIT: same issue

expected a newline, but found }

NEW:

@warning: to people using VFormat in methods, the arguments position is +1 from what it visually look.
@question: will that ever change or it will stay that way? I suppose it make sense since the first argument is hidden of the self object.

NEW 2:

@VoiDeD sorry to ask you again, in your example you call some functions with entity reference instead of index

PHP Code:
public void SetPropPropType propType, const char[] propNameint valueint size 4int element )
{
    
SetEntPropthis.RefpropTypepropNamevaluesizeelement );

I was wondering how is that affecting the code compare to indexes, is there a particular reason that you use the reference on top of the index?

Last edited by Mathias.; 08-27-2014 at 16:43.
Mathias. is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 08-29-2014 , 20:54   Re: New API and Syntax
Reply With Quote #105

Question: How can a native get a function from its arguments now?

I'm mostly trying to do the private forwards shown in: https://wiki.alliedmods.net/Function...ivate_Forwards

But doing "Function:GetNativeCell(1)" gives a warning now:

./scripting/multi1v1/natives.sp(229) : warning 237: coercing functions to and from primitives is unsupported and will be removed in the future


Is there a safer way to do this now?
__________________

Last edited by splewis; 08-29-2014 at 20:54.
splewis is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 08-29-2014 , 20:55   Re: New API and Syntax
Reply With Quote #106

GetNativeFunction.
__________________
VoiDeD is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 08-29-2014 , 21:13   Re: New API and Syntax
Reply With Quote #107

Quote:
Originally Posted by VoiDeD View Post
Ah, I missed that. Thanks!
__________________
splewis is offline
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 08-30-2014 , 03:24   Re: New API and Syntax
Reply With Quote #108

What is garbage collection anyway? I tried to read on google but still can't understand at all....
iGANGNAM is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 08-30-2014 , 07:18   Re: New API and Syntax
Reply With Quote #109

Quote:
Originally Posted by iGANGNAM View Post
What is garbage collection anyway? I tried to read on google but still can't understand at all....
It's where memory is freed of unused blocks
__________________
WildCard65 is offline
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 08-30-2014 , 08:00   Re: New API and Syntax
Reply With Quote #110

Quote:
Originally Posted by WildCard65 View Post
It's where memory is freed of unused blocks
Thank you.
iGANGNAM 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 00:28.


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