// https://rathena.org/board/topic/110783-npc-that-records-when-trading-an-item/
/* Please make sure you run this in your SQL.
ALTER TABLE `guild` ADD COLUMN `guild_point` INT(11) NOT NULL DEFAULT 0;
*/
prontera,155,181,5 script Sample#guildpoint 4_F_KAFRA1,{
switch ( select(
"Exchange Point",
"View Ranking"
)) {
case 1:
.@gid = getcharid(2);
if ( !.@gid ) {
mes "You didnt join any guild.";
}
else if ( getguildmasterid(.@gid) != getcharid(0) ) {
mes "only guild master can use this.";
}
else {
getinventorylist;
for ( .@i = 0; .@i < @inventorylist_count; .@i++ ) {
.@menu$ = .@menu$ + getitemname( @inventorylist_id[.@i] ) + ":";
}
mes "What items you want to exchange for Guild Point?";
.@i = select( .@menu$ ) - 1;
switch ( @inventorylist_id[.@i] ) {
default:
mes "Sorry this items worth nothing to me. Try again with others.";
break;
// case <item ID>: callsub( L_Exchange, @inventorylist_id[.@i], @inventorylist_amount[.@i], <MIN_AMOUNT>, <POINT_GAIN> );
case 512: callsub( L_Exchange, @inventorylist_id[.@i], @inventorylist_amount[.@i], 1, 1 ); break;
case 909: callsub( L_Exchange, @inventorylist_id[.@i], @inventorylist_amount[.@i], 2, 2 ); break;
case 1010: callsub( L_Exchange, @inventorylist_id[.@i], @inventorylist_amount[.@i], 3, 10 ); break;
}
}
break;
case 2:
query_sql( "SELECT `name`, `guild_point` FROM `guild` WHERE `guild_point` > 0 ORDER BY `guild_point` DESC LIMIT 10", .@guild_name$, .@guild_point );
.@size = getarraysize( .@guild_name$ );
mes "Guild Point Rank:";
for ( .@i = 0; .@i < .@size; .@i++ ) {
mes "["+( .@i + 1 )+".] "+.@guild_name$[.@i]+" - "+.@guild_point[.@i];
}
break;
}
close;
L_Exchange:
.@nameid = getarg( 0,0 );
.@countitem = getarg( 1,0 );
.@min_amount = getarg( 2,1 );
.@point = getarg( 3,1 );
mes "How many you want to exchange?";
mes "Every "+.@min_amount+"x "+getitemname( .@nameid )+" will give you "+.@point+" Guild Point(s)";
input .@amount,0,.@countitem;
if ( .@amount ) {
.@total_amount = ( .@amount / .@min_amount );
delitem .@nameid,( .@total_amount * .@min_amount );
mes "Exchanged "+( .@total_amount * .@min_amount )+"x "+getitemname( .@nameid )+" into "+.@total_amount+" Guild Point(s)";
query_sql( "UPDATE `guild` SET `guild_point` = `guild_point` + "+.@total_amount+" WHERE `guild_id` = "+getcharid(2)+" LIMIT 1" );
}
return;
}
Comments
0 B
|👍
/👎