Jump to content
  • 0

Array check


Z e r o

Question


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   0
  • Joined:  02/11/13
  • Last Seen:  

prontera,142,168,5 script Costume Enchanter 878,{
 
setarray .@avail[0],30115,30123,30134;

set .@part, EQI_COSTUME_HEAD_TOP;
set .@equip_id, getequipid(.@part);

if (!getequipisequiped(.@part)) {
mes "[ ^0055FFDriller^000000 ]";
mes "I'm sorry but you don't have any costume that I can inspect for enchantment.";
close;
}

if (getequipcardid(.@part,3) > 0) {
mes "[ ^0055FFDriller^000000 ]";
mes "This item has already been enchanted. I can't work on this as it is against the rules.";
close;
}

for(set .@i,3; .@i>=0; set .@i,.@i-1) {
if ( .@equip_id!=.@avail[.@i] ) {
mes "Cannot Enchant";
}
}

if(select("Cancel:Continue") == 1) {
mes "[ ^0055FFDriller^000000 ]";
mes "Bye.";
close;
}
setarray .@enc[0],4795,4796,4797;
set .@enchant, .@enc[rand(0,2)];

delequip .@part;
getitem2 .@equip_id,1,1,0,0,0,0,0,.@enchant;
}
 

Heres my costume enchanter how can I check if the .@equip_id is not in the array?

anyone please give me an idea :) i use for statement but it seems that it wont work XD

Edited by Z e r o
Code <>
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

prontera,160,180,5    script    askdfjasdhkjasd    100,{
    if ( !getequipisequiped(EQI_HAND_R) ) {
        mes "you don't have a weapon equip on right hand";
        close;
    }
    // original method = 1
//    for ( .@i = 0; .@i < .size; .@i++ )
//        if ( getequipid(EQI_HAND_R) == .id[.@i] ) break;

    // what I always use - 2
    while ( getequipid(EQI_HAND_R) != .id[.@i] && .@i < .size ) .@i++;

    if ( .@i < .size ) {
        mes "you are wearing a weapon in the array";
        close;
    }
    if ( .@i == .size ) {
        mes "nope, you can't proceed";
        close;
    }
    close;
OnInit:
    setarray .id, 1201, 1202, 1203, 1204, 1205, 1206;
    .size = getarraysize( .id );
    end;
}
and another method no.3, use more memory but hasten processing speed

this method I use in writing advanced utility scripts

prontera,162,180,5	script	kjsdfhksdjf	100,{
	if ( !getequipisequiped(EQI_HAND_R) ) {
		mes "you don't have a weapon equip on right hand";
		close;
	}
	if ( getd(".id"+ getequipid(EQI_HAND_R) ) )
		mes "you are wearing a weapon in the array";
	else
		mes "nope, you can't proceed";
	close;
OnInit:
	setd ".id"+ 1201, 1;
	setd ".id"+ 1202, 1;
	setd ".id"+ 1203, 1;
	setd ".id"+ 1204, 1;
	setd ".id"+ 1205, 1;
	setd ".id"+ 1206, 1;
	end;
}
Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  97
  • Reputation:   0
  • Joined:  02/11/13
  • Last Seen:  

Ill test them thanks <3

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...