Jump to content
  • 0

Ways to convert scripts to functions


Tales

Question


  • Group:  Members
  • Topic Count:  163
  • Topics Per Day:  0.04
  • Content Count:  319
  • Reputation:   8
  • Joined:  02/05/12
  • Last Seen:  

Hi guys!
I'm want to use this script in all my npc events... but this are in script ....so... i need to add this code in all my scripts that i want to do this thing...

 

Restricted Code

.@query_result = query_sql("SELECT login.account_id FROM login LEFT JOIN `char` ON login.account_id=`char`.account_id WHERE login.last_ip=(SELECT last_ip FROM login WHERE account_id="+getcharid(3)+") AND `char`.online=1", .@account_id);


if ( .@query_result > 1 && compare( $whiteList$,getcharid(3) +"" ) == 0 ) {
mes "[WARNING]";
mes "Acess Denied";
end;
}

White List Code*

- script whiteList -,{
OnWhisperGlobal:
mes "Lista Atualizada";
$whiteList$ = "2000000,2000794,2000839,2000637,2000624,2000016,2004000,2003933,2003884";
//$whiteList$ = "";
mes ""+$whiteList$+"";
close;


end;
}

I want to convert the "Restricted Code" to fuction to use in all my npcs so that i change some thing in the function and it i'll change automatic in other...

Can someone help me? REP+

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts


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

try this


// F_RestrictedCode( getcharid(3),"2000000,2000794,2000839,2000637,2000624,2000016,2004000,2003933,2003884" );

function	script	F_RestrictedCode	{
	.@aid = getarg( 0,0 );
	.@whitelist$ = getarg( 1,"0" );
	
	.@query_result = query_sql("SELECT login.account_id FROM login LEFT JOIN `char` ON login.account_id=`char`.account_id WHERE login.last_ip=(SELECT last_ip FROM login WHERE account_id="+.@aid+" AND account_id NOT IN ( "+.@whitelist$+" ) ) AND `char`.online=1", .@account_id);
	return .@query_result;
}


  • Upvote 1
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...