• 0
Sign in to follow this  
domez86

i need simple npc gift pls.

Question

Posted (edited)

hi, I need a npc that gives a free equip, but if the char already has the same item in the inventory or equipped you say that you already have it.

thank you

Edited by domez86

Share this post


Link to post
Share on other sites

16 answers to this question

Recommended Posts

  • 0
24 minutes ago, domez86 said:

can you explain this script to me?
Does the item equip it directly?
do I just have to enter an item id?

you didn't mention about being equipped on the topic.

 

prontera,255,255,3	script	Equip Freebies	123,{
	if(#claimed){
		mes "[ Freebies ]";
		mes "You alreay receieved your freebies.";
		close;
	}
	getinventorylist;
	for([email protected] = 0; [email protected] < 20; [email protected]++){
		[email protected] = getequipid([email protected]);
		if([email protected] == -1)
			[email protected]_id[[email protected]] = 0; // Dummy Data
		else
			[email protected]_id[[email protected]] = [email protected];
	}
	for([email protected] = 0; [email protected] < getarraysize(.equip_id); [email protected]++){
		if(inarray([email protected]_id[0],.equip_id[[email protected]]) >= 0 || inarray(@inventorylist_id[0],.equip_id[[email protected]]) >= 0){
			[email protected] = 1;
			break;
		}
		continue;
	}
	if([email protected]){
		mes "[ Freebies ]";
		mes "You already have a duplicated freebies in your inventory/equipment.";
		close;
	}
	#claimed = 1;
	for([email protected] = 0; [email protected] < getarraysize(.equip_id); [email protected]++){
		getitem .equip_id[[email protected]],1;
		equip .equip_id[[email protected]];
	}
	mes "[ Freebies ]";
	mes "Here is your freebies.";
	end;
		
OnInit:
	setarray .equip_id,1208,2154; // Add your ID's here.
	end;
}

Here is the new script that it will automatically equip it after receiving :))

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 1
prontera,255,255,3	script	Equip Freebies	123,{
	if(#claimed){
		mes "[ Freebies ]";
		mes "You alreay receieved your freebies.";
		close;
	}
	getinventorylist;
	for(.@i = 0; .@i < 20; .@i++){
		.@id = getequipid(.@i);
		if(.@id == -1)
			.@equip_id[.@i] = 0; // Dummy Data
		else
			.@equip_id[.@i] = .@id;
	}
	for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){
		if(inarray(.@equip_id[0],.equip_id[.@i]) >= 0 || inarray(@inventorylist_id[0],.equip_id[.@i]) >= 0){
			.@fail = 1;
			break;
		}
		continue;
	}
	if(.@fail){
		mes "[ Freebies ]";
		mes "You already have a duplicated freebies in your inventory/equipment.";
		close;
	}
	#claimed = 1;
	for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){
		getitem .equip_id[.@i],1;
	}
	mes "[ Freebies ]";
	mes "Here is your freebies.";
	end;
		
OnInit:
	setarray .equip_id,1208,2154; // Add your ID's here.
	end;
}

 

Edited by crazyarashi

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)
23 minutes ago, AndyTheGoblin said:

Impossible 

That’s wrong, it is possible. Check the successrefitem script source.

Its certainly not possible to do it without writing your own script command, as far as I know.

but creating the command you want should be quite simple with the successrefitem as reference. 

Edited by Normynator

Share this post


Link to post
Share on other sites
  • 0

i modified this:

start_items: 1201,1,2:2301,1,16

in this:

start_items: 1201,1,2:2301,1,16:2154,1,65536

but not work.... 

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

Why inventory?

Why not

if (character variable=0) give item and set character variable to 1?

Not sure if the syntax is correct but like this :

if (FreeItemGiven==0) {
getitem 2500,1;
FreeItemGiven = 1;
close;
} else {
mes "You already received your free items!";
close;
}

 

Edited by Seravy

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, crazyarashi said:
prontera,255,255,3	script	Equip Freebies	123,{
	if(#claimed){
		mes "[ Freebies ]";
		mes "You alreay receieved your freebies.";
		close;
	}
	getinventorylist;
	for(.@i = 0; .@i < 20; .@i++){
		.@id = getequipid(.@i);
		if(.@id == -1)
			.@equip_id[.@i] = 0; // Dummy Data
		else
			.@equip_id[.@i] = .@id;
	}
	for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){
		if(inarray(.@equip_id[0],.equip_id[.@i]) >= 0 || inarray(@inventorylist_id[0],.equip_id[.@i]) >= 0){
			.@fail = 1;
			break;
		}
		continue;
	}
	if(.@fail){
		mes "[ Freebies ]";
		mes "You already have a duplicated freebies in your inventory/equipment.";
		close;
	}
	#claimed = 1;
	for(.@i = 0; .@i < getarraysize(.equip_id); .@i++){
		getitem .equip_id[.@i],1;
	}
	mes "[ Freebies ]";
	mes "Here is your freebies.";
	end;
		
OnInit:
	setarray .equip_id,1208,2154; // Add your ID's here.
	end;
}

 

can you explain this script to me?
Does the item equip it directly?
do I just have to enter an item id?

Share this post


Link to post
Share on other sites
  • 0
40 minutes ago, crazyarashi said:

you didn't mention about being equipped on the topic.

Here is the new script that it will automatically equip it after receiving :))

 

Could maybe shorten it to...

prontera,255,255,3	script	Equip Freebies	123,{
    getinventorylist;
    copyarray [email protected][0],@inventorylist_id[0],getarraysize(@inventorylist_id);
    for([email protected] = 0; [email protected] < .len; [email protected]++){
        if(!isequipped(.equip_id[[email protected]]) && inarray([email protected], .equip_id[[email protected]]) == -1) {
            getitem .equip_id[[email protected]],1;
            equip .equip_id[[email protected]];
        } else [email protected]++;
    }

    mes "[ Freebies ]";
    if(!.len - [email protected]){
        mes "It looks like you already have all the freebie(s).";
        close;
    } else if ([email protected])
        mes "It looks like you already have "[email protected]+" freebie(s).";
    mes "Here is your freebies.";
    close;
		
OnInit:
    setarray .equip_id, 1208, 2154; // Add your ID's here.
    .len = getarraysize(.equip_id);
}

Although in this case if the user was able to store/trade the freebies he could get more, but it would also allow the list of freebies to be updated.
Also my example is completely untested so...

 

Edit: I think equipped items might already show up in the @inventorylist_id so I might not even need isequipped().

Edited by Skorm
  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0
20 minutes ago, Skorm said:

Could maybe shorten it too...

prontera,255,255,3	script	Equip Freebies	123,{
    getinventorylist;
    copyarray [email protected][0],@inventorylist_id[0],getarraysize(@inventorylist_id);
    for([email protected] = 0; [email protected] < .len; [email protected]++){
        if(isequipped(.equip_id[[email protected]]) || inarray([email protected], .equip_id[[email protected]]) > -1) {
            getitem .equip_id[[email protected]],1;
            equip .equip_id[[email protected]];
        } else [email protected]++;
    }

    mes "[ Freebies ]";
    if(!.len - [email protected]){
        mes "It looks like you already have all the freebie(s).";
        close;
    } else if ([email protected])
        mes "It looks like you already have "[email protected]+" freebie(s).";
    mes "Here is your freebies.";
    close;
		
OnInit:
    setarray .equip_id, 1208, 2154; // Add your ID's here.
    .len = getarraysize(.equip_id);
}

Although in this case if the user was able to store/trade the freebies he could get more, but it would also allow the list of freebies to be updated.
Also my example is completely untested so...

I forgot about the isequipped that could have shorten it a little bit ^^

Share this post


Link to post
Share on other sites
  • 0
11 hours ago, crazyarashi said:

you didn't mention about being equipped on the topic.

 

prontera,255,255,3	script	Equip Freebies	123,{
	if(#claimed){
		mes "[ Freebies ]";
		mes "You alreay receieved your freebies.";
		close;
	}
	getinventorylist;
	for([email protected] = 0; [email protected] < 20; [email protected]++){
		[email protected] = getequipid([email protected]);
		if([email protected] == -1)
			[email protected]_id[[email protected]] = 0; // Dummy Data
		else
			[email protected]_id[[email protected]] = [email protected];
	}
	for([email protected] = 0; [email protected] < getarraysize(.equip_id); [email protected]++){
		if(inarray([email protected]_id[0],.equip_id[[email protected]]) >= 0 || inarray(@inventorylist_id[0],.equip_id[[email protected]]) >= 0){
			[email protected] = 1;
			break;
		}
		continue;
	}
	if([email protected]){
		mes "[ Freebies ]";
		mes "You already have a duplicated freebies in your inventory/equipment.";
		close;
	}
	#claimed = 1;
	for([email protected] = 0; [email protected] < getarraysize(.equip_id); [email protected]++){
		getitem .equip_id[[email protected]],1;
		equip .equip_id[[email protected]];
	}
	mes "[ Freebies ]";
	mes "Here is your freebies.";
	end;
		
OnInit:
	setarray .equip_id,1208,2154; // Add your ID's here.
	end;
}

Here is the new script that it will automatically equip it after receiving :))

hi, can I ask you how the npc detects that a char has already taken the equip? because I see that id equip you only insert it in 1 position in the script.

Edited by domez86

Share this post


Link to post
Share on other sites
  • 0
9 minutes ago, domez86 said:

char has already taken the equip

	if(#claimed){
		mes "[ Freebies ]";
		mes "You alreay receieved your freebies.";
		close;
	}

the player get #claimed = 1; when he get the equipment ,so he will hit the close every time after that

in that case it's account variable , if you want it for each character , just remove the #

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0
12 minutes ago, sader1992 said:
	if(#claimed){
		mes "[ Freebies ]";
		mes "You alreay receieved your freebies.";
		close;
	}

the player get #claimed = 1; when he get the equipment ,so he will hit the close every time after that

in that case it's account variable , if you want it for each character , just remove the #

yes, it concerns every single char, not account equip. okok but I don't understand how this script it detects equip if id equip is not there. 

since it is an item that has all the restrictions (restrictions 507) I would like npc to look right in the inventory and in the equip and if it sees it it refuses. not that it looks if you have already received item, that is not only a script that is spoken only once. excuse my bad english

Edited by domez86

Share this post


Link to post
Share on other sites
  • 0
5 minutes ago, domez86 said:

yes, it concerns every single char, not account equip. okok but I don't understand how this script it detects equip if id equip is not there. 

setarray .equip_id,1208,2154; // Add your ID's here.

 

the script work on the array variable .equip_id so you don't need to add the id all over the script , just add it here

it's 101 how to basic xD

setarray .equip_id,1208,2154; // Add your ID's here.

=

.equip_id[0] is 1208

.equip_id[1] is 2154

Share this post


Link to post
Share on other sites
  • 0
7 minutes ago, sader1992 said:
setarray .equip_id,1208,2154; // Add your ID's here.

 

the script work on the array variable .equip_id so you don't need to add the id all over the script , just add it here

it's 101 how to basic xD

setarray .equip_id,1208,2154; // Add your ID's here.

=

.equip_id[0] is 1208

.equip_id[1] is 2154

and if i restart / reload server?

Share this post


Link to post
Share on other sites
  • 0
12 minutes ago, sader1992 said:
setarray .equip_id,1208,2154; // Add your ID's here.

 

the script work on the array variable .equip_id so you don't need to add the id all over the script , just add it here

it's 101 how to basic xD

setarray .equip_id,1208,2154; // Add your ID's here.

=

.equip_id[0] is 1208

.equip_id[1] is 2154

and if i restart / reload server?

after the first time, npc detects item in inventory / equip? or do you notice that you have already received items and that's it?

Edited by domez86

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, domez86 said:

and if i restart / reload server?

after the first time, npc detects item in inventory / equip? or do you notice that you have already received items and that's it?

Excuse me, could you only answer my last question?

Share this post


Link to post
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.

Loading...
Sign in to follow this