Jump to content
  • 0

help NPC that reads a skull?


Question

Posted

Hello! I would like just to request something? I wanted to create a npc that trades a card for specific players like for example: Anonymous (This is a real IGN) Skull can be tradable into a card. Would you think it would work? Thanks!

13 answers to this question

Recommended Posts

Posted

My fault:

delitem2 7420, 1, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16;

About the name, you have to reloadscript.

Here a fix :

   	 // Damn !? No reloadscript ?!
       if ( .char_name$ == "" ) {
           donpcevent strnpcinfo(3) + "::OnInit";
           sleep2 1; // Execute OnInit before continue.
       }

       mes "I give you an apple if you give me " + .char_name$ . "'s skull !";
       next;

       if ( countitem2( 7420, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16 ) ) {
               mes "Yeah you have the skull ! I give you an apple";
               delitem2 7420, 1, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16;
               getitem 512, 1;
       }
       else {
               mes "Damn, you don't have it...";
       }
       close;

OnInit:
       set .char_name$, "Anonymous";
       query_sql("SELECT `char_id` FROM `char` WHERE `name`='" + escape_sql(.char_name$) + "' LIMIT 1", .cible_cid );
       if ( !.cible_cid )
           debugmes "[skull Trader] Invalid name specify ?";
       end;

Posted

Skull ID - 7420

and yes you can trade it into another Card if your NPC does so.

just check for item 7420 and trade to the Card you want.

I mean just to specific skulls? Like My skull only? Thanks! And could you please put some examples of the codes? Thanks

Posted

Im pretty sure (s)he's wanting it to read the name off of the skull, perhaps for something like a mercenary script (kill a certain person and bring in their skull).

Posted

Just an example:

	mes "I give you an apple if you give me " + .char_name$ . "'s skull !";
next;

if ( countitem2( 7420, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16 ) ) {
	mes "Yeah you have the skull ! I give you an apple";
	delitem2 7420, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16;
	getitem 512, 1;
}
else {
	mes "Damn, you don't have it...";
}
close;

OnInit:
set .char_name$, "Anonymous";
query_sql("SELECT `char_id` FROM `char` WHERE `name`='" + escape_sql(.char_name$) + "' LIMIT 1", .cible_cid );
end;

Good luck.

  • Upvote 1
Posted

Just an example:

	mes "I give you an apple if you give me " + .char_name$ . "'s skull !";
next;

if ( countitem2( 7420, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16 ) ) {
	mes "Yeah you have the skull ! I give you an apple";
	delitem2 7420, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16;
	getitem 512, 1;
}
else {
	mes "Damn, you don't have it...";
}
close;

OnInit:
set .char_name$, "Anonymous";
query_sql("SELECT `char_id` FROM `char` WHERE `name`='" + escape_sql(.char_name$) + "' LIMIT 1", .cible_cid );
end;

Good luck.

Hello there! I tried your script how ever it doesn't recognized a name.

giEY2.jpg

+ An error in this line

delitem2 7420, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16;

Posted (edited)

My fault:

delitem2 7420, 1, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16;

About the name, you have to reloadscript.

Here a fix :

   	 // Damn !? No reloadscript ?!
	if ( .char_name$ == "" ) {
		donpcevent strnpcinfo(3) + "::OnInit";
		sleep2 1; // Execute OnInit before continue.
	}

	mes "I give you an apple if you give me " + .char_name$ . "'s skull !";
	next;

	if ( countitem2( 7420, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16 ) ) {
			mes "Yeah you have the skull ! I give you an apple";
			delitem2 7420, 1, 1, 0, 0, 254, 0, .cible_cid & 0x00FFFF, .cible_cid >> 16;
			getitem 512, 1;
	}
	else {
			mes "Damn, you don't have it...";
	}
	close;

OnInit:
	set .char_name$, "Anonymous";
	query_sql("SELECT `char_id` FROM `char` WHERE `name`='" + escape_sql(.char_name$) + "' LIMIT 1", .cible_cid );
	if ( !.cible_cid )
		debugmes "[skull Trader] Invalid name specify ?";
	end;

I'll try this when I get back home. Thanks!

It works now however the delitem wont work :|.

Edited by laklaker

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...