PDA

View Full Version : Graal Improvement Script: Vote System for Staff Priorities


HoudiniMan
12-29-2007, 01:20 PM
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:

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
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
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
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
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


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 applyVPoint( vID, vText, vPoint, pAcc )
{
if( vPoint % 1 != 0 || vPoint == 0 ) return( MSG_RES_ERROR );
if( player.account.length() <= 0 ) return( MSG_RES_ERROR );
if( this.(@ "votepoints_" @ player.account ).size() == 0 || this.(@ "votepoints_" @ player.account ).length() == 0 )
{
this.(@ "votepoints_" @ player.account ).add( "0" );
}
if( ( vID != 0 && vID == null ) || vID < 0 || vID.length() <= 0 )
{
vID = getvID( vText );
if( vID == -1 ) return( MSG_RES_ERROR );
}
temp.fID = -1;
temp.pPoints = 0;

for( j = 1; j < this.(@ "votepoints_" @ player.account ).size(); j++ )
{
if( this.(@ "votepoints_" @ player.account )[ j ][ 0 ] == vID )
temp.fID = j;
temp.pPoints += ( this.(@ "votepoints_" @ player.account )[ j ][ 1 ] < 0 ? this.(@ "votepoints_" @ player.account )[ j ][ 1 ] * -1 : this.(@ "votepoints_" @ player.account )[ j ][ 1 ] ) * this.votes[ vID ][ 1 ];
}
//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 > 0 ? vPoint : vPoint * -1 ) > this.maxpoints && this.votes[ vID ][ 2 ] + this.votes[ vID ][ 3 ] >= 0 ) return( MSG_RES_ERROR );
if( vPoint != this.votes[ vID ][ 1 ] && vPoint != this.votes[ vID ][ 1 ] * -1 ) return( MSG_RES_ERROR );
if( temp.fID == -1 ) this.(@ "votepoints_" @ player.account ).add( { vID, vPoint } );
else
{
this.(@ "votepoints_" @ player.account )[ temp.fID ][ 1 ] += vPoint;
this.(@ "votepoints_" @ player.account )[ 0 ] = temp.pPoints + ( vPoint < 0 ? vPoint * -1 : vPoint );
}
reCalcVotePoints( vID );
return( getVoteList( pAcc ) );
}

public function getVoteList( pAcc )
{
if( pAcc == null || pAcc.length() <= 0 ) return( MSG_RES_ERROR );
return( { this.votes, this.(@ "votepoints_" @ pAcc ) } );
}

function reCalcVotePoints( vID )
{
temp.pPointsP = 0;
temp.pPointsN = 0;
if( ( vID != 0 && vID == null ) || vID < 0 || vID.length() <= 0 ) return( MSG_RES_ERROR );
for( temp.a: getstringkeys( "this.votepoints_" ) )
{
if( this.(@ "votepoints_" @ temp.a ) == null || this.(@ "votepoints_" @ temp.a ).length() == 0 || this.(@ "votepoints_" @ temp.a ).size() <= 1 ) continue;
temp.skipfirst = true;
for( temp.b: this.(@ "votepoints_" @ temp.a ) )
{
if( temp.skipfirst == true )
{
temp.skipfirst = false;
continue;
}
if( temp.b[ 0 ] == vID )
{
temp.(@ "pPoints" @ ( temp.b[ 1 ] > 0 ? "P" : "N" ) ) += temp.b[ 1 ];
}
}
}
this.votes[ vID ][ 2 ] = temp.pPointsP;
this.votes[ vID ][ 3 ] = temp.pPointsN;
}

public function addVote( voteText )
{
if( player.account in this.staff )
{
this.votes.add( { voteText, 1, 0, 0 } );
return( MSG_RES_OK );
}
return( MSG_RES_ERROR );
}

public function removeVote( vID, vText )
{
if( !( player.account in this.staff ) ) return( MSG_RES_ERROR );
if( vID == null || vID < 0 || vID.length() <= 0 )
{
vID = getvID( vText );
if( vID == -1 ) return( MSG_RES_ERROR );
}
if( this.votes[ vID ][ 0 ] != vText || ( vText.length() == 0 || vText == null || vText <= 0 ) ) return( MSG_RES_ERROR );
this.votes.delete( vID );
return( MSG_RES_OK );
}

function getvID( vText )
{
if( vText == null || vText < 0 || vText.length() <= 0 ) return( -1 );
vID = -1;
for( i = 0; i < this.votes.size(); i++ )
{
if( vText == this.votes[ i ][ 0 ] )
{
vID = i;
break;
}
}
if( vID == -1 ) return( -1 );
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)


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.x + 0.5, this.y + 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?

Chompy
01-02-2008, 10:54 PM
use triggerserver/triggerclient?

Doesn't work with DBs/NPCs :(

cbk1994
01-03-2008, 01:54 AM
Doesn't work with DBs/NPCs :(

You can trigger the client from a DB NPC, and you could always trigger a weapon and have it do wNPC.eventHere() or even wNPC.trigger( "eventHere", "" );

Chompy
01-03-2008, 06:37 PM
You can trigger the client from a DB NPC, and you could always trigger a weapon and have it do wNPC.eventHere() or even wNPC.trigger( "eventHere", "" );

Hence why on the first page I said I tried to put it all in one NPC :P, but I'll probably do what you say :O