Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 29

Thread: Check if player is staff + add a rank

  1. #1
    Soldier
    Join Date
    Jun 2013
    Location
    France
    Posts
    55

    Check if player is staff + add a rank

    Hello,
    So I'm trying to create a function who would check if player is in staff list and then if player is staff it would give him a rank for his Tools Access. But I do not know how to access to the server option (I tried server.staff (with tokenize) but without result). So here is my question, how can I get the server option value, to know all the staff members?

  2. #2
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    serveroptions.*

    for example, serveroptions.staff returns an array of all staff listed in the staff=..., what you can do is if (player.account in serveroptions.staff) ...
    -Johnaudi

  3. #3
    Soldier
    Join Date
    Jun 2013
    Location
    France
    Posts
    55
    Okay thanks you, I also tried another things to let me add ranks to each staff but I don't know if it's really secure to do it like that:
    PHP Code:
    function staffMembers(account){
      
    isStaffMember false;
      
    //staffArray: id, rank, name
      
    this.staffArray = {
        {
    "GraalID",Rank"Name"},
        {
    "GraalID2",Rank2"Name2"}
      };
      
      for (
    temp.0this.staffArray.size(); i++)
      {
        if(
    account == this.staffArray[i][0])
        {
          
    isStaffMember true;
          
    memberRank this.staffArray[i][1];
        }
      }

    and serveroptions.staff or serveroptions.staff.tokenize(",") always return 0:
    PHP Code:
    //#CLIENTSIDE
    function onPlayerChats(){
      if(
    player.account in serveroptions.staff.tokenize(",")){
        
    player.chat "You are Staff!";
      }
      else{
        
    player.chat serveroptions.staff;
      }


  4. #4
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    serveroptions.staff is a serverside variable:

    PHP Code:
    function onActionServerSide() {
      if (
    player.account in serveroptions.staffplayer.chat "I'm staff!";
    }
    //#CLIENTSIDE
    function onCreated() {
      
    triggerserver("weapon"this.name"");

    -Johnaudi

  5. #5
    Soldier
    Join Date
    Jun 2013
    Location
    France
    Posts
    55
    Oh okay and what do you think about my 2nd method?

  6. #6
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    It's not a great idea to store staff IDs in a weapon, having it in serveroptions is better.

    But I like how far you've gone with it, I have cleaned it up for you:

    PHP Code:
    function isStaffMember(acc){
      
    temp.staffArray = {
        {
    "GraalID"Rank"Name"},
        {
    "GraalID2"Rank2"Name2"}
      };
      
      for (
    temp.0temp.staffArray.size(); i++)
      {
        if(
    acc == temp.staffArray[i][0])
        {
          return { 
    temp.staffArray[i][1], temp.staffArray[i][2] };
        }
      } return 
    "Not a staff member";

    -Johnaudi

  7. #7
    Soldier
    Join Date
    Jun 2013
    Location
    France
    Posts
    55
    Thanks, and whats about if I store it into a DB NPC? Or I could also use serveroption then in a database I set the GraalId and the rank and check it with database, which could be more secure, hmmmm?

  8. #8
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    Having the settings saved in the SO is your best guess.

    Unless you have a list of constants of each account, that would be cool, but that's way too advanced and useless.
    -Johnaudi

  9. #9
    Soldier
    Join Date
    Jun 2013
    Location
    France
    Posts
    55
    What SO stand for?

  10. #10
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    ServerOptions
    -Johnaudi

Posting Permissions

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