Jump to content
  • 0

Function return always returning 0


Wenden

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  4
  • Reputation:   1
  • Joined:  11/29/16
  • Last Seen:  

Hi, pardon my English, I speak Portuguese.
I'm facing a possible bug in the "return" function, even setting a value in the variable it always returns the value 0. In case the variable .@erro always returns 0, even though I set 1.
Here is the script:

 

callfunc("Transfer",atoi(.transfer$[3]),atoi(.transfer$[4]),atoi(.transfer$[5])); // Calling the function
	if(.@erro) close;
    
	// Function:
	function    script    Transfer    {
	    if(getarg(0) == 1){
        if(zeny < getarg(1)){
            .@erro = 1;
            return .@erro;
            }
        set zeny,zeny-getarg(1);
        return;
        }
        
        if(getarg(0) == 2){
            if(#CASHPOINTS < getarg(1)){
                .@erro = 1;
                return .@erro;
                }
            set #CASHPOINTS,#CASHPOINTS-getarg(1);
            return;
            }
            
            if(getarg(0) == 3){
                if(countitem(getarg(1)) < getarg(2)){
                    .@erro = 1;
                    return .@erro;
                    }
                delitem getarg(1),getarg(2);
                return;
                }
}

 

Edited by Wenden
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

.@erro = callfunc("Transfer",atoi(.transfer$[3]),atoi(.transfer$[4]),atoi(.transfer$[5])); // Calling the function
if( .@erro ) close;

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  4
  • Reputation:   1
  • Joined:  11/29/16
  • Last Seen:  

@Edit

Now I have a problem here, when it returns from the function this appears in the mapserver.

If the function is not called nothing appears.

 

Erro 2.JPG

Edited by Wenden
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...