Jump to content
  • 0

i need simple npc gift pls.


domez86

Question


  • Group:  Members
  • Topic Count:  85
  • Topics Per Day:  0.02
  • Content Count:  207
  • Reputation:   0
  • Joined:  06/11/13
  • Last Seen:  

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
Link to comment
Share on other sites

16 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

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(.@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;
		equip .equip_id[.@i];
	}
	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
Link to comment
Share on other sites

  • 1

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  292
  • Reputation:   199
  • Joined:  05/03/13
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  85
  • Topics Per Day:  0.02
  • Content Count:  207
  • Reputation:   0
  • Joined:  06/11/13
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  85
  • Topics Per Day:  0.02
  • Content Count:  207
  • Reputation:   0
  • Joined:  06/11/13
  • Last Seen:  

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?

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   381
  • Joined:  02/03/12
  • Last Seen:  

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 .@inventory[0],@inventorylist_id[0],getarraysize(@inventorylist_id);
    for(.@i = 0; .@i < .len; .@i++){
        if(!isequipped(.equip_id[.@i]) && inarray(.@inventory, .equip_id[.@i]) == -1) {
            getitem .equip_id[.@i],1;
            equip .equip_id[.@i];
        } else .@fail++;
    }

    mes "[ Freebies ]";
    if(!.len - .@fail){
        mes "It looks like you already have all the freebie(s).";
        close;
    } else if (.@fail)
        mes "It looks like you already have "+.@fail+" 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
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

20 minutes ago, Skorm said:

Could maybe shorten it too...


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

    mes "[ Freebies ]";
    if(!.len - .@fail){
        mes "It looks like you already have all the freebie(s).";
        close;
    } else if (.@fail)
        mes "It looks like you already have "+.@fail+" 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 ^^

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  85
  • Topics Per Day:  0.02
  • Content Count:  207
  • Reputation:   0
  • Joined:  06/11/13
  • Last Seen:  

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(.@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;
		equip .equip_id[.@i];
	}
	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
Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  85
  • Topics Per Day:  0.02
  • Content Count:  207
  • Reputation:   0
  • Joined:  06/11/13
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  85
  • Topics Per Day:  0.02
  • Content Count:  207
  • Reputation:   0
  • Joined:  06/11/13
  • Last Seen:  

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?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  85
  • Topics Per Day:  0.02
  • Content Count:  207
  • Reputation:   0
  • Joined:  06/11/13
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

5 minutes 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?

this is your best friend

https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  85
  • Topics Per Day:  0.02
  • Content Count:  207
  • Reputation:   0
  • Joined:  06/11/13
  • Last Seen:  

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?

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