Ways to convert script to function

tmav94

New member
Messages
55
Points
0
Github
tmav94
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+


 
@@tmav94

Code:
-	script	whiteList	-1,{	OnWhisperGlobal:		mes "Lista Atualizada";		$whiteList$ = "2000000,2000794,2000839,2000637,2000624,2000016,2004000,2003933,2003884";		mes $whiteList$;		close;}function	script	restrictedCode {	.@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 "Access Denied";		close;	}}prontera,166,206,5	script	Example	405,{	callfunc( "restrictedCode" );		mes "Access granted!";	close;}prontera,164,200,5	script	Example2	405,{	callfunc( "restrictedCode" );		mes "Access granted!";	close;}
 
Back
Top