Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Graal Improvement Script: Vote System for Staff Priorities (https://forums.graalonline.com/forums/showthread.php?t=78119)

HoudiniMan 12-29-2007 01:20 PM

Graal Improvement Script: Vote System for Staff Priorities
 
2 Attachment(s)
This thread is for a Graal Improvement Script - a script that is freely distributed for any server to use (its creators credited of course ;)) for the general improvement of Graal servers.

The NPC I would like assistance to script is illustrated in the attached image. If any of you have ever used Dreamhost, you will be familiar with the concept.

Summary:

A player gets X ammount of vote points to spend.

Suggestions are moderated by the staff and managed through a GUI. Access control to this will be set at the top of the script so servers can customize the staff detection to their current systems. (Ie, if player has a staff flag, or is in serverops, or a certain accounts list, etc.)

Once a suggestion is added a player can spend their points to vote For or Against (+ or -) on a suggestion. The suggestion's rank is then calculated by tallying the For votes and subtracting the Against votes to give you the # of player points contributed to this suggestion by popular opinion.

Example:

HTML Code:

Move fishing house closer to unstick me?  +  24  -
Move fishing house closer to jail?        +  2  -
Move fishing house closer to faraway town? +  -8  -

Suggestions are then displayed in the suggestion tracker by the current rank, positive at the top. Any suggestion you spend points on is "stickied" at the top, so you can easily manage the points you are using and where.

If a suggestion is removed from the list, you regain those points to use elsewhere. You can remove or add points at any time as long as your total votes are less than the X number of points you have to spend.

You'll see in the image below the Dreamhost system has different "costs" for votes on different things (they decide the cost of a vote based on the difficulty of implementing the idea). For our purposes, the costs will all initially be 1. (Ie, a vote costs 1 point.) It would be nice to add that feature in the future, but I'd really like to get a working version of this deployed ASAP :)

Thank you in advance for the time put into this idea, your names will be credited in the script. You may also add a tasteful credit for players to see, be it an "About" button, or a small blurb somewhere saying "Created by ____" :)

Collaborate! I don't want anybody bearing the whole load on these :)
Also, if I've been unclear on anything just ask :)

cbk1994 12-29-2007 03:43 PM

Goood luck, I wish I could help, but at the moment I don't have a computer, and I'm not going to try scripting on a phone ;)

Novo 12-29-2007 10:08 PM

Can't you just have a browser-version of it? Having Dreamhost or whatever manage it already instead of having it as an in-game version of it... Maybe if in-game is so important, have a browser in the game.

Way I see it is it's merely just reinventing the wheel.

Angel_Light 12-29-2007 10:21 PM

Quote:

Originally Posted by Novo (Post 1366680)
Can't you just have a browser-version of it? Having Dreamhost or whatever manage it already instead of having it as an in-game version of it... Maybe if in-game is so important, have a browser in the game.

Way I see it is it's merely just reinventing the wheel.

There is a browser in game, and a computer to use with it, you can send email to anyone server.... *goes off on a tangent* :P

projectigi 12-30-2007 12:47 AM

Quote:

Originally Posted by Novo (Post 1366680)
Can't you just have a browser-version of it? Having Dreamhost or whatever manage it already instead of having it as an in-game version of it... Maybe if in-game is so important, have a browser in the game.

Way I see it is it's merely just reinventing the wheel.

yeah, why make new games, i mean, we could just take parts of other games :P

oh wait, they already do this

HoudiniMan 12-30-2007 12:59 AM

Quote:

Originally Posted by cbkbud (Post 1366571)
Goood luck, I wish I could help, but at the moment I don't have a computer, and I'm not going to try scripting on a phone ;)

How long till you get back online? It seems like nobody else is interested in helping out.

projectigi 12-30-2007 01:21 AM

Quote:

Originally Posted by HoudiniMan (Post 1366724)
How long till you get back online? It seems like nobody else is interested in helping out.

well i already started, but i'm kinda stuck with array sorting x.x

trevor987 12-30-2007 11:29 PM

This script would be pretty useful to have for replacing the common Yes/No or multiple choice voting system. Right now things are somewhat busy with the server I work on, but I'll try to start playing around with something soon.

Chompy 01-01-2008 05:07 AM

I'm working on it right now ;o

I think I might be done later today tho, maybe

projectigi 01-01-2008 11:12 AM

well, I would be already done, but the script compiler hates me XD so good luck chompy

Chompy 01-01-2008 10:08 PM

Well, it's making progress, but a little slower because of being busy (*cough* New Year *cough*)..

HoudiniMan 01-01-2008 10:43 PM

Post what you have guys, work together!

projectigi 01-02-2008 12:00 AM

well got a little more complicated than i thought in the beginning xD
I'm stuck because of the Bug with the param going to 0(see my other thread here for that), but If you want I will post it even if its not fully finished

NPC VotingControlSystem

PHP Code:

enum
  
{
  
MSG_RES_ERROR,   // 0 == false
  
MSG_RES_OK       // 1 == true
  
}

function 
onCreated()
  {
  
//#CONFIG SECTION
  
this.maxpoints 5//Maximum Points per Player
  
this.staff = { "projectigi" };
  
//#END CONFIG SECTION
  
}
  
public function 
applyVPointvIDvTextvPointpAcc )
  {
  if( 
vPoint != || vPoint == ) return( MSG_RES_ERROR );
  if( 
player.account.length() <= ) return( MSG_RES_ERROR );
  if( 
this.(@ "votepoints_" player.account ).size() == || this.(@ "votepoints_" player.account ).length() == )
    {
    
this.(@ "votepoints_" player.account ).add"0" );
    }
  if( ( 
vID != && vID == null ) || vID || vID.length() <= )
    {
    
vID getvIDvText );
    if( 
vID == -) return( MSG_RES_ERROR );
    }  
  
temp.fID = -1;
  
temp.pPoints 0;

  for( 
1this.(@ "votepoints_" player.account ).size(); j++ )
    {
    if( 
this.(@ "votepoints_" player.account )[ ][ ] == vID )
      
temp.fID j;
    
temp.pPoints += ( this.(@ "votepoints_" player.account )[ ][ ] < this.(@ "votepoints_" player.account )[ ][ ] * -this.(@ "votepoints_" player.account )[ ][ ] ) * this.votesvID ][ ];
    }
  
//if( temp.pPoints == this.maxpoints && vPoint > 0 ) return( MSG_RES_ERROR );
  
if( temp.pPoints this.maxpoints )
    {
    
sendtorc"{Vote-Error] Player " player.account " has more than " this.maxpoints " points on votes.(Hacker?)" );
    return( 
MSG_RES_ERROR );
    }
//echo( ( vPoint > 0 ? vPoint : vPoint * -1 ) SPC temp.pPoints );
  
if( temp.pPoints + ( vPoint vPoint vPoint * -) > this.maxpoints && this.votesvID ][ ] + this.votesvID ][ ] >= ) return( MSG_RES_ERROR );
  if( 
vPoint != this.votesvID ][ ] && vPoint != this.votesvID ][ ] * -) return( MSG_RES_ERROR );
  if( 
temp.fID == -this.(@ "votepoints_" player.account ).add( { vIDvPoint } );
  else
    {
    
this.(@ "votepoints_" player.account )[ temp.fID ][ ] += vPoint;
    
this.(@ "votepoints_" player.account )[ ] = temp.pPoints + ( vPoint vPoint * -vPoint );
    }
  
reCalcVotePointsvID );
  return( 
getVoteListpAcc ) );
  }
  
public function 
getVoteListpAcc )
  {
  if( 
pAcc == null || pAcc.length() <= ) return( MSG_RES_ERROR );
  return( { 
this.votesthis.(@ "votepoints_" pAcc ) } );
  }
  
function 
reCalcVotePointsvID )
  {
  
temp.pPointsP 0;
  
temp.pPointsN 0;  
  if( ( 
vID != && vID == null ) || vID || vID.length() <= ) return( MSG_RES_ERROR );
  for( 
temp.agetstringkeys"this.votepoints_" ) )
    {
    if( 
this.(@ "votepoints_" temp.) == null || this.(@ "votepoints_" temp.).length() == || this.(@ "votepoints_" temp.).size() <= ) continue;
    
temp.skipfirst true;
    for( 
temp.bthis.(@ "votepoints_" temp.) )
      {
      if( 
temp.skipfirst == true )
        {
        
temp.skipfirst false;
        continue;
        }
      if( 
temp.b] == vID )
        {
        
temp.(@ "pPoints" @ ( temp.b] > "P" "N" ) ) += temp.b];
        }
      }
    }
  
this.votesvID ][ ] = temp.pPointsP;
  
this.votesvID ][ ] = temp.pPointsN;
  }  
  
public function 
addVotevoteText )
  {
  if( 
player.account in this.staff )
    {
    
this.votes.add( { voteText10} );
    return( 
MSG_RES_OK );  
    }
  return( 
MSG_RES_ERROR );
  }
  
public function 
removeVotevIDvText )
  {
  if( !( 
player.account in this.staff ) ) return( MSG_RES_ERROR );
  if( 
vID == null || vID || vID.length() <= )
    {
    
vID getvIDvText );
    if( 
vID == -) return( MSG_RES_ERROR );
    }
  if( 
this.votesvID ][ ] != vText || ( vText.length() == || vText == null || vText <= ) ) return( MSG_RES_ERROR );
  
this.votes.deletevID );
  return( 
MSG_RES_OK );
  }  
  
function 
getvIDvText )
  {
  if( 
vText == null || vText || vText.length() <= ) return( -);
  
vID = -1;
  for( 
0this.votes.size(); i++ )
    {
    if( 
vText == this.votes][ ] )
      {
      
vID i;
      break;
      }
    }
  if( 
vID == -) return( -);
  return( 
vID );  
  } 

Weapon:

too long for a post...(17k characters, 10k is limit lol)
http://nopaste.info/1e0eb25243.html

Chompy 01-02-2008 08:49 PM

Hmm, I was mainly going to do it all in one NPC, but that would be odd, so I need to change my code :(

I was thinking of some features, dunno if they are needed tho: (This is the config() function)

PHP Code:

function config() {
  
this.categories = { // Add categories here
    
"General",
    
"Level Design",
    
"Errors",
    
"Suggestions",
    
"New Features"
  
};
  
this.vote_mode 1/* 1 will give you an amount of
                           points per voting alternative.
                           
                         2 will give you max amount of
                           points to spend on voting */
                           
  
this.points 3/* mode 1 = amount of points per alternative
                      mode 2 = max amount of points to vote with */
  
  
this.minimum_alternatives 3/* minimum amount of alter-
                                    tives that you need before
                                    mode 1 will be used. Until
                                    then (mode 1) there will be 1 point
                                    per alternative */
                                    
  
this.default_category "Misc"/* When adding an alternative
                                     and the category isn't listed
                                     in this.categories this will
                                     be listed as the category instead */
  
this.canvote false// if the player can vote, if command is disabled it must be turned on with a rc command 
  
clearAlternatives();
  
  
// Add alternatives here: alternative(category, suggestion);
  
alternative("Level Design""Move the osl to an other island");
  
alternative("General""Allow players to buy secret weapons");
  
alternative("New Features""Allow more options with the party system");
  
alternative("General""Release mining");
  
  
temp.array = getAlternatives();
  
triggeraction(this.0.5this.0.5"Client""sync", array);


Only problem is that, by using one npc/db I have to use triggeraction() :(
And triggeraction() is being annoying from serverside to clientside when it works clientside to serverside :(

Angel_Light 01-02-2008 10:52 PM

use triggerserver/triggerclient?


All times are GMT +2. The time now is 04:37 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.