Created
November 1, 2016 13:50
-
-
Save cydh/3f3f3290b298fe7b12b22b193edcc717 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Written by me, Cydh | |
// For rathena.org | |
// Autoload atcommand for players on login | |
prontera,147,155,5 script Kafra#saveyouratcmd 4_F_KAFRA4,{ | |
mes .npc$; | |
mes "Hi, you can select command that auto enable when you login."; | |
next; | |
switch(select("Select commands","Close")) { | |
case 1: | |
callsub(OnSelectCommand); | |
break; | |
} | |
close; | |
OnSelectCommand: | |
mes .npc$; | |
mes "Please select command from menu."; | |
.@menu$ = ""; | |
for (.@i = 0; .@i < .CmdListCnt; .@i++) { | |
if (callsub(OnCheckCmd,.CmdList$[.@i]) != -1) { | |
.@st$ = " - ^33CC33Enabled^000000"; | |
} else { | |
.@st$ = " - ^999999Disabled^000000"; | |
} | |
.@menu$ = .@menu$+":"+.CmdList$[.@i]+" "+.@st$; | |
} | |
.@menu$ = .@menu$+":Close"; | |
.@sel = select(.@menu$)-2; | |
if (.@sel != .@i) { | |
.@idx = callsub(OnCheckCmd,.CmdList$[.@sel]); | |
mes "Atcommand ^3399FF"+.CmdList$[.@sel]+"^000000:"; | |
if (.@idx < 0) { // Enable it | |
#AutoAtcommand$[getarraysize(#AutoAtcommand$)] = .CmdList$[.@sel]; | |
mes " ^33CC33Auto-enabled on login^000000"; | |
} else { // Disable it | |
callsub(OnClearRemoveCmd,#AutoAtcommand$[.@idx]); | |
mes " ^FF0000Not enabled on login^000000"; | |
} | |
next; | |
callsub(OnSelectCommand); | |
} | |
return; | |
OnCheckCmd: | |
.@cmd$ = getarg(0); | |
for (.@i = 0; .@i < getarraysize(#AutoAtcommand$); .@i++) { | |
if (#AutoAtcommand$[.@i] == .@cmd$) | |
return .@i; | |
} | |
return -1; | |
OnClearRemoveCmd: | |
.@cmd$ = getarg(0); | |
.@size = getarraysize(#AutoAtcommand$); | |
for (.@i = 0; .@i < .@size; .@i++) { | |
if (#AutoAtcommand$[.@i] == .@cmd$) | |
break; | |
} | |
if (.@i != .@size) { | |
#AutoAtcommand$[.@i] = ""; | |
.@j = 0; | |
for (.@i = 0; .@i < .@size; .@i++) { | |
if (#AutoAtcommand$[.@i] == "") | |
continue; | |
if (.@i != .@j) { | |
#AutoAtcommand$[.@j] = #AutoAtcommand$[.@i]; | |
#AutoAtcommand$[.@i] = ""; | |
} | |
.@j++; | |
} | |
} | |
return 1; | |
OnPCLoginEvent: | |
.@j = 0; | |
for (.@i = 0; .@i < getarraysize(#AutoAtcommand$); .@i++) { | |
if (#AutoAtcommand$[.@i] != "") { | |
dispbottom "[ Auto command: "+#AutoAtcommand$[.@i]+" ]"; | |
atcommand ""+#AutoAtcommand$[.@i]+""; | |
.@j++; | |
} | |
} | |
end; | |
OnInit: | |
.npc$ = "[ Kafra ]"; | |
setarray .CmdList$[0],"@autoloot","@noks","@showexp"; | |
.CmdListCnt = getarraysize(.CmdList$); | |
end; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment