Results 1 to 3 of 3

Thread: Emera's Submissions

  1. #1

    Post Emera's Submissions

    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.

    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.guildplayer.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.guildplayer.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 (
    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.pltemp.rights1);
          
    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 (
    lines) {
            
    temp.msg @= "\n";
          }
          
    triggerclient("gui"name"tryrename"temp.msg);
          break;
        }
        
        case 
    "kickplayer": {
          
    temp.pl params[1];
          
    temp.rights getGuildRights(player.guildplayer.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.guildplayer.account"kick")) {
            
    DB_Guilds.kickGuildMember(player.guildpl);
            
    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.datatemp.memberdatatemp.avRightsleader);
          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"allrightsplayerrightsparams[1], ownrights);
          break;
        }
      }
    }

    function 
    getGuildRights(gp) {
      
    temp.rights findnpc("DB_Guilds").getGuildData(g"rights_" p);
      return 
    temp.rights;
    }

    function 
    hasGuildRight(gpr) {
      
    temp.rights getGuildRights(gp).tokenize(",");
      if (
    r in temp.rights || "all" in temp.rights || temp.rights == "all") {
        return 
    true;
      } else {
        return 
    false;
      }

    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:
    temp.hat getPlayerProperty("Graal808129""attr[1]");
    temp.nick getPlayerProperty("Graal808129""nick");
    temp.isstaff getPlayerProperty("Graal808129""clientr.isStaff"); 
    Last edited by Emera; 09-03-2013 at 08:04 PM.

  2. #2
    Big Cheese 3.X's Avatar
    Join Date
    Jun 2013
    Location
    Texas
    Posts
    1,638
    So this is coding for a guild system?
    Live your life, enjoy it while it lasts. Don't give it up when you are down, you are a light like the stars in a sky.

  3. #3
    Quote Originally Posted by 3.X View Post
    So this is coding for a guild system?
    As explained, that's one of the systems included in the OP.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •