AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   New API and Syntax (https://forums.alliedmods.net/showthread.php?t=244092)

sheo 08-24-2014 03:08

Re: New API and Syntax
 
lol
Thank you, BAILOPAN

Mathias. 08-27-2014 15:18

Re: New API and Syntax
 
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.

VoiDeD 08-27-2014 15:21

Re: New API and Syntax
 
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.

Mathias. 08-27-2014 15:36

Re: New API and Syntax
 
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?

splewis 08-29-2014 20:54

Re: New API and Syntax
 
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?

VoiDeD 08-29-2014 20:55

Re: New API and Syntax
 
GetNativeFunction.

splewis 08-29-2014 21:13

Re: New API and Syntax
 
Quote:

Originally Posted by VoiDeD (Post 2191617)

Ah, I missed that. Thanks!

iGANGNAM 08-30-2014 03:24

Re: New API and Syntax
 
What is garbage collection anyway? I tried to read on google but still can't understand at all....

WildCard65 08-30-2014 07:18

Re: New API and Syntax
 
Quote:

Originally Posted by iGANGNAM (Post 2191693)
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

iGANGNAM 08-30-2014 08:00

Re: New API and Syntax
 
Quote:

Originally Posted by WildCard65 (Post 2191779)
It's where memory is freed of unused blocks

Thank you.


All times are GMT -4. The time now is 23:38.

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