/* create table guild_invite ( id int(11) unsigned primary key auto_increment, char_id int(11) unsigned, guild_id int(11) unsigned, key (char_id), key (guild_id), unique (char_id,guild_id) ) engine = innodb; */ - script kjhlkjgsdfds -1,{ OnInit: bindatcmd "guildinvite", strnpcinfo(0)+"::OnInvite", 0,100; bindatcmd "guildaccept", strnpcinfo(0)+"::OnAccept", 0,100; bindatcmd "guildreject", strnpcinfo(0)+"::OnReject", 0,100; bindatcmd "invitelist", strnpcinfo(0)+"::OnList", 0,100; // bindatcmd "guildjoin", strnpcinfo(0)+"::OnJoin", 0,100,0; end; OnJoin: .@gid = atoi( .@atcmd_parameters$ ); if ( getguildname( .@gid ) == "null" ) { requestguildinfo .@gid; sleep2 200; // slow down to retrieve information from char-server.exe } guildjoin .@gid, getcharid(0); end; OnInvite: .@origin_name$ = strcharinfo(0); .@gid = getcharid(2); if ( !.@gid ) { message .@origin_name$, "You must have a guild to use this command."; end; } if ( getguildmasterid( .@gid ) != getcharid(0) ) { message .@origin_name$, "You must be a guild master to use this command."; end; } if ( !( .@cid = getcharid( 0, .@atcmd_parameters$ ) ) ) { if ( !query_sql( "select char_id, guild_id, name from `char` where name = '"+ escape_sql( .@atcmd_parameters$ ) +"'", .@cid, .@player_gid, .@name$ ) ) { message .@origin_name$, "Player not exist"; end; } if ( .@player_gid ) { message .@origin_name$, "Player ["+ .@name$ +"] already has a guild."; end; } if ( query_sql( "select 1 from guild_invite where char_id = "+ .@cid +" and guild_id = "+ .@gid, .@dummy ) ) { message .@origin_name$, "Player ["+ .@name$ +"] has already invited by this guild."; end; } query_sql "insert into guild_invite values ( null, "+ .@cid +", "+ .@gid +" )"; message .@origin_name$, "The player ["+ .@name$ +"] will receive an invitation on his/her next login."; } else { .@name$ = rid2name( getcharid( 3, .@atcmd_parameters$ ) ); if ( getcharid( 2, .@name$ ) ) { message .@origin_name$, "Player ["+ .@name$ +"] already has a guild."; end; } if ( query_sql( "select 1 from guild_invite where char_id = "+ .@cid +" and guild_id = "+ .@gid, .@dummy ) ) { message .@origin_name$, "Player ["+ .@name$ +"] has already invited by this guild."; end; } query_sql "insert into guild_invite values ( null, "+ .@cid +", "+ .@gid +" )"; message .@name$, "You have an invitation by ["+ strcharinfo(0) +"] from the ["+ strcharinfo(2) +"] guild."; message .@origin_name$, "The player ["+ .@name$ +"] has received an invitation."; } end; OnAccept: .@origin_name$ = strcharinfo(0); if ( getcharid(2) ) { message strcharinfo(0), "You already have a guild."; end; } if ( !query_sql( "select guild_id from guild where name = '"+ escape_sql( .@atcmd_parameters$ ) +"'", .@gid ) ) { message .@origin_name$, "No such guild name exist."; end; } if ( getguildname( .@gid ) == "null" ) { requestguildinfo .@gid; sleep2 200; // slow down to retrieve information from char-server.exe } if ( !query_sql( "select 1 from guild_invite where char_id = "+ getcharid(0) +" and guild_id = "+ .@gid, .@dummy ) ) { message .@origin_name$, "You don't have invitation from that guild."; end; } guildjoin .@gid, getcharid(0); query_sql "delete from guild_invite where char_id = "+ getcharid(0); end; OnReject: query_sql "delete from guild_invite where char_id = "+ getcharid(0); message strcharinfo(0), "You have rejected all guild invitations."; end; OnList: if ( getcharid(2) ) { dispbottom "You already have a guild"; // query_sql "delete from guild_invite where char_id = "+ getcharid(0); end; } .@nb = query_sql( "select guild_id from guild_invite where char_id = "+ getcharid(0), .@gid ); if ( !.@nb ) { dispbottom "You don't have any guild invitation."; end; } for ( .@i = 0; .@i < .@nb; .@i++ ) { if ( getguildname( .@gid[.@i] ) == "null" ) { requestguildinfo .@gid[.@i]; sleep2 200; // slow down to retrieve information from char-server.exe } dispbottom ( .@i +1 )+". "+ getguildname( .@gid[.@i] ); } end; OnPCLoginEvent: .@nb = query_sql( "select guild_id from guild_invite where char_id = "+ getcharid(0), .@gid ); if ( !.@nb ) end; dispbottom "You have "+ .@nb +" pending guild invitations"; for ( .@i = 0; .@i < .@nb; .@i++ ) { if ( getguildname( .@gid[.@i] ) == "null" ) { requestguildinfo .@gid[.@i]; sleep2 200; // slow down to retrieve information from char-server.exe } dispbottom ( .@i +1 )+". "+ getguildname( .@gid[.@i] ); } end; }