//============================================================
//= Guildmake v1.0
//============================================================
prontera,102,128,6 script Guildo#guildmaker::guildmaker 653,{
function guildo_createguild;
function guildo_breakguild;
function guildo_createguildGER;
.@npcname$ = "^8B008B[Guildo]^000000";
if ( #language == 1 ) goto L_English;
mes .@npcname$;
mes "Suchst du nach einer Möglichkeit, eine Gilde mit";
mes "Leerzeichen im Namen zu erstellen? Dann kann ich dir helfen!";
mes "Bring mir einfach ein ^8B0000Emperium^000000, dann mach ich das für dich!";
next;
mes .@npcname$;
mes "Ich kann auch Gilden mit Leerzeichen im Namen für dich brechen.";
next;
switch(select("Erstellen:Auflösen:Nichts")) {
case 1:
mes .@npcname$;
mes "Bitte wähle den Namen für deine Gilde.";
next;
input .@gname$;
.@res = guildo_createguildGER(.@gname$);
mes .@npcname$;
switch(.@res) {
case 0:
mes "Machs gut!";
break;
case 1:
mes "Du bist doch schon in einer Gilde...";
break;
case 2:
mes "Wie gesagt: ein ^8B0000Emperium^000000 hätte ich gerne für meine Dienste.";
break;
case 3:
mes "Oh, das ist was schief gelaufen.";
break;
case 4:
mes "Sorry, die Gilde gibt es schon.";
break;
}
close;
break;
case 2:
mes .@npcname$;
mes "Bist du dir auch wirklich sicher?";
next;
switch(select("Nein, warte!:Ja, Gilde auflösen")) {
case 1:
mes .@npcname$;
mes "Okay, bis dann!";
close;
break;
case 2:
.@res = guildo_breakguildGER;
mes .@npcname$;
switch(.@res) {
case 0:
mes "Du bist frei.";
break;
case 1:
mes "Du bist in gar keiner Gilde!";
break;
case 2:
mes "Das wollen wir doch mal eurem Leader überlassen, was?";
break;
case 3:
mes "Ups, das hat nicht geklappt. Ist die Gilde schon leer?";
break;
}
close;
}
break;
}
close;
L_English:
mes .@npcname$;
mes "Are you looking for a way to create a guild with";
mes "Spaces in the name? Then I can help you!";
mes "Bring me an ^8B0000Emperium^000000, then I do it for you!";
next;
mes .@npcname$;
mes "I can also break guilds with spaces in the name for you.";
next;
switch(select("Create:Dissolve:Nothing")) {
case 1:
mes .@npcname$;
mes "Please choose a name for your guild.";
next;
input .@gname$;
.@res = guildo_createguild(.@gname$);
mes .@npcname$;
switch(.@res) {
case 0:
mes "Bye!";
break;
case 1:
mes "You are already in a guild...";
break;
case 2:
mes "How i said: an ^8B0000Emperium^000000 I would like for my services.";
break;
case 3:
mes "Oh, there went somthing wrong.";
break;
case 4:
mes "Sorry, the guild exists already.";
break;
}
close;
break;
case 2:
mes .@npcname$;
mes "Are you really sure?";
next;
switch(select("No, wait warte!:Yes, dissolve guild")) {
case 1:
mes .@npcname$;
mes "Okay, see you!";
close;
break;
case 2:
.@res = guildo_breakguild();
mes .@npcname$;
switch(.@res) {
case 0:
mes "You are free.";
break;
case 1:
mes "You are in no guild!";
break;
case 2:
mes "We want it out leave your Leader, what?";
break;
case 3:
mes "Oops, that did not work. Is the guild already empty?";
break;
}
close;
}
break;
}
close;
function guildo_createguild {
.@name$ = getarg(0);
set .@nb, query_sql("select `name` from `guild` where `guild`.`name`='"+escape_sql(.@name$)+"'", .@guilds$);
// guild already exists
if(getarraysize(.@guilds$) > 0) {
return 4;
}
// already in guild
if(getcharid(2) != 0) {
return 1;
}
// no emperium
if(countitem(714) == 0) {
return 2;
}
atcommand "@guild "+.@name$;
// here comes some nasty hack.
// It seems like the NPC caches the users guildid, which will still be 0.
// We have to let the NPC sleep which apparently empties the "cache" to check again, whether the creation was successful
set .@RID,getcharid(3);
sleep 1;
attachrid(.@RID);
// success
if(getcharid(2) != 0) {
return 0;
}
// user still not in guild - fail
return 3;
}
function guildo_createguildGER {
.@name$ = getarg(0);
set .@nb, query_sql("select `name` from `guild` where `guild`.`name`='"+escape_sql(.@name$)+"'", .@guilds$);
// guild already exists
if(getarraysize(.@guilds$) > 0) {
return 4;
}
// already in guild
if(getcharid(2) != 0) {
return 1;
}
// no emperium
if(countitem(714) == 0) {
return 2;
}
atcommand "@guild "+.@name$;
// here comes some nasty hack.
// It seems like the NPC caches the users guildid, which will still be 0.
// We have to let the NPC sleep which apparently empties the "cache" to check again, whether the creation was successful
set .@RID,getcharid(3);
sleep 1;
attachrid(.@RID);
// success
if(getcharid(2) != 0) {
return 0;
}
// user still not in guild - fail
return 3;
}
function guildo_breakguildGER {
.@name$ = getguildname(getcharid(2));
// no guild
if(getcharid(2) == 0) {
return 1;
}
// not guildmaster
if(getcharid(0,getguildmaster(getcharid(2))) != getcharid(0)) {
return 2;
}
atcommand "@breakguild "+.@name$;
// hack again
set .@RID,getcharid(3);
sleep 1;
attachrid(.@RID);
// still in guild - failed
if(getcharid(2) != 0) {
return 3;
}
return 0;
}
function guildo_breakguild {
.@name$ = getguildname(getcharid(2));
// no guild
if(getcharid(2) == 0) {
return 1;
}
// not guildmaster
if(getcharid(0,getguildmaster(getcharid(2))) != getcharid(0)) {
return 2;
}
atcommand "@breakguild "+.@name$;
// hack again
set .@RID,getcharid(3);
sleep 1;
attachrid(.@RID);
// still in guild - failed
if(getcharid(2) != 0) {
return 3;
}
return 0;
}
}