A while ago, I started submitting some of what I've been working on to a public Gist where other people could view my code and use it for whatever it is they want to use it for. Perhaps some of you on here could benefit from reading my stuff or perhaps using it on your server. If you guys have any questions about what you've read on my Gist then just post them here and I'll try to answer them to the best of my ability. Whenever I make a new submission I'll also post a link to it here.
Thanks.
Text file guild system core - Sets you up with the functions you need to create a working guild system. You'll obviously need to script some kind of GUI around it to present guild data, adding new members, viewing rights, changing rights, etc.
Text file item system - Again, a set of functions that allows you to manipulate an item system for storing items, weapons, guns, whatever the hell you want.
Online & Offlines player property gathering - Allows you to gather data from an offline or online player including client/client flags and attrs.
There's more than that saved in my Gist but I don't think there's anything else worth mentioning here. If you'd like to see the rest of my Gist's contents, you can find my Gist page here.
As far as the guild system goes, here's an example of how you can use the functions provided to properly use the guild system.
It's not the best coding in the world, admittedly, but it shows you what you need to be shown. As for the online & offline player property gathering, it's pretty straight forward.PHP Code:
function onActionServerSide() {
temp.npc = findNPC("DB_Guilds");
switch (params[0]) {
case "setguild": {
if (!(temp.npc.guildExists(params[1]))) {
player.chat = "That guild doesn't exist!";
return;
}
if (!(temp.npc.isGuildMember(params[1], player.account))) {
player.chat = "I'm not a member of that guild!";
return;
}
player.guild = params[1];
break;
}
case "tryrecruit": {
if (hasGuildRight(player.guild, player.account, "add")) {
triggerclient("gui", name, "tryrecruit");
} else {
triggerclient("gui", name, "msg", "You don't have rights!");
}
break;
}
case "changerights": {
temp.pl = params[1];
temp.rights = params[2];
temp.ownrights = DB_Guilds.getGuildData(player.guild, "rights_" @ player.account);
if (!(hasGuildRight(player.guild, player.account, "editrights"))) {
triggerclient("gui", name, "msg", "You don't have rights!");
return;
}
if (pl == player.account) {
triggerclient("gui", name, "msg", "You can't edit your own rights!");
return;
}
for (r : temp.rights) {
if (!(r in ownrights)) {
if ("all" in temp.ownrights || temp.ownrights == "all") continue;
temp.failed = true;
}
}
if (failed == true) {
triggerclient("gui", name, "msg", "You tried to give rights you don't have access to yourself!");
return;
}
DB_Guilds.editGuildData(player.guild, "rights_" @ temp.pl, temp.rights, 1);
triggerclient("gui", name, "msg", "Success!");
break;
}
case "tryrename": {
temp.leader = DB_Guilds.getGuildData(player.guild, "leader");
if (temp.leader != player.account) {
triggerclient("gui", name, "msg", "Only the leader can do this!");
return;
}
temp.lines.loadlines("storage/guilds/settings/renamemessage.txt");
for (l : lines) {
temp.msg @= l @ "\n";
}
triggerclient("gui", name, "tryrename", temp.msg);
break;
}
case "kickplayer": {
temp.pl = params[1];
temp.rights = getGuildRights(player.guild, player.account);
temp.leader = DB_Guilds.getGuildData(player.guild, "leader");
if (temp.pl == temp.leader) {
triggerclient("gui", name, "msg", "You can't kick the leader!");
return;
}
if (hasGuildRight(player.guild, player.account, "kick")) {
DB_Guilds.kickGuildMember(player.guild, pl);
player.triggerclient("gui", name, "reloadguild");
} else {
triggerclient("gui", name, "msg", "You don't have rights!");
}
break;
}
case "loadguild": {
if (temp.npc.guildExists(player.guild) != true) {
return;
}
temp.data = temp.npc.getGuildDataFull(player.guild);
temp.members = temp.npc.getGuildData(player.guild, "members").tokenize(",");
for (member : temp.members) {
temp.memberdata.add({
member,
getPlayerData(member, "nick"),
getPlayerData(member, "head"),
temp.npc.getGuildData(player.guild, "rights_" @ member).tokenize(","),
temp.npc.getGuildData(player.guild, "rank_" @ member)
});
}
temp.avRights.loadlines("storage/guilds/settings/rights.txt");
temp.leader = temp.npc.getGuildData(player.guild, "leader");
triggerclient("gui", name, "loadguild", temp.data, temp.memberdata, temp.avRights, leader);
break;
}
case "getrights": {
temp.allrights.loadlines("storage/guilds/settings/rights.txt");
temp.playerrights = DB_Guilds.getGuildData(player.guild, "rights_" @ params[1]).tokenize(",");
temp.ownrights = DB_Guilds.getGuildData(player.guild, "rights_" @ player.account).tokenize(",");
triggerclient("gui", name, "getrights", allrights, playerrights, params[1], ownrights);
break;
}
}
}
function getGuildRights(g, p) {
temp.rights = findnpc("DB_Guilds").getGuildData(g, "rights_" @ p);
return temp.rights;
}
function hasGuildRight(g, p, r) {
temp.rights = getGuildRights(g, p).tokenize(",");
if (r in temp.rights || "all" in temp.rights || temp.rights == "all") {
return true;
} else {
return false;
}
}
PHP Code:
temp.hat = getPlayerProperty("Graal808129", "attr[1]");
temp.nick = getPlayerProperty("Graal808129", "nick");
temp.isstaff = getPlayerProperty("Graal808129", "clientr.isStaff");